Skip to content

Commit a902ab8

Browse files
committed
fix encoding of public key for audience
1 parent 905d7d4 commit a902ab8

File tree

2 files changed

+1
-17
lines changed

2 files changed

+1
-17
lines changed

path_audience.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (b *backend) pathAudiencesCreate(ctx context.Context, req *logical.Request,
9393
return nil, err
9494
}
9595
publicKeyBytes := crypto.FromECDSAPub(pubkey)
96-
publicKey := hexutil.Encode(publicKeyBytes)
96+
publicKey := hex.EncodeToString(publicKeyBytes)
9797
address := crypto.PubkeyToAddress(*pubkey)
9898

9999
audienceJSON := &Audience{

util.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ import (
1818
"bytes"
1919
"context"
2020
"crypto/ecdsa"
21-
"crypto/x509"
2221
"encoding/json"
23-
"encoding/pem"
2422
"errors"
2523
"fmt"
2624
"io/ioutil"
@@ -194,20 +192,6 @@ func hashKeccak256(data string) []byte {
194192
return hash
195193
}
196194

197-
func encodePrivateKey(privateKey *ecdsa.PrivateKey) string {
198-
x509Encoded, _ := x509.MarshalECPrivateKey(privateKey)
199-
pemEncoded := pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: x509Encoded})
200-
201-
return string(pemEncoded)
202-
}
203-
204-
func encodePublicKey(publicKey *ecdsa.PublicKey) string {
205-
x509EncodedPub, _ := x509.MarshalPKIXPublicKey(publicKey)
206-
pemEncodedPub := pem.EncodeToMemory(&pem.Block{Type: "PUBLIC KEY", Bytes: x509EncodedPub})
207-
208-
return string(pemEncodedPub)
209-
}
210-
211195
// ZeroKey removes the key from memory
212196
func ZeroKey(k *ecdsa.PrivateKey) {
213197
b := k.D.Bits()

0 commit comments

Comments
 (0)