What should we do if s in the ecdsa signature is greater than n/2? As we all know, in the ECDSA signature of Ethernum, the output s must be smaller than n/2, where s is the signature output and n is the ECC group order. If s>n/2, we have two choices:

  1. Should we just re-choose a k, then re-sign the message to make s
  2. Or just make $v\oplus 1$ in the signature to make r -> (x,-y)?

What Ethernum ECDSA really do?


Geth uses https://github.com/bitcoin-core/secp256k1.

And that implementation will apply option 2 https://github.com/bitcoin-core/secp256k1/blob/544435fc90a5672d862e2a51f44c10251893b97d/src/ecdsa_impl.h#L310-L315

if (secp256k1_scalar_is_high(sigs)) {
    secp256k1_scalar_negate(sigs, sigs);
    if (recid) {
        *recid ^= 1;

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.