I am using BouncyCastle to generate .NET core packet signatures. I want to be able to get the v value for the Ethereum signature.

To these ends, and with my understanding of the meaning of the v value, my aim is to take the source for ECDSASigner, modify it to a custom local version, and return the correct v value on the basis of the discovered X coordinate in that code.

What I don't know though is which of the values 27..30 (27..28 in Ethereum yellow paper), correspond to which of the possible outputs. Is eg: 27==positive Y for given X?

Also, btw where is this stuff documented? YellowPaper.io refers to "The Literature" but where?


I think I found it. Basically this code from the bitcoin core libraries define the v value

*recid = (overflow ? 2 : 0) | (secp256k1_fe_is_odd(&r.y) ? 1 : 0);

That gets added to 27 for Ethereum, while 29 and 30 are invalid according to YellowPaper.io

  • Please note that if an implementation supports EIP-155, instead of using 27 or 28, it uses CHAIN_ID* 2 + 35. So the value of "v" can also be 37 or 38 – Linmao Song Jan 15 '18 at 12:05
  • Thanks. Also, to add, it seems the v value definition comes from the sec specification for compressing points to octet strings secg.org/sec1-v2.pdf (section 2.3.3) – Sentinel Jan 15 '18 at 13:30

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.