-
Notifications
You must be signed in to change notification settings - Fork 106
/
packets.go
110 lines (96 loc) · 3.08 KB
/
packets.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package byzcoin
import (
"gopkg.in/dedis/cothority.v0/lib/cosi"
"gopkg.in/dedis/cothority.v0/lib/sda"
"gopkg.in/dedis/cothority.v0/protocols/byzcoin/blockchain"
)
// RoundType is a type to know if we are in the "prepare" round or the "commit"
// round
type RoundType int32
const (
// RoundPrepare is the first round (prepare)
RoundPrepare RoundType = iota
// RoundCommit is the final round (Commit)
RoundCommit
)
// BlockSignature is what a byzcoin protocol outputs. It contains the signature,
// the block and some possible exceptions.
type BlockSignature struct {
// cosi signature of the commit round.
Sig *cosi.Signature
// the block signed.
Block *blockchain.TrBlock
// List of peers that did not want to sign.
Exceptions []cosi.Exception
}
// Announce is the struct used during the announcement phase (of both
// rounds)
type Announce struct {
*cosi.Announcement
TYPE RoundType
Timeout uint64
}
// announceChan is the type of the channel that will be used to catch
// announcement messges.
type announceChan struct {
*sda.TreeNode
Announce
}
// Commitment is the commitment packets that is sent for both rounds
type Commitment struct {
TYPE RoundType
*cosi.Commitment
}
// commitChan is the type of the channel that will be used to catch commitment
// messages.
type commitChan struct {
*sda.TreeNode
Commitment
}
// ChallengePrepare is the challenge used by ByzCoin during the "prepare" phase. It contains the basic
// challenge plus the transactions from where the challenge has been generated.
type ChallengePrepare struct {
TYPE RoundType
*cosi.Challenge
*blockchain.TrBlock
}
// ChallengeCommit is the challenge used by ByzCoin during the "commit"
// phase. It contains the basic challenge (out of the block we want to sign) +
// the signature of the "prepare" round. It also contains the exception list
// coming from the "prepare" phase. This exception list has been collected by
// the root during the response of the "prepare" phase and broadcast it through
// the challenge of the "commit". These are needed in order to verify the
// signature and to see how many peers did not sign. It's not spoofable because
// otherwise the signature verification will be wrong.
type ChallengeCommit struct {
TYPE RoundType
*cosi.Challenge
// Signature is the basic signature Challenge / response
Signature *cosi.Signature
// Exception is the list of peers that did not want to sign. It's needed for
// verifying the signature. It can not be spoofed otherwise the signature
// would be wrong.
Exceptions []cosi.Exception
}
// challengeChan is the type of the channel that will be used to dcatch the
// challenge messages.
type challengePrepareChan struct {
*sda.TreeNode
ChallengePrepare
}
type challengeCommitChan struct {
*sda.TreeNode
ChallengeCommit
}
// Response is the struct used by ByzCoin during the response. It
// contains the response + the basic exception list.
type Response struct {
*cosi.Response
Exceptions []cosi.Exception
TYPE RoundType
}
// responseChan is the type of the channel used to catch the response messages.
type responseChan struct {
*sda.TreeNode
Response
}