aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-09 12:21:27 +0800
committerWei-Ning Huang <aitjcize@gmail.com>2018-10-09 12:21:27 +0800
commit86e15da7cee5463e37b972683b6b2fcf151a4a77 (patch)
treeefa2b041f48de50b0b911851038eeda8563332e2
parentdb07d005e2e5a9208620a8d0e5fcaedeaa6ed644 (diff)
downloaddexon-consensus-86e15da7cee5463e37b972683b6b2fcf151a4a77.tar
dexon-consensus-86e15da7cee5463e37b972683b6b2fcf151a4a77.tar.gz
dexon-consensus-86e15da7cee5463e37b972683b6b2fcf151a4a77.tar.bz2
dexon-consensus-86e15da7cee5463e37b972683b6b2fcf151a4a77.tar.lz
dexon-consensus-86e15da7cee5463e37b972683b6b2fcf151a4a77.tar.xz
dexon-consensus-86e15da7cee5463e37b972683b6b2fcf151a4a77.tar.zst
dexon-consensus-86e15da7cee5463e37b972683b6b2fcf151a4a77.zip
Fix typo in crypto (#186)
-rw-r--r--core/crypto.go4
-rw-r--r--core/crypto_test.go14
2 files changed, 16 insertions, 2 deletions
diff --git a/core/crypto.go b/core/crypto.go
index e286d2b..62c095d 100644
--- a/core/crypto.go
+++ b/core/crypto.go
@@ -256,8 +256,8 @@ func hashDKGFinalize(final *types.DKGFinalize) common.Hash {
// VerifyDKGFinalizeSignature verifies DKGFinalize signature.
func VerifyDKGFinalizeSignature(
- final *types.DKGPartialSignature) (bool, error) {
- hash := hashDKGPartialSignature(final)
+ final *types.DKGFinalize) (bool, error) {
+ hash := hashDKGFinalize(final)
pubKey, err := crypto.SigToPub(hash, final.Signature)
if err != nil {
return false, err
diff --git a/core/crypto_test.go b/core/crypto_test.go
index 8cd2e20..bbedeaf 100644
--- a/core/crypto_test.go
+++ b/core/crypto_test.go
@@ -249,6 +249,20 @@ func (s *CryptoTestSuite) TestDKGSignature() {
ok, err = verifyDKGPartialSignatureSignature(sig)
s.Require().NoError(err)
s.False(ok)
+
+ final := &types.DKGFinalize{
+ ProposerID: nID,
+ Round: 5,
+ }
+ final.Signature, err = prv.Sign(hashDKGFinalize(final))
+ s.Require().NoError(err)
+ ok, err = VerifyDKGFinalizeSignature(final)
+ s.Require().NoError(err)
+ s.True(ok)
+ final.Round++
+ ok, err = VerifyDKGFinalizeSignature(final)
+ s.Require().NoError(err)
+ s.False(ok)
}
func TestCrypto(t *testing.T) {