Skip to content

Commit 29537e9

Browse files
committed
add some testcases
1 parent ab3a994 commit 29537e9

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

cases_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ var testCases = []struct {
3838
nil,
3939
"",
4040
},
41+
{
42+
"6d6c66873739bc7bfb3526629670d0ea357e92cc4581490d62779ae15f6b787b",
43+
"026d7f1d87ab3bbc8bc01f95d9aece1e659d6e33c880f8efa65facf83e698bbbf7",
44+
"b2f0cd8ecb23c1710903f872c31b0fd37e15224af457722a87c5e0c7f50fffb3",
45+
"68ca1cc46f291a385e7c255562068357f964532300beadffb72dd93668c0c1cac8d26132eb3200b86d66de9c661a464c6b2293bb9a9f5b966e53ca736c7e504f",
46+
true,
47+
nil,
48+
"",
49+
},
4150
{
4251
"",
4352
"03DEFDEA4CDB677750A420FEE807EACF21EB9898AE79B9768766E4FAA04A2D4A34",
@@ -155,4 +164,13 @@ var testCases = []struct {
155164
errors.New("s is larger than or equal to curve order"),
156165
"sig[32:64] is equal to curve order",
157166
},
167+
{
168+
"",
169+
"6d6c66873739bc7bfb3526629670d0ea",
170+
"b2f0cd8ecb23c1710903f872c31b0fd37e15224af457722a87c5e0c7f50fffb3",
171+
"2A298DACAE57395A15D0795DDBFD1DCB564DA82B0F269BC70A74F8220429BA1D1E51A22CCEC35599B8F266912281F8365FFC2D035A230434A1A64DC59F7013FD",
172+
false,
173+
errors.New("signature verification failed"),
174+
"public key is only 16 bytes",
175+
},
158176
}

schnorr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func Verify(publicKey [33]byte, message [32]byte, signature [64]byte) (bool, err
8585
}
8686

8787
// AggregateSignatures aggregates multiple signatures of different private keys over
88-
// the same message into a single 64 byte signature.
88+
// the same message into a single 64 byte signature. (Experimental)
8989
func AggregateSignatures(privateKeys []*big.Int, message [32]byte) ([64]byte, error) {
9090
sig := [64]byte{}
9191
if privateKeys == nil || len(privateKeys) == 0 {

schnorr_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ func TestAggregateSignatures(t *testing.T) {
5757
continue
5858
}
5959

60-
pubKey, ok := new(big.Int).SetString(test.pk, 16)
60+
privKey, ok := new(big.Int).SetString(test.d, 16)
6161
if !ok {
62-
t.Fatalf("Unexpected error from new(big.Int).SetString(%s, 16)", test.pk)
62+
t.Fatalf("Unexpected error from new(big.Int).SetString(%s, 16)", test.d)
6363
}
64-
pks = append(pks, pubKey)
64+
pks = append(pks, privKey)
6565

6666
if i == 0 {
6767
message, err := hex.DecodeString(test.m)
@@ -71,7 +71,7 @@ func TestAggregateSignatures(t *testing.T) {
7171
copy(m[:], message)
7272
}
7373

74-
Px, Py := Curve.ScalarBaseMult(pubKey.Bytes())
74+
Px, Py := Curve.ScalarBaseMult(privKey.Bytes())
7575
Pxs = append(Pxs, Px)
7676
Pys = append(Pys, Py)
7777
}

0 commit comments

Comments
 (0)