aboutsummaryrefslogtreecommitdiffstats
path: root/core/crypto.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-12-20 16:54:11 +0800
committerGitHub <noreply@github.com>2018-12-20 16:54:11 +0800
commit24783a4b3d4a23256e1e16c9f35191c7de4bb7ee (patch)
tree75d78bed2b2c5cc69129dec7af2808fdcbe3645f /core/crypto.go
parent45609b1dbfba5d7083826e27f2c5862fcca24106 (diff)
downloaddexon-consensus-24783a4b3d4a23256e1e16c9f35191c7de4bb7ee.tar
dexon-consensus-24783a4b3d4a23256e1e16c9f35191c7de4bb7ee.tar.gz
dexon-consensus-24783a4b3d4a23256e1e16c9f35191c7de4bb7ee.tar.bz2
dexon-consensus-24783a4b3d4a23256e1e16c9f35191c7de4bb7ee.tar.lz
dexon-consensus-24783a4b3d4a23256e1e16c9f35191c7de4bb7ee.tar.xz
dexon-consensus-24783a4b3d4a23256e1e16c9f35191c7de4bb7ee.tar.zst
dexon-consensus-24783a4b3d4a23256e1e16c9f35191c7de4bb7ee.zip
core: Add VerifyDKGMPKReadySignature (#377)
* core: Add VerifyDKGMPKReadySignature * Fix typo
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)