0

I've written a small script that will create a bitcoin transaction from scratch, using an ECDSA library. It works, but sometimes I get this error:

64: non-mandatory-script-verify-flag (Non-canonical signature: S value is unnecessarily high)

I found this reply answer on bitcoin talk:

The signature is composed of two values, the r value and the s value. In your third input, the s value is greater than N/2, which is not allowed. Just add in some code that if s is greater than N/2, then s = N - s.

But what exactly is N?

2

It seems as though N is the order of the elliptic curve.

Or in other words, the number of possible points on the secp256k1 curve.

N = 115792089237316195423570985008687907852837564279074904382605163141518161494337
1

This is one of the parameters of elliptic curve. The secp256k1 curve used in bitcoin have parameter N set to:

N = FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141

  • You seem to be missing some (hex) digits. – Pieter Wuille Jan 11 '18 at 23:47
  • @PieterWuille you are right. Nów it should be fixed. – Michał Zabielski Jan 12 '18 at 5:14

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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