From 9e9211771840f83f0905eecab4a7605876aed7cd Mon Sep 17 00:00:00 2001 From: Sergio Mena Date: Wed, 17 Jul 2024 15:46:34 +0200 Subject: [PATCH] Add function `GenPrivKeyFromSeed` (#5) --- curves/bls12381/secret_key.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/curves/bls12381/secret_key.go b/curves/bls12381/secret_key.go index 917f627..9ebcd08 100644 --- a/curves/bls12381/secret_key.go +++ b/curves/bls12381/secret_key.go @@ -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") }