Skip to content

Commit

Permalink
Add function GenPrivKeyFromSeed (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio-mena authored Jul 17, 2024
1 parent 618779f commit 9e92117
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion curves/bls12381/secret_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ func RandKey() (SecretKey, error) {
if err != nil {
return nil, err
}
return GenPrivKeyFromSeed(ikm)
}

// GenPrivKeyFromSeed creates a new private key directly from the seed passed as parameter
func GenPrivKeyFromSeed(seed [32]byte) (SecretKey, error) {
// Defensive check, that we have not generated a secret key,
secKey := &bls12SecretKey{blst.KeyGen(ikm[:])}
secKey := &bls12SecretKey{blst.KeyGen(seed[:])}
if IsZero(secKey.Marshal()) {
return nil, errors.New("received secret key is zero")
}
Expand Down

0 comments on commit 9e92117

Please sign in to comment.