|
|
@ -215,13 +215,14 @@ func (consensus *Consensus) constructChallengeMessage() []byte { |
|
|
|
for _, val := range consensus.commitments { |
|
|
|
for _, val := range consensus.commitments { |
|
|
|
commitments = append(commitments, val) |
|
|
|
commitments = append(commitments, val) |
|
|
|
} |
|
|
|
} |
|
|
|
buffer.Write(getAggregatedCommit(commitments, consensus.bitmap)) |
|
|
|
aggCommitment, aggCommitmentBytes := getAggregatedCommit(commitments) |
|
|
|
|
|
|
|
buffer.Write(aggCommitmentBytes) |
|
|
|
|
|
|
|
|
|
|
|
// 33 byte aggregated key
|
|
|
|
// 33 byte aggregated key
|
|
|
|
buffer.Write(getAggregatedKey(consensus.bitmap)) |
|
|
|
buffer.Write(getAggregatedKey(consensus.bitmap)) |
|
|
|
|
|
|
|
|
|
|
|
// 32 byte challenge
|
|
|
|
// 32 byte challenge
|
|
|
|
buffer.Write(getChallenge()) |
|
|
|
buffer.Write(getChallenge(aggCommitment, consensus.bitmap.AggregatePublic, buffer.Bytes()[:36])) // message contains consensus id and block hash for now.
|
|
|
|
|
|
|
|
|
|
|
|
// 64 byte of signature on previous data
|
|
|
|
// 64 byte of signature on previous data
|
|
|
|
signature := signMessage(buffer.Bytes()) |
|
|
|
signature := signMessage(buffer.Bytes()) |
|
|
@ -230,13 +231,13 @@ func (consensus *Consensus) constructChallengeMessage() []byte { |
|
|
|
return proto_consensus.ConstructConsensusMessage(proto_consensus.CHALLENGE, buffer.Bytes()) |
|
|
|
return proto_consensus.ConstructConsensusMessage(proto_consensus.CHALLENGE, buffer.Bytes()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func getAggregatedCommit(commitments []kyber.Point, bitmap *crypto.Mask) []byte { |
|
|
|
func getAggregatedCommit(commitments []kyber.Point) (commitment kyber.Point, bytes []byte) { |
|
|
|
aggCommitment := crypto.AggregateCommitmentsOnly(crypto.Curve, commitments) |
|
|
|
aggCommitment := crypto.AggregateCommitmentsOnly(crypto.Curve, commitments) |
|
|
|
bytes, err := aggCommitment.MarshalBinary() |
|
|
|
bytes, err := aggCommitment.MarshalBinary() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
panic("Failed to deserialize the aggregated commitment") |
|
|
|
panic("Failed to deserialize the aggregated commitment") |
|
|
|
} |
|
|
|
} |
|
|
|
return append(bytes[:], byte(0)) |
|
|
|
return aggCommitment, append(bytes[:], byte(0)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func getAggregatedKey(bitmap *crypto.Mask) []byte { |
|
|
|
func getAggregatedKey(bitmap *crypto.Mask) []byte { |
|
|
@ -247,8 +248,8 @@ func getAggregatedKey(bitmap *crypto.Mask) []byte { |
|
|
|
return append(bytes[:], byte(0)) |
|
|
|
return append(bytes[:], byte(0)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func getChallenge() []byte { |
|
|
|
func getChallenge(aggCommitment, aggKey kyber.Point, message []byte) []byte { |
|
|
|
// TODO: implement actual challenge data
|
|
|
|
crypto.Challenge(crypto.Curve, aggCommitment, aggKey, message) |
|
|
|
return make([]byte, 32) |
|
|
|
return make([]byte, 32) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|