The value returned by signTransaction is a RLP-encoded raw Ethereum transaction including the signature.
For more info see:
The ABI or the Application Binary Interface is the standard to interact with the contracts. EVM uses the ABI encoded data to understand which part of the bytecode to execute.
When does it happen?
A contract interaction is just another transaction on ethereum. The payload/what-to-do is in the data field of the transaction. ABI encoding encodes the user's ...
However Trezor adds the prefix auto, but wherever its required you to manually enter it for strlen(msg),it should be "32" (in string) or better to use "\x19Ethereum Signed Message:\n32" + keccak256(msg)
How the hash is calculated highly depends on the contract. So to provide a detailed answer you would have to link the specific contract.
There are a couple standards that outline guidlines on how such an hash should be generated:
As an example where signature recovery is used you can look at tokens that implement EIP-2612 or at smart ...
I was looking for some way to directly acquire the Y-parity, instead of recovering it after the fact. Did some research after posting this question, particularly on this article:
So apparently R and S are calculated using several different values. One of these values is the X-coordinate of a randomly ...
There is a clear front-running issue with the claimTokens function.
Let's say that user A sends a claimTokens transaction with a signed message as the sig parameter.
User B (evil) sees the transaction in the mempool. To claim the tokens that belong to A, all B has to do is copy the parameters of A's transaction, including sig, and send its own claimTokens ...
In general there is no issue in using ecrecover the most important part is how you create the hash that you sign (e.g. include the contract address and chain id into the hash to prevent replay attacks)
Most wallets don't let you sign data that could potentially be a raw transaction. Therefore you have a couple standards for signing.
The most notable ones are ...
I figured it out thanks to this brilliant article.
The secret is to use web3.utils.soliditySha3 which will abi encode and hash like Solidity would!
const message = web3.utils.soliditySha3(
and in the contract simply do:
We observe that web3 exposes a few wallet functionalities that may not be very clear at first:
web3.eth.accounts / getAccounts()
It seems web3.eth.accounts.wallet.create is a utility meant to create accounts on the fly without actually auto-binding them to your local node's account list (credits: previous answer). You could use ...
What exactly do v, r, and s stand for?
r is the R.x value of the signature's R point.
s is the signature proof for R.x
v is a recovery parameter used to ease the signature verification.
v is not required but often included. But what is v?
Since the signature only includes the x coordinate of the point R, there are either 0, 1, 2, 3, or 4 matching y ...
For future people, Ismael in the comments was correct. I also had encoding and hashing problems. This solution depends on the .net Nethereum library. Item of note - my data type was the sender address, so the ABIValue TYPE was set to "address". This made a huge difference.
private byte GetSignature(string privateKey, string textToHash)