Skip to content

Commit

Permalink
validate signature
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshkshah1992 committed May 6, 2024
1 parent 7f202a4 commit 0dfac4b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chain/types/ethtypes/eth_legacy_155_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0dfac4b

Please sign in to comment.