-
Notifications
You must be signed in to change notification settings - Fork 15
/
aug_scheme_mpl_test.go
54 lines (43 loc) · 1.02 KB
/
aug_scheme_mpl_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package bls
import (
"encoding/hex"
"testing"
)
func TestSign(t *testing.T) {
asm := new(AugSchemeMPL)
sk := KeyGen(testSeed)
sign := asm.Sign(sk, []byte("chuwt"))
t.Log("signedMsg:", hex.EncodeToString(sign))
t.Log("verify:", asm.Verify(sk.GetPublicKey(), []byte("chuwt"), sign))
}
func TestAggregate(t *testing.T) {
asm := new(AugSchemeMPL)
masterSk := KeyGen(testSeed)
farmerSk := masterSk.FarmerSk()
farmerPk := farmerSk.GetPublicKey()
poolSk := masterSk.PoolSk()
poolPk := poolSk.GetPublicKey()
// 签名
sig1 := asm.Sign(farmerSk, []byte("chuwt1"))
sig2 := asm.Sign(poolSk, []byte("chuwt2"))
t.Log("sig1:", hex.EncodeToString(sig1))
t.Log("sig2:", hex.EncodeToString(sig2))
aggSig, err := asm.Aggregate(sig1, sig2)
if err != nil {
t.Error(err)
return
}
t.Log("Aggregate:", hex.EncodeToString(aggSig))
// 多签验证
t.Log("AggregateVerify:", asm.AggregateVerify(
[][]byte{
farmerPk.Bytes(),
poolPk.Bytes(),
},
[][]byte{
[]byte("chuwt1"),
[]byte("chuwt2"),
},
aggSig,
))
}