-
Notifications
You must be signed in to change notification settings - Fork 156
/
Copy pathwotsp_test.go
64 lines (50 loc) · 1.26 KB
/
wotsp_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
55
56
57
58
59
60
61
62
63
64
package slhdsa
import (
"bytes"
"testing"
"github.com/cloudflare/circl/internal/test"
)
func testWotsPlus(t *testing.T, p *params) {
skSeed := mustRead(t, p.n)
pkSeed := mustRead(t, p.n)
msg := mustRead(t, p.n)
state := p.NewStatePriv(skSeed, pkSeed)
addr := p.NewAddress()
addr.SetTypeAndClear(addressWotsHash)
pk0 := state.wotsPkGen(addr)
var sig wotsSignature
curSig := cursor(make([]byte, p.wotsSigSize()))
sig.fromBytes(p, &curSig)
state.wotsSign(sig, msg, addr)
pk1 := state.wotsPkFromSig(sig, msg, addr)
if !bytes.Equal(pk0, pk1) {
test.ReportError(t, pk0, pk1, skSeed, pkSeed, msg)
}
}
func benchmarkWotsPlus(b *testing.B, p *params) {
skSeed := mustRead(b, p.n)
pkSeed := mustRead(b, p.n)
msg := mustRead(b, p.n)
state := p.NewStatePriv(skSeed, pkSeed)
addr := p.NewAddress()
addr.SetTypeAndClear(addressWotsHash)
var sig wotsSignature
curSig := cursor(make([]byte, p.wotsSigSize()))
sig.fromBytes(p, &curSig)
state.wotsSign(sig, msg, addr)
b.Run("PkGen", func(b *testing.B) {
for range b.N {
_ = state.wotsPkGen(addr)
}
})
b.Run("Sign", func(b *testing.B) {
for range b.N {
state.wotsSign(sig, msg, addr)
}
})
b.Run("PkFromSig", func(b *testing.B) {
for range b.N {
_ = state.wotsPkFromSig(sig, msg, addr)
}
})
}