-
Notifications
You must be signed in to change notification settings - Fork 179
/
dkg.go
46 lines (40 loc) · 1.67 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
39
40
41
42
43
44
45
46
package messages
import (
"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/model/flow"
)
// DKGMessage is the type of message exchanged between DKG nodes.
type DKGMessage struct {
Data []byte
DKGInstanceID string
}
// NewDKGMessage creates a new DKGMessage.
func NewDKGMessage(data []byte, dkgInstanceID string) DKGMessage {
return DKGMessage{
Data: data,
DKGInstanceID: dkgInstanceID,
}
}
// PrivDKGMessageIn is a wrapper around a DKGMessage containing the network ID
// of the sender.
type PrivDKGMessageIn struct {
DKGMessage
CommitteeMemberIndex uint64 // CommitteeMemberIndex field is set when the message arrives at the Broker
OriginID flow.Identifier
}
// PrivDKGMessageOut is a wrapper around a DKGMessage containing the network ID of
// the destination.
type PrivDKGMessageOut struct {
DKGMessage
DestID flow.Identifier
}
// BroadcastDKGMessage is a wrapper around a DKGMessage intended for broadcasting.
// It contains a signature of the DKGMessage signed with the staking key of the
// sender. When the DKG contract receives BroadcastDKGMessage' it will attach the
// NodeID of the sender, we then add this field to the BroadcastDKGMessage when reading broadcast messages.
type BroadcastDKGMessage struct {
DKGMessage
CommitteeMemberIndex uint64 `json:"-"` // CommitteeMemberIndex field is set when reading broadcast messages using the NodeID to find the index of the sender in the DKG committee
NodeID flow.Identifier `json:"-"` // NodeID field is added when reading broadcast messages from the DKG contract, this field is ignored when sending broadcast messages
Signature crypto.Signature
}