-
Notifications
You must be signed in to change notification settings - Fork 2
/
integration_test.go
79 lines (62 loc) · 1.96 KB
/
integration_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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package frost_test
import (
"time"
"github.com/renproject/frost"
"github.com/renproject/secp256k1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Integration", func() {
Context("all nodes honest and online", func() {
It("DKG should succeed and the outputs can be used to successfully sign", func() {
n := 10
t := 5
bip340 := false
indices := sequentialIndices(n)
context := [32]byte{}
copy(context[:], []byte("context"))
step1Timeout := time.Duration(500 * time.Millisecond)
dkgPlayers := createDKGPlayers(indices, t, context)
outputs := executeDKG(dkgPlayers, step1Timeout)
checkOutputs(outputs, n, t, indices)
players, aggregator, aggregatedPubKey, _, _ := createPlayers(n, t, bip340)
var msgHash [32]byte
copy(msgHash[:], "good evening")
sig := executeThresholdSignature(&aggregator, players, msgHash)
Expect(sigIsValid(&sig, &msgHash, &aggregatedPubKey, bip340)).To(BeTrue())
})
})
})
func createPlayersFromDKGOutputs(outputs []dkgSimOutput, indices []uint16, t int, bip340 bool) ([]player, sa, secp256k1.Point, frost.InstanceParameters, []uint16) {
n := len(indices)
aggregatedPubKey := outputs[0].output.PubKey
pubKeyShares := outputs[0].output.PubKeyShares
players := make([]player, n)
for i := range players {
var output dkgSimOutput
for j := range outputs {
if outputs[j].index == indices[i] {
output = outputs[j]
break
}
}
players[i] = player{
state: frost.State{},
index: indices[i],
n: n,
t: t,
privKeyShare: output.output.Share,
pubKey: output.output.PubKey,
bip340: bip340,
}
}
subset := randomIndexSubset(indices, t)
params := frost.NewInstanceParameters(subset, pubKeyShares)
aggregator := sa{
params: params,
aggregatedPubKey: aggregatedPubKey,
bip340: bip340,
state: frost.NewSAState(t),
}
return players, aggregator, aggregatedPubKey, params, subset
}