Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: COBRAS on February 21, 2021, 12:30:21 PM



Title: Anybody share a scrypt/method for calculate R,S,Z of bitcoin raw transaction ?
Post by: COBRAS on February 21, 2021, 12:30:21 PM
Can you help with scrypt for calculatiing R,S,Z of btc raw transaction ? I was try many methods but usuccesful

for me ((


I'm use https://2xoin.com/getRSZfromRawTX/ not worked for me (((

Thx !!!


Title: Re: Anybody share a scrypt/method for calculate R,S,Z of bitcoin raw transaction ?
Post by: NotATether on February 21, 2021, 04:09:46 PM
As I told you in the other thread (https://bitcointalk.org/index.php?topic=1027221.msg56404513#msg56404513), 2xoin's tool is correct. But if you want to construct the r, s and z values by yourself, there is a helpful guide in the linked thread at http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html?m=1 . All you have to do is extract the scriptSig for each input of the raw transaction (your life is made easier by converting the raw transaction to JSON first).

https://i.ibb.co/861dSLr/5-F4-E7-EC2-96-E4-4903-AFDB-2-FC11-BC1335-A.jpg

The scriptSig is a DER signature as you can see, and it has a particular format. In this case, sequence (which we don't need), integer and integer. The last two are the r and s values (the picture calls them x and y), but first you have to "pop" the sequence number out of the DER using e.g ecdsa.der.remove_sequence(input) in Python. Then you pop r and s using two ecdsa.der.remove_integer calls, and this'll give you r and s as base10 numbers.

Then the z value is just a double SHA256 of the transaction bytes after performing a little cosmetic surgery on it to add some bytes and substitute in a Ripemd160 hash (see this code (https://github.com/stateactor/Bitcoin-Key-Compression-Tool/blob/master/txnUtils.py#L31-L54) for details).

Obviously then you convert them to hex to match what the SAGE and Python scripts and 2xoin's tool are displaying.


But if you want something quick and dirty (and you probably do), use the 2xoin page or https://github.com/stateactor/Bitcoin-Key-Compression-Tool . Be warned that the latter was coded to only get r s z for the first input of a raw transaction.


Title: Re: Anybody share a scrypt/method for calculate R,S,Z of bitcoin raw transaction ?
Post by: COBRAS on February 21, 2021, 04:14:22 PM
As I told you in the other thread (https://bitcointalk.org/index.php?topic=1027221.msg56404513#msg56404513), 2xoin's tool is correct. But if you want to construct the r, s and z values by yourself, there is a helpful guide in the linked thread at http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html?m=1 . All you have to do is extract the scriptSig for each input of the raw transaction (your life is made easier by converting the raw transaction to JSON first).

https://i.ibb.co/861dSLr/5-F4-E7-EC2-96-E4-4903-AFDB-2-FC11-BC1335-A.jpg

The scriptSig is a DER signature as you can see, and it has a particular format. In this case, sequence (which we don't need), integer and integer. The last two are the r and s values (the picture calls them x and y), but first you have to "pop" the sequence number out of the DER using e.g ecdsa.der.remove_sequence(input) in Python. Then you pop r and s using two ecdsa.der.remove_integer calls, and this'll give you r and s as base10 numbers.

Then the z value is just a double SHA256 of the transaction bytes after performing a little cosmetic surgery on it to add some bytes and substitute in a Ripemd160 hash (see this code (https://github.com/stateactor/Bitcoin-Key-Compression-Tool/blob/master/txnUtils.py#L31-L54) for details).

Obviously then you convert them to hex to match what the SAGE and Python scripts and 2xoin's tool are displaying.


But if you want something quick and dirty (and you probably do), use the 2xoin page or https://github.com/stateactor/Bitcoin-Key-Compression-Tool . Be warned that the latter was coded to only get r s z for the first input of a raw transaction.

Hi, Bro, see this message - https://bitcointalk.org/index.php?topic=1027221.msg56405486#msg56405486 there a Mamuu, calculate manualy, but 2xoin was unsuccessful !!!!!



Title: Re: Anybody share a scrypt/method for calculate R,S,Z of bitcoin raw transaction ?
Post by: dextronomous on February 23, 2021, 11:55:11 PM
Who's site, Sean Bradley it says,
are you also user here, if so, reading this, could you add some extra function
at this website, 2xoin ? thanks a lot. Love that site, since 2coin left, this one is usefull for me thanks a lot
for making it.


Title: Re: Anybody share a scrypt/method for calculate R,S,Z of bitcoin raw transaction ?
Post by: math09183 on February 24, 2021, 07:22:56 PM
Can you help with scrypt for calculatiing R,S,Z of btc raw transaction ? I was try many methods but usuccesful

for me ((


I'm use https://2xoin.com/getRSZfromRawTX/ not worked for me (((

Thx !!!


https://github.com/stateactor/Bitcoin-Key-Compression-Tool