Skip to content
Snippets Groups Projects
Commit c3bbc1ca authored by Josh Brooks's avatar Josh Brooks
Browse files

Improve documentation

parent 3a0bb1fd
Branches
Tags
2 merge requests!117Release,!74Implement bindings for downloading and verifying signed partial NDF
...@@ -22,10 +22,9 @@ import ( ...@@ -22,10 +22,9 @@ import (
// ndfUrl is a hardcoded url to a bucket containing the signed NDF message. // ndfUrl is a hardcoded url to a bucket containing the signed NDF message.
const ndfUrl = `elixxir.io` const ndfUrl = `elixxir.io`
// DownloadSignedNdf retrieves the NDF from a hardcoded bucket URL. // DownloadSignedNdf retrieves the NDF from a hardcoded bucket URL.
// The NDF returned requires further processing and verification // The NDF returned requires further processing and verification
// before being used. Use VerifySignedNdf to properly process // before being used. Use ProcessSignedNdf to properly process
// the downloaded data returned. // the downloaded data returned.
// DO NOT USE THE RETURNED DATA TO START A CLIENT. // DO NOT USE THE RETURNED DATA TO START A CLIENT.
func DownloadSignedNdf() ([]byte, error) { func DownloadSignedNdf() ([]byte, error) {
...@@ -49,10 +48,10 @@ func DownloadSignedNdf() ([]byte, error) { ...@@ -49,10 +48,10 @@ func DownloadSignedNdf() ([]byte, error) {
// DownloadSignedNdfWithUrl retrieves the NDF from a specified URL. // DownloadSignedNdfWithUrl retrieves the NDF from a specified URL.
// The NDF returned requires further processing and verification // The NDF returned requires further processing and verification
// before being used. Use VerifySignedNdf to properly process // before being used. Use ProcessSignedNdf to properly process
// the downloaded data returned. // the downloaded data returned.
// DO NOT USE THE RETURNED DATA TO START A CLIENT. // DO NOT USE THE RETURNED DATA TO START A CLIENT.
func DownloadSignedNdfWithUrl(url, cert string) ([]byte, error) { func DownloadSignedNdfWithUrl(url string) ([]byte, error) {
// Build a reqeust for the file // Build a reqeust for the file
resp, err := http.Get(url) resp, err := http.Get(url)
if err != nil { if err != nil {
...@@ -71,13 +70,13 @@ func DownloadSignedNdfWithUrl(url, cert string) ([]byte, error) { ...@@ -71,13 +70,13 @@ func DownloadSignedNdfWithUrl(url, cert string) ([]byte, error) {
return signedNdfEncoded, nil return signedNdfEncoded, nil
} }
// VerifySignedNdf takes the downloaded NDF from either // ProcessSignedNdf takes the downloaded NDF from either
// DownloadSignedNdf or DownloadSignedNdfWithUrl (signedNdfEncoded) // DownloadSignedNdf or DownloadSignedNdfWithUrl (signedNdfEncoded)
// an the scheduling certificate (cert). The downloaded NDF is parsed // and the scheduling certificate (cert). The downloaded NDF is parsed
// into a protobuf containing a signature. The signature is verified using the // into a protobuf containing a signature. The signature is verified using the
// passed in cert. Upon successful parsing and verification, the NDF is // passed in cert. Upon successful parsing and verification, the NDF is
// returned. This may be used to start a client. // returned as byte data, which may be used to start a client.
func VerifySignedNdf(signedNdfEncoded []byte, cert string) ([]byte, error) { func ProcessSignedNdf(signedNdfEncoded []byte, cert string) ([]byte, error) {
// Base64 decode the signed NDF // Base64 decode the signed NDF
signedNdfMarshaled, err := base64.StdEncoding.DecodeString( signedNdfMarshaled, err := base64.StdEncoding.DecodeString(
string(signedNdfEncoded)) string(signedNdfEncoded))
...@@ -93,7 +92,6 @@ func VerifySignedNdf(signedNdfEncoded []byte, cert string) ([]byte, error) { ...@@ -93,7 +92,6 @@ func VerifySignedNdf(signedNdfEncoded []byte, cert string) ([]byte, error) {
"signed NDF into protobuf") "signed NDF into protobuf")
} }
// Load the certificate from it's PEM contents // Load the certificate from it's PEM contents
schedulingCert, err := tls.LoadCertificate(cert) schedulingCert, err := tls.LoadCertificate(cert)
if err != nil { if err != nil {
...@@ -114,4 +112,3 @@ func VerifySignedNdf(signedNdfEncoded []byte, cert string) ([]byte, error) { ...@@ -114,4 +112,3 @@ func VerifySignedNdf(signedNdfEncoded []byte, cert string) ([]byte, error) {
return signedNdfMsg.Ndf, nil return signedNdfMsg.Ndf, nil
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment