-
Notifications
You must be signed in to change notification settings - Fork 174
/
dkg.go
38 lines (32 loc) · 1.13 KB
/
dkg.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
package bootstrap
import (
"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/model/encodable"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/model/flow/filter"
)
// DKGData represents all the output data from the DKG process, including private information.
// It is used while running the DKG during bootstrapping.
type DKGData struct {
PrivKeyShares []crypto.PrivateKey
PubGroupKey crypto.PublicKey
PubKeyShares []crypto.PublicKey
}
// bootstrap.DKGParticipantPriv is the canonical structure for encoding private node DKG information.
type DKGParticipantPriv struct {
NodeID flow.Identifier
RandomBeaconPrivKey encodable.RandomBeaconPrivKey
GroupIndex int
}
func ToDKGLookup(dkg DKGData, identities flow.IdentityList) map[flow.Identifier]flow.DKGParticipant {
lookup := make(map[flow.Identifier]flow.DKGParticipant)
participants := identities.Filter(filter.HasRole(flow.RoleConsensus))
for i, keyShare := range dkg.PubKeyShares {
identity := participants[i]
lookup[identity.NodeID] = flow.DKGParticipant{
Index: uint(i),
KeyShare: keyShare,
}
}
return lookup
}