Skip to content

Commit

Permalink
Add EventDigest in balloon.Commitment
Browse files Browse the repository at this point in the history
  • Loading branch information
iknite committed Nov 27, 2018
1 parent 673ca18 commit e61e180
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/apihttp/apihttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type fakeRaftBalloon struct {
}

func (b fakeRaftBalloon) Add(event []byte) (*balloon.Commitment, error) {
return &balloon.Commitment{hashing.Digest{0x00}, hashing.Digest{0x01}, 0}, nil
return &balloon.Commitment{hashing.Digest{0x02}, hashing.Digest{0x00}, hashing.Digest{0x01}, 0}, nil
}

func (b fakeRaftBalloon) Join(nodeID, addr string) error {
Expand Down
1 change: 1 addition & 0 deletions balloon/balloon.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ func (b *Balloon) Add(event []byte) (*Commitment, []*storage.Mutation, error) {
mutations = append(mutations, historyMutations...)

commitment := &Commitment{
EventDigest: eventDigest,
HistoryDigest: historyDigest,
HyperDigest: hyperDigest,
Version: version,
Expand Down
1 change: 1 addition & 0 deletions balloon/balloon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func TestMembershipProofVerify(t *testing.T) {
for i, c := range testCases {
event := []byte("Yadda yadda")
commitment := &Commitment{
event, //TODO: should be eventDigest and used in the test
hashing.Digest("Some hyperDigest"),
hashing.Digest("Some historyDigest"),
c.actualVersion,
Expand Down
3 changes: 3 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ func (c HttpClient) Verify(result *protocol.MembershipResult, snap *protocol.Sna
proof := protocol.ToBalloonProof([]byte(c.apiKey), result, hasherF)

return proof.Verify(snap.EventDigest, &balloon.Commitment{
snap.EventDigest,
snap.HistoryDigest,
snap.HyperDigest,
snap.Version,
Expand All @@ -183,11 +184,13 @@ func (c HttpClient) VerifyIncremental(result *protocol.IncrementalResponse, star
proof := protocol.ToIncrementalProof(result, hasher)

startCommitment := &balloon.Commitment{
startSnapshot.EventDigest,
startSnapshot.HistoryDigest,
startSnapshot.HyperDigest,
startSnapshot.Version,
}
endCommitment := &balloon.Commitment{
endSnapshot.EventDigest,
endSnapshot.HistoryDigest,
endSnapshot.HyperDigest,
endSnapshot.Version,
Expand Down
13 changes: 11 additions & 2 deletions cmd/client_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,17 @@ func newAddCommand(ctx *clientContext) *cobra.Command {
return err
}

log.Infof("Received snapshot with values: \n\tEvent: %s\n\tHyperDigest: %x\n\tHistoryDigest: %x\n\tVersion: %d\n",
snapshot.EventDigest, snapshot.HyperDigest, snapshot.HistoryDigest, snapshot.Version)
log.Infof(`
Received snapshot with values:
EventDigest: %s
HyperDigest: %x
HistoryDigest: %x
Version: %d
`,
snapshot.EventDigest,
snapshot.HyperDigest,
snapshot.HistoryDigest,
snapshot.Version)

return nil
},
Expand Down

0 comments on commit e61e180

Please sign in to comment.