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

Bitcoin-lib may produce valid but different signatures from bitcoin-core #25

Open
araspitzu opened this issue Sep 28, 2018 · 1 comment

Comments

@araspitzu
Copy link

There is a scenario where the signature produced by bitcoin-lib is different than the one made by bitcoin-core, it's a legacy multisig (P2SH) with 2-of-2 signatures required. For clarity i reproduced the issue in bitcoin using regtest mode and comparing the produced scriptSig with the one from bitcoin-lib,
the example is located here, to run the test:

$ test/functional/regtest_signature.py

The test in bitcoin-lib tries to sign the same input of the same transaction (also with same private keys)
and results in a mismatch of the signature (specifically the last in the 2-of-2), this is located here.This test shows that the signature script (for legacy p2sh multisig) produced in this case is different from the one made by bitcoin-core. I also added sighash tests (both in bitcoin-core and bitcoin-lib) to check that we're signing the same data, those test can be found in the same git branch of the above examples.

@sstone
Copy link
Member

sstone commented Oct 12, 2018

Bitcoin-lib still creates valid signatures, but they may be different from the ones created by bitcoin core since bitcoin/bitcoin@18dfea0.
AFAICT none of the reference tests depend on creating exactly the same sigs and will still pass, but I guess that in some cases in may make the life of lib developers a bit harder. Reproducing exactly the same behaviour is not so easy yet because first the JNI bindings for libsecp256k1 would have to be updated, so I'll leave this issue open in case someone wonders why our sigs may be different from core's. Thanks for the test data!

@sstone sstone changed the title Signing P2SH input produces different signatures from bitcoin-core Bitcoin-lib may produce valid but different signatures from bitcoin-core Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants