aboutsummaryrefslogtreecommitdiffstats
path: root/core/crypto.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/crypto.go')
-rw-r--r--core/crypto.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/crypto.go b/core/crypto.go
index 96ea54f..d4a7f0e 100644
--- a/core/crypto.go
+++ b/core/crypto.go
@@ -252,6 +252,21 @@ func hashDKGMPKReady(ready *typesDKG.MPKReady) common.Hash {
binaryRound,
)
}
+
+// VerifyDKGMPKReadySignature verifies DKGMPKReady signature.
+func VerifyDKGMPKReadySignature(
+ ready *typesDKG.MPKReady) (bool, error) {
+ hash := hashDKGMPKReady(ready)
+ pubKey, err := crypto.SigToPub(hash, ready.Signature)
+ if err != nil {
+ return false, err
+ }
+ if ready.ProposerID != types.NewNodeID(pubKey) {
+ return false, nil
+ }
+ return true, nil
+}
+
func hashDKGFinalize(final *typesDKG.Finalize) common.Hash {
binaryRound := make([]byte, 8)
binary.LittleEndian.PutUint64(binaryRound, final.Round)