Title: PubKey Transaction verification with python - Problem Post by: cz3kit on March 01, 2017, 12:54:33 AM Hey everyone, I hope this is the right place to ask this question.
I am currently working on a blockchain parser. It is just for me to get a better understanding on how everything works. I am currently stuck on pubkey verification and maybe someone would be able to help me out. I am currently working on the following block : https://blockchain.info/tx/f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16 (https://blockchain.info/tx/f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16) I would like to verify the non-coinbase input. I wrote therefore a small python script with a ECDSA Verification function. I tested it with several signatures and it seems to work. As another resource I use https://en.bitcoin.it/wiki/OP_CHECKSIG (https://en.bitcoin.it/wiki/OP_CHECKSIG) where it describes the process of verification. I wanted to download the code, but it got moved and I was not able to find the files in order to make it work :( These are the values I extraced: Code: #bitcoin curve I am not 100% sure if the r and s value are correct extracted. The value of the message is from the second link. Another problem I am facing is, which hash of the message is the correct one? Maye both are wrong? Is there someone who could help me and verify the values? I can|t find a good tutorial regarding that problem :( Title: Re: PubKey Transaction verification with python - Problem Post by: achow101 on March 01, 2017, 04:25:20 AM Hey everyone, I hope this is the right place to ask this question. That is a transaction, not a block.I am currently working on a blockchain parser. It is just for me to get a better understanding on how everything works. I am currently stuck on pubkey verification and maybe someone would be able to help me out. I am currently working on the following block : https://blockchain.info/tx/f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16 (https://blockchain.info/tx/f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16) I would like to verify the non-coinbase input. I wrote therefore a small python script with a ECDSA Verification function. I tested it with several signatures and it seems to work. As another resource I use https://en.bitcoin.it/wiki/OP_CHECKSIG (https://en.bitcoin.it/wiki/OP_CHECKSIG) where it describes the process of verification. I wanted to download the code, but it got moved and I was not able to find the files in order to make it work :( The r and s values look right to me.These are the values I extraced: Code: #bitcoin curve I am not 100% sure if the r and s value are correct extracted. The value of the message is from the second link. Another problem I am facing is, which hash of the message is the correct one? Maye both are wrong? The message that is signed is the sha256 of the sha256 of the transaction with the signing serialization (which is your second hash). Note that this is different from the transaction id which is the sha256 of the sha256 of the entire transaction.Title: Re: PubKey Transaction verification with python - Problem Post by: cz3kit on March 01, 2017, 08:37:25 AM I see I had been in the wrong section, sorry.
Hey everyone, I hope this is the right place to ask this question. That is a transaction, not a block.I am currently working on a blockchain parser. It is just for me to get a better understanding on how everything works. I am currently stuck on pubkey verification and maybe someone would be able to help me out. I am currently working on the following block : https://blockchain.info/tx/f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16 (https://blockchain.info/tx/f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16) I would like to verify the non-coinbase input. I wrote therefore a small python script with a ECDSA Verification function. I tested it with several signatures and it seems to work. As another resource I use https://en.bitcoin.it/wiki/OP_CHECKSIG (https://en.bitcoin.it/wiki/OP_CHECKSIG) where it describes the process of verification. I wanted to download the code, but it got moved and I was not able to find the files in order to make it work :( The r and s values look right to me.These are the values I extraced: Code: #bitcoin curve I am not 100% sure if the r and s value are correct extracted. The value of the message is from the second link. Another problem I am facing is, which hash of the message is the correct one? Maye both are wrong? The message that is signed is the sha256 of the sha256 of the transaction with the signing serialization (which is your second hash). Note that this is different from the transaction id which is the sha256 of the sha256 of the entire transaction.An idea which code I could use to test and see how it exactly works? Title: Re: PubKey Transaction verification with python - Problem Post by: cz3kit on March 01, 2017, 11:28:00 PM After working on it I found a solution. Might be useful to others, maybe.
Code: message = "0100000001c997a5e56e104102fa209c6a852dd90660a20b2d9c352423edce25857fcd37040000000043410411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3acffffffff0200ca9a3b00000000434104ae1a62fe09c5f51b13905f07f06b99a2f7159b2225f374cd378d71302fa28414e7aab37397f554a7df5f142c21c1b7303b8a0626f1baded5c72a704f7e6cd84cac00286bee0000000043410411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3ac0000000001000000" |