1

EIP-155 states:

If block.number >= FORK_BLKNUM and v = CHAIN_ID * 2 + 35 or v = CHAIN_ID * 2 + 36, then when computing the hash of a transaction for purposes of signing or recovering, instead of hashing only the first six elements (ie. nonce, gasprice, startgas, to, value, data), hash nine elements, with v ...

These are instructions for the hashing party, but not the the original signing party. Therefore, the question arises: when signing a transaction, should one use the first equation (with 35) or second equation (with 36). Practically speaking, sometimes only the former works and sometimes only the latter and I was unable to find a clear rationale.

Could someone explain the logic by which to choose between these 2 options? A reference to a document which defines the needed logic here would also be much appreciated.

Thanks in advance,

Tal

1

1 Answer 1

2

As @Ismael commented, the v is the "recovery ID", during transaction validation, v is used to recover the account's public key (Look at the Ethereum transaction structure, there is no field that explicitly states the "from" account. The "from" is worked out by recovering the public key from the signature).

Coming back to the text in EIP-155, it might be slightly confusing, as it's talking about two things

  • the original value of v, i.e. the "recovery ID", either 1 or 0 (unrelated to the original question, but the calculation can be found here),
  • how to encode v (essentially re-using this field to carry additional information [i.e. chain ID] for replay attack prevention)

The encoding is done as CHAIN_ID * 2 + (V_recoveryId + 35). Consider the V_recoverId can be either 1 or 0, the result is either CHAIN_ID * 2 + 35, or CHAIN_ID * 2 + 36.

The encoding inside the Geth client code can be found here. It's clear to see it's not "choose between 2 options", but just simple addition.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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