From e9b2c28c377f592f9d4b5d21801e93a03aa0db38 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 7 Aug 2024 00:40:35 +0200 Subject: [PATCH] error CryptoInvalidV(); --- contracts/ClaimContract.sol | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contracts/ClaimContract.sol b/contracts/ClaimContract.sol index 7a4e632..1794e03 100644 --- a/contracts/ClaimContract.sol +++ b/contracts/ClaimContract.sol @@ -1,4 +1,4 @@ - +// pragma solidity >=0.8.1 <0.9.0; contract ClaimContract { @@ -102,6 +102,9 @@ contract ClaimContract { /// @dev Claim Error: Signature does not match error ClaimErrorSignatureMissmatch(); + /// @dev Provided v value is invalid for Ethereum signatures. + error CryptoInvalidV(); + event Claim( bytes20 indexed _from, address _to, @@ -295,8 +298,9 @@ contract ClaimContract { bytes32 _r, bytes32 _s ) public view returns (bool) { - require(_v >= 27 && _v <= 30, "v invalid"); + if (_v < 27 || _v > 30) revert CryptoInvalidV(); + /* ecrecover() returns an Eth address rather than a public key, so we must do the same to compare.