I made a bitcoin transaction, but I keep getting this error when I try to send it out:
mandatory-script-verify-flag-failed (Non-canonical signature: S value is unnecessarily high) (code 16)
HEX-WITH-HIGH-S
I did some digging online and it looks like the S value in my ScriptSig is too high. I think I found a way to change my High-S value to Low-S, but I'm not sure if I'm doing it right since it’s still not working.
HEX-WITH-LOW-S
Can anyone lend a hand? I’d really appreciate any tips.
Issue with converting high-S signature in a transaction
3 replies 431 views
coin_sigmaLegendary
Posts: 1275 · Reputation: 5553
#2Mar 3, 2017, 11:17 AM
I'm not familiar with the error code is this from openssl when broadcasting a transaction?
I tried to search a bit and I found a similar issue but the error code is different. I tried to search here on the forum and I found a similar error code he fixed the issue so it might also work for you check the post from this link below
- https://bitcointalk.org/index.php?topic=5226185.msg53958884#msg53958884
In ECDSA when you create a signature (r,s) using your private key, the (r,-s) signature is also a valid signature and anybody can compute -s without needing your private key.
That creates a malleability issue. Meaning any node receiving your transaction can just negate the s value in your signature(s) and create a malleated transaction that would also have a different transaction ID for legacy transactions.
To prevent that, the nodes only accept one of the two equivalent "s" values that is considered a "low s" meaning a value that is lower than half the curve order and reject the other one with the error message you saw.
So whenever you sign a transaction, you just need to check your final s value and if it were bigger than N/2 you simply negate it.
Thank You BitMaxz and pooya87 for your replays.
To clarify, I am not the creator of the transaction or the owner of the wallet, but the recipient of the transaction.
I've looked through all the topics with similar problems, probably I'm making a mistake by adding the s-value manually, because I have no idea about how to do it correctly.
In this post https://bitcointalk.org/index.php?topic=1356430.0, user luv2drnkbr corrected and broadcasted this transaction by having only hex. I'm following this but I'm not sure if I did everything right, but since I don't have access to wallet, I assume this is my only hope.
Assuming I calculated the low-S value correctly, what should I do to add it to the hex properly?
BTW.
I'm also considering the possibility that I was scammed... any help figuring this out would be greatly appreciated.