我有一笔交易,我正在尝试从s
中找到r
,m
和s = (m + r * x) / k
。
var tx = new NBitcoin.Transaction("01000000014af76d127f2c525a5afe00a7003d5dec1bfdff15d96dbae7e394efa337c9245a000000008b483045022100c717169b0055cf66d79d4cc59d05ce220341efd80985fa30bbfa88e9b69ecfb0022010dbe3a7e3bc3201df8a42081c869f981bdd9d3e465f5fc483eaafab82f1ce7c014104a45ebc40f95cc06ef93a5f5e9daa22774a5c9a120ac14d87c328b44c1158f81cddd109246a4d8bff5f93cbba79a17f2dc6e7c73da8d6bd0d98615d1bf353f8beffffffff01f76a0000000000001976a914170a13c86ece92a9b902dbb5f367e361f227f08f88ac00000000");
我可以拔出s
和r
:
var txIn = tx.Inputs.First();
var signature = txIn.ScriptSig.ToString();
var rLength = Convert.ToInt32(signature.Substring(6, 2), 16) * 2;
var r = new BigInteger(input.ScriptSignature.Substring(8, rLength).ToBytes());
var sLength = Convert.ToInt32(input.ScriptSignature.Substring(8 + rLength + 2, 2), 16) * 2;
var s = new BigInteger(input.ScriptSignature.Substring(8 + rLength + 2 + 2, sLength).ToBytes());
但是我似乎无法弄清楚m
。我知道这是产生r
和s
的某些消息的double sha2哈希,但是它来自何处或如何组合似乎是一个谜。我花了几天时间浏览NBitcoin的源代码,但我很迷茫。
有几件事我觉得很亲密,但是没有运气:
var hopingWasM = new BigInteger(tx.GetSignatureHash(txIn.ScriptSig, 0, SigHash.All).ToBytes());
和
HashStream hashStream = new HashStream();
BitcoinStream bitcoinStream = new BitcoinStream(hashStream, true);
bitcoinStream.Type = SerializationType.Hash;
bitcoinStream.TransactionOptions = TransactionOptions.None;
txIn.ReadWrite(bitcoinStream);
var hopingWasM = new BigInteger(((HashStream)bitcoinStream.Inner).GetHash().ToBytes());
找到m
的最简单方法是什么?