aboutsummaryrefslogtreecommitdiffstats
path: root/core/utils
diff options
context:
space:
mode:
Diffstat (limited to 'core/utils')
-rw-r--r--core/utils/crypto.go6
-rw-r--r--core/utils/penalty-helper.go7
2 files changed, 12 insertions, 1 deletions
diff --git a/core/utils/crypto.go b/core/utils/crypto.go
index 34bf08f..7fd3a77 100644
--- a/core/utils/crypto.go
+++ b/core/utils/crypto.go
@@ -63,6 +63,12 @@ func VerifyBlockSignature(b *types.Block) (err error) {
err = ErrIncorrectHash
return
}
+ return VerifyBlockSignatureWithoutPayload(b)
+}
+
+// VerifyBlockSignatureWithoutPayload verifies the signature of types.Block but
+// does not check if PayloadHash is correct.
+func VerifyBlockSignatureWithoutPayload(b *types.Block) (err error) {
hash, err := HashBlock(b)
if err != nil {
return
diff --git a/core/utils/penalty-helper.go b/core/utils/penalty-helper.go
index 2b2456c..0b38474 100644
--- a/core/utils/penalty-helper.go
+++ b/core/utils/penalty-helper.go
@@ -27,6 +27,8 @@ import (
var (
// ErrInvalidDKGMasterPublicKey means the DKG MasterPublicKey is invalid.
ErrInvalidDKGMasterPublicKey = errors.New("invalid DKG master public key")
+ // ErrPayloadNotEmpty means the payload of block is not empty.
+ ErrPayloadNotEmpty = errors.New("payload not empty")
)
// NeedPenaltyDKGPrivateShare checks if the proposer of dkg private share
@@ -95,8 +97,11 @@ func NeedPenaltyForkBlock(block1, block2 *types.Block) (bool, error) {
block1.Hash == block2.Hash {
return false, nil
}
+ if len(block1.Payload) != 0 || len(block2.Payload) != 0 {
+ return false, ErrPayloadNotEmpty
+ }
verifyBlock := func(block *types.Block) (bool, error) {
- err := VerifyBlockSignature(block)
+ err := VerifyBlockSignatureWithoutPayload(block)
switch err {
case nil:
return true, nil