0

Understand VRS is the output of ECDSA. Not many will use ecrecover() to check for the signature.

How does the public ethereum network handle an invalid transaction signed with an invalid private key? What happens to the transaction? Will it be propagted and/or recognised by majority of the nodes or rejected?

1

A transaction with an invalid signature will not be propagated, and in the event that it somehow got to a miner it would not be included in a block. If a miner did include it in a block, that block would be invalid, and it would be rejected by the rest of the network.

A transaction that called a contract that checked signatures as part of its processing (using ecrecover on data supplied as part of a correctly-signed transaction) would be executed, and the results of that ecrecover call would be returned to the calling contract. Normally when you use ecrecover you have an address or some addresses that you are testing for, and if someone feeds it invalid signature data, it will return some address that isn't the one you're testing for. At that point the contract would usually revert to abort transaction processing, but that depends on the contract code.

1

Depends on what you mean by invalid signature.

  • If some of the v, r, s are not within the valid length then the transaction is invalid and it will be rejected by compliant nodes. v should be 1 byte, r and s are 32 bytes each.

  • If v, r, s are of valid length but v doesn't follow EIP 155 - Replay protection then the transaction is invalid and it will be rejected.

  • If v, r, s are valid and follow EIP 155 then transaction will be propagated by nodes. Before executing the transaction miners node will execute ECDSA recovery to determine sender address. Then it will check if they have enough balance to pay transaction fees if there's not enough the transaction will not be processed.

1

Here is an explanation of an attack that happened on Ropsten network on June 5th 2018 Invalid signature was included into the block 3377452

Example on how to create invalid unsigned transaction:

const EthereumTx = require('ethereumjs-tx')
const chain = 99;

const txParams = {
  nonce: '0x0',
  gasPrice: 0,
  gasLimit: 30000,
  to: '0x4a071eee72bc8664c81b62836932ed0d246da82b',
  value: '0x00',
  data: '0x',
  chainId: chain,
  r: 0,
  s: 0,
  v: chain
}

const tx = new EthereumTx(txParams)

const serializedTx = tx.serialize()
console.log('0x' + serializedTx.toString('hex'))

which will generate RLP-encoded transaction which you can send using eth_sendRawTransaction JSONRPC Api.

Once tx is mined, the tx details will look like the following:

{
  "jsonrpc": "2.0",
  "result": {
    "blockHash": "0xd8fbb544a4b7ca073c5fb43a768d2497c583e4a557be926581aabc5c304bbd96",
    "blockNumber": "0x4",
    "chainId": "0x63",
    "condition": null,
    "creates": null,
    "from": "0xffffffffffffffffffffffffffffffffffffffff",
    "gas": "0x7530",
    "gasPrice": "0x0",
    "hash": "0xf7a2b1a30c16281337047f2018eef633a131c5ad235d3749a71bedaa57710c02",
    "input": "0x",
    "nonce": "0x0",
    "publicKey": null,
    "r": "0x0",
    "raw": "0xdf808082753094ea674fdde714fd979de3edf0f56aa9716b898ec88080638080",
    "s": "0x0",
    "standardV": "0x0",
    "to": "0xea674fdde714fd979de3edf0f56aa9716b898ec8",
    "transactionIndex": "0x0",
    "v": "0x63",
    "value": "0x0"
  },
  "id": 1
}

The important part here is that we don't have private key from
0xffffffffffffffffffffffffffffffffffffffff address but we did generated and sent a tx to a ethereum network.

Full details and video tutorial: blog-post

Video explanation: YouTube

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.