-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
64 lines (54 loc) · 1.07 KB
/
main.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
55
56
57
58
59
60
61
62
63
64
package main
import (
"bls-w-sss/curves/curvebls12381"
"crypto/rand"
"fmt"
)
func main() {
var sigs []curvebls12381.Signature
var pks []curvebls12381.PublicKey
var msgs []curvebls12381.Message
for i := 0; i < 100; i++ {
sk, err := curvebls12381.KeyGen()
if err != nil {
panic(err)
}
fmt.Printf("sk is %s\n", sk)
pk := sk.PublicKey()
pks = append(pks, pk)
fmt.Printf("pk is %s\n", pk)
err = pk.Validate()
if err != nil {
panic(err)
}
msg := make(curvebls12381.Message, 32)
_, err = rand.Read(msg)
if err != nil {
panic(err)
}
msgs = append(msgs, msg)
fmt.Printf("msg is %s\n", msg)
sig, err := sk.Sign(msg)
if err != nil {
panic(err)
}
sigs = append(sigs, sig)
fmt.Printf("sig is %s\n", sig)
err = pk.Verify(msg, sig)
if err != nil {
panic(err)
}
fmt.Println("Signature valid!")
}
//aggSig, err := curvebls12381.Aggregate(sigs)
//if err != nil {
// panic(err)
//}
//
//err = curvebls12381.AggregateVerify(pks, msgs, aggSig)
//if err != nil {
// panic(err)
//}
//
//fmt.Printf("aggSig is %s\n", aggSig)
}