我已经阅读了几篇文章,并且我熟悉scriptsig的格式以及如何从中提取相关信息。我遇到的问题是将其放入代码中。我已阅读以下帖子: https://bitcoin.stackexchange.com/questions/58853/how-do-you-figure-out-the-r-and-s-out-of-a-signature-using-python https://bitcoin.stackexchange.com/questions/2376/ecdsa-r-s-encoding-as-a-signature
我有一个scriptsigs列表,并且我有一个函数(到目前为止),该函数在scriptsig字符串上使用切片:
def scriptsig_to_ecdsa_sig(asn_sig):
strip1 = asn_sig[6:] #Remove first 6 characters
if strip1[:2] == "20" #Read next two characters to determine length of r
return {
'r': some list,
's': some list}
这是最好的路线吗?如果是这样,完成它的最佳方法是什么?
答案 0 :(得分:0)
想通了:
from pyasn1.codec.der import decoder as asn1der
int_value = asn1der.decode(asn_sig.decode('hex')[1:]) #asn_sig is the scriptsig hex
long(int_value[0][0]) #R Value in int form
long(int_value[0][1]) #S Value in int form