Questions tagged [ecrecover]
Questions about EcRecover, a function of the programming language Solidity to verify a signature on the blockchain
100
questions
2
votes
1
answer
75
views
Ecrecover in smart contract doesn't return my address
I'm trying to call a smart contract on Base L2 that has an ecrecover function, but when I sign a message and pass it my r,s,v values (contract accepts 4 params, all uint256, presumably hashedmessage, ...
1
vote
1
answer
41
views
How to get r, s and v values for ecrecover using Solidity?
I've seen some answers showing how to get r, s, v values using web3.js but how to retrieve them using Solidity? Assuming I enter the signature into the contract.
0
votes
0
answers
56
views
removeLiqudityWithPermit: Invalid Signature
So, I am trying to remove liquidity from a pancake v2 pair and I do not understand why this is not working. I am looking at the code, and I've triple checked every value, I don' think I am doing ...
1
vote
1
answer
76
views
SWC-117 signature and ecrecover
source code is here.
As the SWC-117 says "A signature should never be included into a signed message hash to check if previously messages have been processed by the contract.". I don't know ...
1
vote
1
answer
165
views
ECDSA (ecrecover) - How an attacker can construct a hash and signature that look valid
I found information, that it is possible to construct a hash and signature that look valid if the hash is not computed within the contract itself (we are talking about ECDSA/ecrecover here).
So, the ...
2
votes
1
answer
340
views
Issues verifying signed data for Permit2
I'm trying to develop an end-to-end system using Uniswap's Permit2 (AllowanceTransfer).
To achieve that, after the Permit2 allowance, I have to sign a message and verify its integrity contract side. ...
1
vote
0
answers
98
views
Public Key from Transactional Hash of Type 2 EIP-1559
Is it possible to derive the public key based solely on information provided from the transaction hash? It must be able to work on newer transactions (type 0x02 transactions EIP-1559).I want to get ...
1
vote
2
answers
496
views
ECRecover not recovering correct address, but works with ethers.js library
Im trying to test some signature verification in Solidity.
I have generated the signature with nodejs using the ethers.js library.
The signature successfully verifies in nodejs.
I have tried to verify ...
0
votes
0
answers
21
views
Which COSE algorithms are compatible with EVM ecrecover
I want to verify a signature on chain via ecrecover.
Which of the COSE algorithms (https://www.iana.org/assignments/cose/cose.xhtml#algorithms) can be used for signing off chain for the signature to ...
1
vote
0
answers
466
views
ECDSA Nonce reuse attack
so I recently stumbled upon this video by @bertcmiller who created two transactions with the same nonce "k". That seen I researched quite a lot of pages explaining how to recover the private ...
1
vote
2
answers
818
views
Can't recover address from signature (implementing EIP712 with eth_signTypedData_v4 and using OpenZeppelin)
can someone help me to find out what is wrong with my solidity code? (I'm trying to implement usage of the signatures and EIP712)
(ECDSA and _hashTypedDataV4 are from OpenZeppelin: https://github.com/...
1
vote
0
answers
204
views
Problem with ecrecover, it returns an incorrect address
I know that this issue is already in other questions but I've already read them and they didn't help.
I'm trying to sign a message in my tests, I'm using hardhat and this is the code I'm using to sign ...
0
votes
1
answer
595
views
Potential signature malleability in Solidity CTF
I am doing a CTF so I don't want to give too much information away. I am pretty sure I can practice signature malleability or otherwise abuse the signer functions to be able to mint tokens given the ...
0
votes
1
answer
373
views
Failing to verify signature
I'm trying to verify a signature using OpenZeppelin's SignatureChecker library, but always returns false. This is the verify function from the lib:
function isValidSignatureNow(
address ...
2
votes
1
answer
144
views
Why isn't EIP3009 getting much use?
I am researching the use of the EIP3009 and am noticing that the proposal, though implemented in, say, USDC's smart contracts, is not actually getting used (the functions have never been called in ...
0
votes
1
answer
170
views
ecrecover returns wrong address if toSignString consists of only number
//web3 code
let hash = web3.utils.soliditySha3("String"); //if replace "String" with "0" "123" etc , ecrecover returns wrong address
console.log(&...
1
vote
1
answer
1k
views
How to recover Ethereum Public Key from Transaction
How can I recover the Ethereum Public Key from a Transaction?
web3.eth.accounts.recoverTransaction("...
1
vote
2
answers
2k
views
How to recover the public key from r, s and v without the private key
I would like to recover the public key (or address) from the r,s and v values of a signed transaction without using a private key. The idea of course being, that I want to use Nick's method to deploy ...
0
votes
0
answers
157
views
Validate Certificates on Ethereum blockchain
i have a function transferWithData(address to, uint256 amount, bytes data) it basically transfer ERC20 token but it has an additional 'data' field, in order to inject a certificate generated off-chain ...
0
votes
1
answer
420
views
what is the point of the chainId parameter in ethereumjs's ecrecover method?
The parameters for ecrecover() are:
msgHash
v
r
s
chainId
The first four are pretty straight forward to me but the last one - chainId.... what's the point of that one?
In looking at the source code ...
0
votes
2
answers
62
views
unable to validate signature - recovered key doesn't match the actual key?
I'm trying to use ethereumjs to verify a signature. The signature verifies successfully with https://etherscan.io/verifySig using the following parameters:
[Step 1] Address: ...
0
votes
0
answers
145
views
etherscan.io says a sig is valid but i can't get ethereumjs to say that that same sig is valid
I'm trying to use ethereumjs to verify a signature. The signature verifies successfully with https://etherscan.io/verifySig using the following parameters:
[Step 1] Address: ...
3
votes
1
answer
834
views
solidity cannot verify ethers.js signed data
I have a simple contract which recover the signature signer
signing:
const signer = new Wallet(process.env.PRIVATE_KEY)
console.log(signer.address)
const encoded = abiCoder.encode([ "uint" ],...
1
vote
1
answer
383
views
signTransaction produces huge signature, which fails with 'ECDSA: invalid signature length'
I'm trying to create a transaction (created with populateTransaction), and sign it offchain (the above result, passed as a parameter to signTransaction), but it seems it produces an invalid signature (...
1
vote
1
answer
438
views
Unable to construct hash from address and uint256 for ecrecover and signature verification
I am creating a signature with web3.js form a hashed message that contains two numbers and an address:
const tokenIds = [1,2,3];
const state = 1;
const messageHash = web3.utils.keccak256(tokenIds....
1
vote
0
answers
606
views
How do I perform _hashTypedDataV4 on a struct containing an array of structs
I have signed a typed data, and I am trying to recover the address of the signer from my contract using ECDSA.recover(). But each time I try it, I get an address that is different from the address of ...
2
votes
0
answers
110
views
Is there only one valid r,s,parity for a given transaction signed by one private key?
As I understand it in secp256k1 there are infinitely many secrets which, for the same message to be signed, can lead to a valid signature. So the same private key can sign the exact same message and ...
0
votes
1
answer
174
views
Unable to validate one of two signatures that were signed the same way
I have a contract that requires two witnesses to sign. Signatures are both being generated using the same code, but I am only able to validate Witness A. Witness B is never found, always just get the ...
1
vote
1
answer
715
views
Sign with web3, verify with Solidity
I have been trying, debugging, and crying, for a few days now. I simply for the life of me cannot figure out how to verify a signature that I've created with web3, in Solidity. I am sure I am just ...
0
votes
0
answers
124
views
Signed message valid only for a specific smart contract
Is it possible to create a smart contract A and a signed message for which the signature would be valid only if it's signed by the expected Ethereum account and the signature check happens in that ...
1
vote
0
answers
157
views
Recovering address from signed message in Elixir
I'm signing a message via Web3js:
const string = this.web3.utils.sha3("test");
const signature = await this.web3.eth.sign(string, this.wallet.address);
In Elixir, i'm parsing the hash and ...
0
votes
0
answers
642
views
Workflow to verify a user signature from a backend service
I have a frontend web application that creates a message and asks the user to sign it via, for example, metamask.
The user signs the message and now I have a signed message hash.
Is there a common/...
4
votes
1
answer
7k
views
How do you verify a Metamask signature on the server side?
I want my server to be able to authenticate a user based on whether or not they have the private key to their wallet. I am using web3.js in my front end, and web3.py in my backend.
The scenario will ...
2
votes
1
answer
2k
views
How to recover public key using ecRecover in Python?
I am able to use ecRecover to verify the signer in Javascript, for example:
const ecRecoverAddr = await window.ethereum.request({
method: "personal_ecRecover",
params: [message, ...
1
vote
1
answer
2k
views
how I can sign message using web3js?
I know that I can sign a message using web3js, but I don't know how I can do that, then how to verify that signature using ecrecover()?
5
votes
2
answers
1k
views
Cannot verifiy a signature produced by Ledger in Solidity using ecrecover
I used a smart contract to verify signatures:
function verify(string memory _msg, bytes memory _sig) public pure returns (address) {
bytes memory _msgHex = bytes(_msg);
bytes32 prefixedHash = ...
0
votes
1
answer
1k
views
EIP712: ecrecover returns different address from recoverTypedSignature_v4
I am trying to sign typed data via MetaMask "eth_signTypedData_v4". Recovering signer via recoverTypedSignature_v4 returns correct address that I signed my data with. But smart contract ...
0
votes
1
answer
5k
views
How to implement owner check in Solidity
Is there any EIP that specifies how to implement function in contract, that let's you call any other function as contract owner, with provided signature?
I don't want to reinvent wheel.
For example:
I ...
3
votes
1
answer
1k
views
Is it best practice to check signature malleability in ecrecover
I am wondering if it is considered best practice to guard against signature malleability to check against the half curve order like this or if this is totally unnecessary.
uint256 constant ...
2
votes
0
answers
710
views
EIP712-- Sign/Recovery using ethereumJS/Solidity
I've tried to mirror the example as shown: https://github.com/ethereum/EIPs/tree/master/assets/eip-712
However after much attempt at troubleshooting I have been unable to return the correct address ...
1
vote
0
answers
1k
views
Verification of ECDSA signature is not valid while testing HashDice.sol
While practising on the ethereum contract HashDice.sol using truffle, the verification of the ECDSA signature is getting invalid after running the test script.
describe('verify()', () => {
it('...
0
votes
1
answer
653
views
What is the gas cost of recovering a wallet address from a signature using Solidity?
As titled. I understand that there's an ecrecover function in Solidity. Can I use it for recovering a wallet address from a signature? Is it cheaper than a Keccak hash operation?
2
votes
2
answers
722
views
Recover public key from sign generated by AWS Cloud HSM - Golang
I am signing a transaction by using a private key in AWS Cloud HSM. But not able to recover the correct public key from the signature. Every time I try to run ECRecover method, it generates different ...
3
votes
1
answer
674
views
What's the magic numbers meaning of 27 or 28 in VRS ( use to ecrover the sender) ? why not 0 or 1?
What's the magic numbers meaning of 27 or 28 in VRS ( use to ecrover the sender) ? why not 0 or 1?
Ecrecover need 0 or 1, but transaction RLP is 27 or 28. Before ecrecover, sub 27 to get 0 or 1. Why ...
2
votes
2
answers
6k
views
ethers.js Recover public key from contract deployment via v,r,s values
I'm currently trying to get the public key of the user that deploys a contract. Unfortunately I can't make it work.
I am trying to achieve this solely by using ethers.js as I don't want to bloat my ...
0
votes
0
answers
104
views
Signature not matching the sig obtained from MyEtherWallet
I am serializing the unsigned txn in C, then I found Keccak-256 hash and I signed it with the privatekey. However, the resulting signature is not the same as in MyEtherWallet for the same values(...
0
votes
2
answers
974
views
Recovering of typed signature fails because it's too long
I have a typed signature generated by EIP712 V3. It is 132 characters long. I'm trying to recover it using recoverTypedSignature from eth-sig-util. This fails saying:
index.js:1 Error: Invalid ...
7
votes
2
answers
11k
views
Sign message with web3 and verify with openzeppelin-solidity ECDSA.sol
I'm trying to get a little example working with ECDSA.sol here: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/cryptography/ECDSA.sol
This contract:
Generate a random(...
0
votes
1
answer
183
views
How to have ecrecover return nothing ? I means which value for malformed input?
I have a contract where the hash value is also the key to unlock the money.
As the full ecrecover parameters are fetched from transaction parameters, and it was compiled in 2016, it is vulnerable to ...
0
votes
1
answer
496
views
How to call ecrecover() in pure assembly?
If I do remember correctly, it’s a contract built‑in in the Ethereum Virtual machine, isn’t it?
if yes, what’s the address to call for it?