Bitcoin Forum
September 27, 2021, 04:54:42 PM *
News: Latest Bitcoin Core release: 22.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Handiest way to verify a signature in isolation  (Read 854 times)
edmundedgar
Sr. Member
****
Offline Offline

Activity: 352
Merit: 250


https://www.realitykeys.com


View Profile WWW
June 21, 2014, 09:37:16 AM
 #1

So I've been hacking on bitcore.io trying to do some (hopefully not for much longer, Inshallah) non-standard transactions with it, and I'm finding they're getting rejected by my testnet node for being invalid. I can generate the same transactions with a python script I made earlier and get them accepted and mined OK, and the hash that's getting passed to the sign code seems to be the same in both cases, so I reckon I'm somehow screwing up the actual signature creation rather than elsewhere in the script, but I'd like to test the signatures in isolation to be sure and confirm that the ones getting created by my JavaScript are definitely wonky where the ones created by my Python code are good.

Any suggestions for an easy, hard-to-screw-up-when-sleep-deprived way to verify a signature in isolation? I'm wondering if I can do something like (made-up options follow):
Code:
openssl --i-would-like-to-verify-a-signature-please --ecdsa-something-or-other <pubkey> <hash_that_gets_passed_in_for_signing> <signature>
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1632761682
Hero Member
*
Offline Offline

Posts: 1632761682

View Profile Personal Message (Offline)

Ignore
1632761682
Reply with quote  #2

1632761682
Report to moderator
1632761682
Hero Member
*
Offline Offline

Posts: 1632761682

View Profile Personal Message (Offline)

Ignore
1632761682
Reply with quote  #2

1632761682
Report to moderator
dexX7
Legendary
*
Offline Offline

Activity: 1106
Merit: 1005



View Profile WWW
June 21, 2014, 06:19:37 PM
 #2

Probably not exatly what you are looking for, but you may could give python-bitcoinlib a try:

https://github.com/petertodd/python-bitcoinlib/blob/master/examples/spend-pay-to-script-hash-txout.py

12648430
Full Member
***
Offline Offline

Activity: 144
Merit: 100


View Profile
June 21, 2014, 06:49:07 PM
 #3

bitcoind has some unit tests that are exactly what you want; you could copy one, put in your own values, and run it as a bitcoind test. You could do it with openssl but you'd probably need to convert the pubkey into an openssl-compatible format somehow.
edmundedgar
Sr. Member
****
Offline Offline

Activity: 352
Merit: 250


https://www.realitykeys.com


View Profile WWW
June 26, 2014, 07:21:45 AM
 #4

Thanks for the suggestions. I ended up doing it the other way: Instead of verifying the signatures my JavaScript was emitting, I plugged in a couple of signatures for the same transaction from my Python code to prove that the rest of the JavaScript was OK and figured it out that way. (Seems like my signatures were OK but I had them in the wrong order, which results in OP_CHECKMULTISIG reporting an invalid signature???)
Aleksei Richards
Newbie
*
Offline Offline

Activity: 38
Merit: 0



View Profile
June 26, 2014, 01:16:39 PM
 #5

Thanks for the suggestions. I ended up doing it the other way: Instead of verifying the signatures my JavaScript was emitting, I plugged in a couple of signatures for the same transaction from my Python code to prove that the rest of the JavaScript was OK and figured it out that way. (Seems like my signatures were OK but I had them in the wrong order, which results in OP_CHECKMULTISIG reporting an invalid signature???)

Yes you do need them in the correct order as I've just found out.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!