Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio-mena committed Jul 17, 2024
1 parent 9e92117 commit 486322e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 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,22 @@ func TestSignVerify(t *testing.T) {
assert.Equal(t, true, sig.Verify(pub, msg), "Signature did not verify")
}

func TestSignVerifyRecreatedKey(t *testing.T) {
//seed := [32]byte(sha256.Sum("this is my little key"))
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.Equal(t, true, 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 486322e

Please sign in to comment.