From 86e15da7cee5463e37b972683b6b2fcf151a4a77 Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Tue, 9 Oct 2018 12:21:27 +0800 Subject: Fix typo in crypto (#186) --- core/crypto.go | 4 ++-- core/crypto_test.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'core') 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) { -- cgit v1.2.3