aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/crypto.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-12-21 12:03:28 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:19 +0800
commit1dae18a03ae58e4b98a81a1596fedb9cb2b893e6 (patch)
tree5a938edadfb36844a1b64fafc85c6b9124d69304 /vendor/github.com/dexon-foundation/dexon-consensus/core/crypto.go
parent1c3de255e5507b32116bb37ba206fe66d6edde35 (diff)
downloadgo-tangerine-1dae18a03ae58e4b98a81a1596fedb9cb2b893e6.tar
go-tangerine-1dae18a03ae58e4b98a81a1596fedb9cb2b893e6.tar.gz
go-tangerine-1dae18a03ae58e4b98a81a1596fedb9cb2b893e6.tar.bz2
go-tangerine-1dae18a03ae58e4b98a81a1596fedb9cb2b893e6.tar.lz
go-tangerine-1dae18a03ae58e4b98a81a1596fedb9cb2b893e6.tar.xz
go-tangerine-1dae18a03ae58e4b98a81a1596fedb9cb2b893e6.tar.zst
go-tangerine-1dae18a03ae58e4b98a81a1596fedb9cb2b893e6.zip
core: vm: Add `MPKReady` to governance (#97)
* core/vm: Add DKGMPKReady * param: update GenesisHash * vendor: sync to latest core
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/crypto.go')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/crypto.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/crypto.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/crypto.go
index 914ca0865..d4a7f0ead 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/crypto.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/crypto.go
@@ -243,6 +243,30 @@ func verifyDKGPartialSignatureSignature(
return true, nil
}
+func hashDKGMPKReady(ready *typesDKG.MPKReady) common.Hash {
+ binaryRound := make([]byte, 8)
+ binary.LittleEndian.PutUint64(binaryRound, ready.Round)
+
+ return crypto.Keccak256Hash(
+ ready.ProposerID.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)