Skip to content

Commit

Permalink
Merge pull request #123 from relab/fixeddsa
Browse files Browse the repository at this point in the history
Fix eddsa private key parsing bug
  • Loading branch information
meling authored Mar 12, 2024
2 parents 301532c + 18716fd commit daffe57
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crypto/keygen/keygen.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,15 @@ func ParsePrivateKey(buf []byte) (key hotstuff.PrivateKey, err error) {
case ecdsacrypto.PrivateKeyFileType:
key, err = x509.ParseECPrivateKey(b.Bytes)
case eddsa.PrivateKeyFileType:
key = ed25519.NewKeyFromSeed(b.Bytes[:32])
genericKey, err := x509.ParsePKCS8PrivateKey(b.Bytes)
if err != nil {
return nil, err
}
var ok bool
key, ok = genericKey.(ed25519.PrivateKey)
if !ok {
return nil, fmt.Errorf("failed to parse key")
}
case bls12.PrivateKeyFileType:
k := &bls12.PrivateKey{}
k.FromBytes(b.Bytes)
Expand Down

0 comments on commit daffe57

Please sign in to comment.