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)
downloadtangerine-consensus-24783a4b3d4a23256e1e16c9f35191c7de4bb7ee.tar
tangerine-consensus-24783a4b3d4a23256e1e16c9f35191c7de4bb7ee.tar.gz
tangerine-consensus-24783a4b3d4a23256e1e16c9f35191c7de4bb7ee.tar.bz2
tangerine-consensus-24783a4b3d4a23256e1e16c9f35191c7de4bb7ee.tar.lz
tangerine-consensus-24783a4b3d4a23256e1e16c9f35191c7de4bb7ee.tar.xz
tangerine-consensus-24783a4b3d4a23256e1e16c9f35191c7de4bb7ee.tar.zst
tangerine-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)