2

I'm trying to convert a scriptsig into bytes so that I can better extract R & S values, but when I try and convert, I'm missing some of elements that should be there, like x30 for example.

scriptsig = '473044022015d8e1ba1d7fa0bd065f3da2d91d71d12890ff4d9a655161783504714c8b06a3022007d71d93d79039d73fc47ab9787128b7a6d7449e72688f0cf6dc175cfa90755d0121037ab79af7f21e54e03297fc9447952bfacedc57dcebd802eb19ba75636ad1fd5e'

import binascii
bytes1 = binascii.unhexlify(scriptsig) #doesn't work
bytes2 = scriptsig.decode('base64') #doesn't work

The output:
bytes1
'G0D\x02 \x15\xd8\xe1\xba\x1d\x7f\xa0\xbd\x06_=\xa2\xd9\x1dq\xd1(\x90\xffM\x9aeQax5\x04qL\x8b\x06\xa3\x02 \x07\xd7\x1d\x93\xd7\x909\xd7?\xc4z\xb9xq(\xb7\xa6\xd7D\x9erh\x8f\x0c\xf6\xdc\x17\\\xfa\x90u]\x01!\x03z\xb7\x9a\xf7\xf2\x1eT\xe02\x97\xfc\x94G\x95+\xfa\xce\xdcW\xdc\xeb\xd8\x02\xeb\x19\xbaucj\xd1\xfd^'

bytes2
'\xe3\xbd\xf4\xe3\x8d6\xdbMyw\xc7\xb5m\xad]\xed\xf6\xb4m\xdd:\xe5\xfd\xddkg}\xd5\xde\xf5w]\xbc\xf7G\xdf\xe1\xdfZ\xeb\x9eu\xeb^\xfc\xdf\x9d8\xef^\x1c\xf1\xbd:k}6\xdbM;w\xbd]\xf7w{\xf7M\xfdw\xbd\xdfs\x8e\xdao\xde\xfc\xef]\xbco\xb6\xbaw\xbe8\xf5\xee\xf6\xeb\xcf\x1f\xd1\xc7\xfau\xcd{\xe5\xc7\xda\xf7N\xf9\xe5\xdd5\xdb]7\xed\xa6\xfb\xf5\xa7\xfb\x7fm^\xe7\x87\xb4\xdfo{}\xcfx\xe3\xbfy\xd9\xb7\xdaq\xe7\\\xe7\xb7\\y\xb7|\xd3g\x9b\xd7\xd6\xda\xef\x9e\xb7\xe9\xa7u}\xde^'

Once I got the right format I was going to use asn1decoder to parse for x30 and then extract R and S

1

0x30 is there it's '0' in ascii (second character in your bytes1)

>>> b'\x30'
b'0'

You also want to extract the signature from the scriptSig before passing it to a decoder, right now it contains both the signature and the public key.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.