Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transaction on testnet flags error on non-canonical signature #43

Open
mborgatti opened this issue Nov 30, 2018 · 2 comments
Open

transaction on testnet flags error on non-canonical signature #43

mborgatti opened this issue Nov 30, 2018 · 2 comments

Comments

@mborgatti
Copy link

I generated this transaction using the suite from utxo in the testnet and I get this error (tried to push the transaction using an electrum wallet):

error: {'code': 1, 'message': 'the transaction was rejected by network rules.\n\n64: non-mandatory-script-verify-flag (Non-canonical signature: S value is unnecessarily high)\n[0100000001A30EC4D4BA5BBC833268C4B8959280F08A9724D2B088A731E05F3E90F213A2A1010000008B483045022052487B2BEE5BD56C2D4013A3408D7B28AB893324595DFA8B4BB25D0ED2535C6E0221009047E11C5014FDDBFDF64F49BD2E6269B7F7833337A1AF7C7942104648679453014104E934D333064E2F97C93EBF223CDC5F5D38EE69EB01FBA6C81F4655283A1760A60146D3922565F131EBFEA4D6B23029B343A849B69732DC01AC8DDE267A74A5ABFFFFFFFF02E0FD1C000000000017A914A9974100AEEE974A20CDA9A2F545704A0AB54FDC87D4F69100000000001976A914DBB194A78F50021822F39127C16427693DC00BC688AC00000000]'}

I pushed it at blockcypher.com and it got accepted, but not confirmed.

Thanks
Michele

@pebwindkraft
Copy link
Owner

just checked the signature:

./tcls_strict_sig_verify.sh -vv 3045022052487B2BEE5BD56C2D4013A3408D7B28AB893324595DFA8B4BB25D0ED2535C6E0221009047E11C5014FDDBFDF64F49BD2E6269B7F7833337A1AF7C79421046486794530

S-value is beginning with "009047E11C5014FD..." so it is zero padded, to avoid high bit is set - which should be correct. I have from time to time the same issue, but don't understand the underlying checks. I fell OpenSSL is generating from time to time signatures, which don't comply with the rules of bitcoin nodes, receiving the tx. You may want to regenerate the tx, and see if you get an S-value without zero padding. I found that this happens only once out of 5 (or even worth?).

Looking at the code, I put some verification on the size of S-value. I understand that S-value must not be higher than N/2. Here the manual check with N/2:

echo "obase=16;ibase=16;FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - 9047E11C5014FDDBFDF64F49BD2E6269B7F7833337A1AF7C7942104648679453" | bc
6FB81EE3AFEB02240209B0B642D19D9502B759B377A6F0BF46904E4687CEACEE

So S-value is not greater than N/2. So I might be missing here something in the code...

@mborgatti
Copy link
Author

sorry for the slow reply, I was off for a few days.
I agree with you, I do not fully understand what the check exactly expects. As you suggested I am running the signature until I get one that does not require padding and doing so it works well
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants