Skip to content

Commit

Permalink
Add unit test for function GenPrivKeyFromSeed (#6)
Browse files Browse the repository at this point in the history
* add unit test

* Update curves/bls12381/signature_test.go

* Update curves/bls12381/signature_test.go

* small improvement
  • Loading branch information
sergio-mena committed Jul 17, 2024
1 parent 9e92117 commit bb8c5de
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions curves/bls12381/signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package blst

import (
"bytes"
"crypto/sha256"
"errors"
"reflect"
"testing"
Expand All @@ -19,6 +20,20 @@ func TestSignVerify(t *testing.T) {
assert.Equal(t, true, sig.Verify(pub, msg), "Signature did not verify")
}

func TestSignVerifyRecreatedKey(t *testing.T) {
seedStr := []byte("this is my little key")
seed := sha256.Sum256(seedStr)
priv, err := GenPrivKeyFromSeed(seed)
require.NoError(t, err)
msg := []byte("hello crypto")
sig := priv.Sign(msg)

priv2, err := GenPrivKeyFromSeed(seed)
require.NoError(t, err)
pub2 := priv2.PublicKey()
assert.True(t, sig.Verify(pub2, msg), "Signature did not verify")
}

func TestVerifySingleSignature_InvalidSignature(t *testing.T) {
priv, err := RandKey()
require.NoError(t, err)
Expand Down

0 comments on commit bb8c5de

Please sign in to comment.