How can I fix this: (Non-canonical signature: S value is unnecessarily high)

1

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?

inersha

Posted 2018-01-11T18:20:59.527

Reputation: 2 236

Answers

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

inersha

Posted 2018-01-11T18:20:59.527

Reputation: 2 236

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

MichaƂ Zabielski

Posted 2018-01-11T18:20:59.527

Reputation: 326