71
votes
Accepted
Get public key of any ethereum account
You can if and only if a transaction has been sent from the account. When you send a tx, you sign the transaction and it includes these v r and s values. You parse these from the signed tx and then ...
51
votes
Accepted
What does v, r, s in eth_getTransactionByHash mean?
v, r, s are the values for the transaction's signature. They can be used as in Get public key of any ethereum account
A little more information, r and s are outputs of an ECDSA signature, and v is ...
eth♦
- 86.5k
24
votes
Accepted
How do you sign an verify a message in javascript proving you own an Ethereum address?
You can sign a string of data using web3.eth.sign
The address you use needs to be unlocked and you can sign text like this:
> web3.eth.sign(<your address>, web3.sha3("Some text"))
...
24
votes
Accepted
Invalid sender error on private chain
The issue was that the chain id was not being set correctly. As a result transactions were signed with the incorrect chain id, so the sender could not be derived correctly. The fix was to also declare ...
19
votes
Accepted
How to properly create a raw transaction and sign it using web3 in browser
Below is working code that calls "increment" on https://programtheblockchain.com/dapps/counter. (More info about that sample here: https://programtheblockchain.com/posts/2017/12/13/building-...
19
votes
Accepted
Using AWS CloudHSM to sign transactions
OK,
so when we (me and the ShaneT) implemented hardware signing (private key stored exclusively on AWS CloudHSM) there were a number of things we learned. Hopefully this gives you a guide on how you ...
18
votes
Get public key of any ethereum account
It is now possible to recover public key from Ethereum transaction without any coding:
Open the transaction in Etherscan.io
Click on vertical ellipsis in the top-right corner
Click on "Get Raw ...
18
votes
How to properly create a raw transaction and sign it using web3 in browser
Using Web3.js 1.0.0
encoded = contractInstance.methods.myMethod(params).encodeABI()
var tx = {
to : myContractAddress,
data : encoded
}
web3.eth.accounts.signTransaction(tx, privateKey)....
16
votes
Accepted
What are the IDs for the various Ethereum chains?
1 Mainnet: https://ethereum.org
2 Morden Testnet (deprecated)
3 Ropsten Testnet (deprecated)
4 Rinkeby Testnet (deprecated)
5 Goerli Testnet: https://goerli.net
42 Kovan Testnet (deprecated)
11155111 ...
16
votes
Accepted
Is it possible to sign a message in Solidity?
There might be implementations of signing in Solidity, but you shouldn't do it.
This is because in order to sign something, you will need a private key. Since every transaction is public on the ...
14
votes
How do you sign an verify a message in javascript proving you own an Ethereum address?
You can now verify signatures in web3 1.0 using web3.eth.accounts.recover
const account = web3.eth.accounts[0];
const signature = await web3.eth.sign("Hello world", account);
const signingAddress = ...
14
votes
Get public key of any ethereum account
I don't think this is possible, since you lose information when going from public key to address:
Start with the public key (64 bytes)
Take the Keccak-256 hash of the public key. You should ...
13
votes
Accepted
Getting an address from ethereumjs-utils ecrecover
ecrecover returns public key, you need to convert it to address with pubToAddress.
pub = ethJsUtil.ecrecover(msg, v, r, s);
addrBuf = ethJsUtil.pubToAddress(pub);
addr = ethJsUtil.bufferToHex(...
13
votes
Accepted
How to get private keys on Truffle from Ganache accounts
You can start ganache with a mnemonic as a parameter ( -m 'jar boss sister abuse equal ....'). Doing this, you'll:
be guaranteed to have the same addresses generated with each run
be able to derive ...
12
votes
Accepted
Getting the wrong address back from ecrecover
Geth adds prefix to the message before siginig it in web3.eth.sign (see JSON-PRC spec).
Without this it can be possible to trick user to sign transaction (more here).
So, the correct code to sign ...
12
votes
What if two ether functions have the same signature?
The function signatures need to be unique only within a contract. The Solidity compiler will detect and prevent collisions if they are not unique in this case. If you have fewer than 2^16 functions ...
11
votes
workflow on signing a string with private key, followed by signature verification with public key
Here's a working example I tested out using truffle:
Example.sol
pragma solidity ^0.4.0;
contract Example {
function testRecovery(bytes32 h, uint8 v, bytes32 r, bytes32 s) returns (address) {
...
11
votes
Create and sign OFFLINE raw transactions?
You can use Web3.
var Accounts = require('web3-eth-accounts');
// Passing in the eth or web3 package is necessary to allow retrieving chainId, gasPrice and nonce automatically
// for accounts....
11
votes
How to use ethers keccak256?
With ethers.js v5 you can use:
const { ethers, utils } = require("ethers");
const labelhash = utils.keccak256(utils.toUtf8Bytes("example"))
This is documented here.
9
votes
Accepted
Can a message hash be recovered from a signature?
No, you cannot recover the message hash from an ECDSA signature. The siagnture is calculated by generating (x, y) = kG where k is the secret nonce and G is the generator for the curve. Then r = x and ...
9
votes
Accepted
How to use ethers keccak256?
Let's look at the function definition for keccak256:
export function keccak256(data: BytesLike): string {
return '0x' + sha3.keccak_256(arrayify(data));
}
The input is not a string - it's a ...
8
votes
How can I verify a signature with the web3 javascript API?
Starting v1.0 you can use web3.eth.accounts.recover
// message, signature
web3.eth.accounts.recover('Some data', '...
8
votes
Accepted
Can I web3.eth.sign with private key
N/A, in that you don't need to unlock an account at all.
Yes, see below.
The following uses Web3.js version 1.0.0-beta which is now the default installed by npm. Note that no node is attached.
> ...
8
votes
Accepted
How are tuples handled for the function selector?
Use (type1,type2,...) to represent structs.
For example, the fillOrder function in 0x 2.0:
function fillOrder(
Order memory order,
uint256 takerAssetFillAmount,
bytes memory signature
)
...
8
votes
Accepted
Verification of externally-created ECDSA signatures in Solidity
The main issue is that you're signing "TEST" but then trying to recover the signer as though you signed a hash of "\x19Ethereum Signed Message:\n4TEST".
I'm also not confident you're emitting the ...
7
votes
Ethereum ecrecover signature verification and encryption
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 ...
7
votes
Accepted
Verifying personal.sign signature with pyethereum
Everything in Python looks correct. The message hash in JavaScript is being generated incorrectly.
Preparing the Message Hash in Javascript
The message hash must be generated using the original ...
7
votes
Accepted
How to sign a send method in web3 1.0?
First, you need to generate your transaction, here is an example:
let tx_builder = contractInstance.methods.myMethod(arg1, arg2, ...);
let encoded_tx = tx_builder.encodeABI();
let ...
7
votes
Sign message with web3 and verify with openzeppelin-solidity ECDSA.sol
Rob, I see that you have already resolved (which is great).
For future readers:
For OpenZeppelin Contracts you can check the documentation for more information, in this case the Cryptography section:...
7
votes
Accepted
New contract deployment pattern (0x60c06040)?
I've been monitoring new contract deployments simply by looking for
leading 0x60806040 (truncated keccak signature) in a transaction's
data field (example).
This is not a signature, but the memory ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
signature × 560solidity × 110
web3js × 96
transactions × 80
ecrecover × 62
ecdsa × 46
cryptography × 45
metamask × 41
ethers.js × 40
private-key × 33
contract-development × 32
go-ethereum × 28
raw-transaction × 28
public-key × 25
javascript × 24
eip712 × 24
contract-design × 23
hash × 23
ethereumjs × 21
keccak × 20
python × 18
multisignature × 18
security × 16
verify × 16
blockchain × 14