-
Notifications
You must be signed in to change notification settings - Fork 22
/
dkg_round.go
51 lines (44 loc) · 1.12 KB
/
dkg_round.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
package dkg
import (
"crypto/elliptic"
"fmt"
"math/big"
"github.com/okx/threshold-lib/crypto/commitment"
"github.com/okx/threshold-lib/crypto/curves"
"github.com/okx/threshold-lib/crypto/vss"
)
type SetupInfo struct {
DeviceNumber int // device id, start 1
Threshold int // 2/n, fixed 2
Total int // number of participants
RoundNumber int
ui *big.Int
shareI *big.Int // key share
publicKey *curves.ECPoint
curve elliptic.Curve
chaincode *big.Int // for non-hardened derivation, unchangeable
verifiers []*curves.ECPoint
secretShares []*vss.Share
deC *commitment.Witness
commitmentMap map[int]commitment.Commitment
}
func NewSetUp(deviceNumber, total int, curve elliptic.Curve) *SetupInfo {
if total < 2 || deviceNumber > total || deviceNumber <= 0 {
panic(fmt.Errorf("NewSetUp params error"))
}
info := &SetupInfo{
DeviceNumber: deviceNumber,
Threshold: 2,
Total: total,
RoundNumber: 1,
curve: curve,
}
return info
}
func (info *SetupInfo) Ids() []int {
var ids []int
for i := 1; i <= info.Total; i++ {
ids = append(ids, i)
}
return ids
}