diff options
Diffstat (limited to 'core/crypto.go')
-rw-r--r-- | core/crypto.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/core/crypto.go b/core/crypto.go index ab484a0..e286d2b 100644 --- a/core/crypto.go +++ b/core/crypto.go @@ -243,3 +243,27 @@ func verifyDKGPartialSignatureSignature( } return true, nil } + +func hashDKGFinalize(final *types.DKGFinalize) common.Hash { + binaryRound := make([]byte, 8) + binary.LittleEndian.PutUint64(binaryRound, final.Round) + + return crypto.Keccak256Hash( + final.ProposerID.Hash[:], + binaryRound, + ) +} + +// VerifyDKGFinalizeSignature verifies DKGFinalize signature. +func VerifyDKGFinalizeSignature( + final *types.DKGPartialSignature) (bool, error) { + hash := hashDKGPartialSignature(final) + pubKey, err := crypto.SigToPub(hash, final.Signature) + if err != nil { + return false, err + } + if final.ProposerID != types.NewNodeID(pubKey) { + return false, nil + } + return true, nil +} |