Questions tagged [ecrecover]

Questions about EcRecover, a function of the programming language Solidity to verify a signature on the blockchain

Filter by
Sorted by
Tagged with
0 votes
1 answer
20 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 ...
user avatar
  • 307
2 votes
1 answer
23 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 ...
user avatar
  • 33
0 votes
1 answer
40 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(&...
user avatar
0 votes
1 answer
97 views

How to recover Ethereum Public Key from Transaction

How can I recover the Ethereum Public Key from a Transaction? web3.eth.accounts.recoverTransaction("...
user avatar
  • 199
1 vote
2 answers
257 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 ...
user avatar
  • 177
0 votes
0 answers
36 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 ...
user avatar
0 votes
1 answer
45 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 ...
user avatar
  • 103
0 votes
2 answers
34 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: ...
user avatar
  • 103
0 votes
0 answers
71 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: ...
user avatar
  • 103
3 votes
1 answer
285 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" ],...
user avatar
0 votes
1 answer
149 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 (...
user avatar
  • 130
1 vote
1 answer
165 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....
user avatar
  • 133
1 vote
0 answers
347 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 ...
user avatar
  • 131
1 vote
0 answers
28 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 ...
user avatar
0 votes
1 answer
80 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 ...
user avatar
  • 133
0 votes
1 answer
380 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 ...
user avatar
  • 133
0 votes
0 answers
44 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 ...
user avatar
  • 1
1 vote
0 answers
102 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 ...
user avatar
  • 11
0 votes
0 answers
366 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/...
user avatar
  • 329
1 vote
1 answer
3k 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 ...
user avatar
  • 45
2 votes
1 answer
593 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, ...
user avatar
  • 45
0 votes
0 answers
12 views

what are the steps to execute this contract

I want to execute this program https://solidity-by-example.org/signature/, but I do not know where should I run web3 code any one can tell me the hole steps that describe how to run this ?
user avatar
  • 11
1 vote
1 answer
1k 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()?
user avatar
  • 11
0 votes
0 answers
39 views

Best practice for ecrecover in Vyper

What is the best practice for using ecrecover in Vyper? Because of signature malleability OpenZeppelin recommends to use their version of ecrecover for Solidity https://github.com/OpenZeppelin/...
user avatar
4 votes
1 answer
684 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 = ...
user avatar
0 votes
1 answer
723 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 ...
user avatar
0 votes
1 answer
3k 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 ...
user avatar
  • 713
2 votes
1 answer
448 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 ...
user avatar
  • 8,114
2 votes
0 answers
382 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 ...
user avatar
0 votes
0 answers
960 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('...
user avatar
  • 27
0 votes
1 answer
319 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?
user avatar
2 votes
1 answer
454 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 ...
user avatar
2 votes
1 answer
197 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 ...
user avatar
  • 121
2 votes
1 answer
3k 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 ...
user avatar
  • 1,092
0 votes
0 answers
88 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(...
user avatar
0 votes
2 answers
551 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 ...
user avatar
6 votes
2 answers
7k 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(...
user avatar
  • 51.1k
0 votes
1 answer
108 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 ...
user avatar
0 votes
1 answer
242 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?
user avatar
1 vote
2 answers
720 views

ecrecover() always returns 0x0000000000000000000000000000000000000000

I'm aware of these posts How do you sign an verify a message in javascript proving you own an Ethereum address? How does one properly use ecrecover to verify Ethereum signatures? I'd like to sign a ...
user avatar
  • 1,947
1 vote
1 answer
362 views

ecrecover not giving back the adress of the sender

I am trying to understand how eliptic curve work and when i try to get the sender of this transaction: https://etherscan.io/tx/0x14a298c1eea89f42285948b7d51eeac2876ca7406c9784b9b90dd3591d156d64 ( ...
user avatar
  • 1,024
1 vote
1 answer
1k views

How to pass bytes32 to Web3.methods.function.call

I have a contract that is doing an ecrecover: function recover(bytes32 h, uint8 v, bytes32 r, bytes32 s) public returns (address) { return ecrecover(h, v, r, s); } It works ...
user avatar
4 votes
1 answer
428 views

How to get the zero address from ecrecover?

I have a fair understanding of how ecrecover works, but I don't know how to enforce a parameter set that will deterministically return the 0x0 address. I need this in my contract tests. Is this even ...
user avatar
1 vote
1 answer
493 views

web3js recover returns different address than what signed message

Web3js as of version 1.0.0 beta supports an interface for verifying signed messages: https://github.com/ethereum/web3.js/issues/404 This is documented here: https://web3js.readthedocs.io/en/1.0/web3-...
user avatar
2 votes
0 answers
157 views

Ecrecover wrong address is returned

I'm trying to validate signed data with ecrecover. The message is signed like this on the FE: return this.web3.eth.personal.sign( `${nonce}`, publicAddress ).then( ( signature ) => { ...
user avatar
  • 141
5 votes
2 answers
1k views

Why does ecrecover() take signature parameters (v,r,s) instead of the full signature?

Is there any reason ecrecover() takes the (v, r, s) signature parameters instead of the full signature, given that these can be easily computed inside the function itself? I am asking because ...
user avatar
  • 533
2 votes
0 answers
60 views

How to change prefix of signature in Javascript?

Is it possible to change the signature prefix, which by default: "\x19Ethereum Signed Message:\n32" Can I change it to another prefix? I need to get a signature in solidity in this way: bytes32 ...
user avatar
2 votes
1 answer
611 views

HD wallet public to public key derivation and non-hardened keys

This question is about hierarchical deterministic wallets and the bip32 standard which, as I understand it, allows you to deterministically derive child private/public key pairs from a master seed ...
user avatar
1 vote
1 answer
270 views

web3.eth.sign sometimes gives V parameter of 54 or 55, ecrecover then fails. What's going on?

I've been using ecrecover and web3.eth.sign to authorize transactions, but when I run web3.eth.sign a second time on my server, the V part of the signature is wrong(or, at least, ecrecover thinks it's ...
user avatar
1 vote
1 answer
268 views

Geth ecrecover function returning '0x'

can someone help me with this ecrecover issue? The code below is a truffle test. The recoverSigner function just calls ecrecover, but the return is always '0x'. Recovering with ethereumjs-util works ...
user avatar
  • 11