I'm trying to test my code with the BIP143 reference transactions, but I hit a wall with the first example for Native P2WPKH. I'm working on signing segwit inputs, and it seems to be fine, but my P2PK input isn’t producing the right preimage for signing. This is the preimage I'm using, and after taking out the sighash, I got...
{"txid": "66bd35"
Need Help with P2PK Transaction Signing
2 replies 450 views
matrix2021Full Member
Posts: 14 · Reputation: 612
#2Sep 14, 2023, 03:45 PM
Have you checked the sighash tests available on GitHub? They might help isolate the issue since signatures can shift due to different nonces. Those tests are more reliable for diagnosing what's wrong without the signature noise. By the way, libsecp has been around for a while now, since 2013, and is used in Core since 2014, so it should be solid.
Thanks for the advice! I was using coincurve for generating my signatures, but it turns out it was hashing the message additional times before signing. I didn't know that! I found an option to turn off that hasher, but it just led to complaints about byte length. So I tweaked my code, removed one of my SHA256 calls, and let the library handle the hashing. Now everything works perfectly!