Skip to content

Commit

Permalink
fix encoding of public key for audience
Browse files Browse the repository at this point in the history
  • Loading branch information
cypherhat committed Dec 9, 2018
1 parent 905d7d4 commit a902ab8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
2 changes: 1 addition & 1 deletion path_audience.go
Expand Up @@ -93,7 +93,7 @@ func (b *backend) pathAudiencesCreate(ctx context.Context, req *logical.Request,
return nil, err
}
publicKeyBytes := crypto.FromECDSAPub(pubkey)
publicKey := hexutil.Encode(publicKeyBytes)
publicKey := hex.EncodeToString(publicKeyBytes)
address := crypto.PubkeyToAddress(*pubkey)

audienceJSON := &Audience{
Expand Down
16 changes: 0 additions & 16 deletions util.go
Expand Up @@ -18,9 +18,7 @@ import (
"bytes"
"context"
"crypto/ecdsa"
"crypto/x509"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -194,20 +192,6 @@ func hashKeccak256(data string) []byte {
return hash
}

func encodePrivateKey(privateKey *ecdsa.PrivateKey) string {
x509Encoded, _ := x509.MarshalECPrivateKey(privateKey)
pemEncoded := pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: x509Encoded})

return string(pemEncoded)
}

func encodePublicKey(publicKey *ecdsa.PublicKey) string {
x509EncodedPub, _ := x509.MarshalPKIXPublicKey(publicKey)
pemEncodedPub := pem.EncodeToMemory(&pem.Block{Type: "PUBLIC KEY", Bytes: x509EncodedPub})

return string(pemEncodedPub)
}

// ZeroKey removes the key from memory
func ZeroKey(k *ecdsa.PrivateKey) {
b := k.D.Bits()
Expand Down

0 comments on commit a902ab8

Please sign in to comment.