From 0dfac4b75910fff5cc9c366b60a19b21b3b001cc Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Mon, 6 May 2024 16:18:06 +0530 Subject: [PATCH] validate signature --- chain/types/ethtypes/eth_legacy_155_transactions.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chain/types/ethtypes/eth_legacy_155_transactions.go b/chain/types/ethtypes/eth_legacy_155_transactions.go index c9d8c703a2f..dc591a025b1 100644 --- a/chain/types/ethtypes/eth_legacy_155_transactions.go +++ b/chain/types/ethtypes/eth_legacy_155_transactions.go @@ -145,6 +145,10 @@ func (tx *EthLegacy155TxArgs) ToVerifiableSignature(sig []byte) ([]byte, error) // Extract the 'v' value from the signature vValue := big.NewFromGo(big.NewInt(0).SetBytes(sig[64:])) + if err := validateEIP155ChainId(vValue); err != nil { + return nil, fmt.Errorf("failed to validate EIP155 chain id: %w", err) + } + // See https://github.com/ethereum/go-ethereum/blob/86a1f0c39494c8f5caddf6bd9fbddd4bdfa944fd/core/types/transaction_signing.go#L424 chainIdMul := big.Mul(big.NewIntUnsigned(build.Eip155ChainId), big.NewInt(2)) vValue = big.Sub(vValue, chainIdMul)