diff --git a/common/config/config.go b/common/config/config.go index 8afb0fa0..37a703d7 100644 --- a/common/config/config.go +++ b/common/config/config.go @@ -78,9 +78,9 @@ const ( ) var NETWORK_MAGIC = map[uint32]uint32{ - NETWORK_ID_MAIN_NET: constants.NETWORK_MAIGIC_MAINNET, //Network main - NETWORK_ID_POLARIS_NET: constants.NETWORK_MAIGIC_POLARIS, //Network polaris - NETWORK_ID_SOLO_NET: 0, //Network solo + NETWORK_ID_MAIN_NET: constants.NETWORK_MAGIC_MAINNET, //Network main + NETWORK_ID_POLARIS_NET: constants.NETWORK_MAGIC_POLARIS, //Network polaris + NETWORK_ID_SOLO_NET: 0, //Network solo } var NETWORK_NAME = map[uint32]string{ diff --git a/common/constants/constants.go b/common/constants/constants.go index 88a98014..3745973c 100644 --- a/common/constants/constants.go +++ b/common/constants/constants.go @@ -68,9 +68,13 @@ var UNBOUND_DEADLINE = (func() uint32 { })() // multi-sig constants -const MULTI_SIG_MAX_PUBKEY_SIZE = 1024 +const MULTI_SIG_MAX_PUBKEY_SIZE = 16 +// transaction constants +const TX_MAX_SIG_SIZE = 16 + +// network magic number const ( - NETWORK_MAIGIC_MAINNET = 0x74746e41 - NETWORK_MAIGIC_POLARIS = 0x74746e41 + NETWORK_MAGIC_MAINNET = 0x74746e41 + NETWORK_MAGIC_POLARIS = 0x74746e41 ) diff --git a/core/types/transaction.go b/core/types/transaction.go index 04257fa9..8d6c8682 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -26,6 +26,7 @@ import ( "github.com/ontio/ontology-crypto/keypair" "github.com/ontio/ontology/common" + "github.com/ontio/ontology/common/constants" "github.com/ontio/ontology/common/serialization" "github.com/ontio/ontology/core/payload" "github.com/ontio/ontology/core/program" @@ -211,6 +212,10 @@ func (tx *Transaction) Deserialize(r io.Reader) error { return errors.NewDetailErr(err, errors.ErrNoCode, "[Deserialize], Transaction sigs length deserialize error.") } + if length > constants.TX_MAX_SIG_SIZE { + return fmt.Errorf("transaction signature number %d execced %d", length, constants.TX_MAX_SIG_SIZE) + } + for i := 0; i < int(length); i++ { sig := new(Sig) err := sig.Deserialize(r) diff --git a/core/validation/transaction_validator.go b/core/validation/transaction_validator.go index 5669c475..75746780 100644 --- a/core/validation/transaction_validator.go +++ b/core/validation/transaction_validator.go @@ -54,6 +54,12 @@ func VerifyTransactionWithLedger(tx *types.Transaction, ledger *ledger.Ledger) o func checkTransactionSignatures(tx *types.Transaction) error { hash := tx.Hash() + + lensig := len(tx.Sigs) + if lensig > constants.TX_MAX_SIG_SIZE { + return fmt.Errorf("transaction signature number %d execced %d", lensig, constants.TX_MAX_SIG_SIZE) + } + address := make(map[common.Address]bool, len(tx.Sigs)) for _, sig := range tx.Sigs { m := int(sig.M)