Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 为什么Blockcypher签名工具比bip32 dart包返回更多字符?_Flutter_Dart_Bitcoin_Bitcoin Testnet_Blockcypher - Fatal编程技术网

Flutter 为什么Blockcypher签名工具比bip32 dart包返回更多字符?

Flutter 为什么Blockcypher签名工具比bip32 dart包返回更多字符?,flutter,dart,bitcoin,bitcoin-testnet,blockcypher,Flutter,Dart,Bitcoin,Bitcoin Testnet,Blockcypher,我试图签署一个交易框架Blockcypher返回,以便发送它,如下所示 在这个例子中,我将使用完全不安全的“原始”助记符,它使用dart bip32包创建一个带有私钥0x05A2716A8EB37EB2AA72594573165349498AA6CA20C71346FB15D82C0CBBF7C的bip32,并为BTC testnet地址MPQFIFFQ7SHVZS9EBXMRGVOHWRJF9RA Blockcypher Tx Skeletontosign为1cbbb4d229dcafe6dc

我试图签署一个交易框架Blockcypher返回,以便发送它,如下所示

在这个例子中,我将使用完全不安全的“原始”助记符,它使用dart bip32包创建一个带有私钥0x05A2716A8EB37EB2AA72594573165349498AA6CA20C71346FB15D82C0CBBF7C的bip32,并为BTC testnet地址MPQFIFFQ7SHVZS9EBXMRGVOHWRJF9RA

Blockcypher Tx Skeletontosign为1cbbb4d229dcafe6dc3363daab8de99d6d38b043ce62b7129a8236e40053383e

使用:

另一方面,使用bip32我得到:

String toSign = txSkel['tosign'][0];
var uToSign = crypto.hexToBytes(toSign);
var signed = fromNode.sign(uToSign);
var signedHex = bufferToHex(signed);
var signedHexNo0x = signedHex.substring(2);
其中
fromNode
是bip32.bip32节点。输出为
signedHexNo0x=2711792B72547D2A1730A319BD219854F0892451B8C2AB8C17EC0C6CBA4ECC458F675CA0AF3DB455913E59DADC7C5E0BD0BF1B8EF8C13E830A627A18AC375AB

乍一看,它们似乎是完全不同的缓冲区,但经过详细查看,Blockcypher签名者输出仅比bip32多了一些字符:

我希望两个64个字符的数字给出一个128个字符的签名,这是bip32输出完成的。因此,Blockcypher签名者输出有140个字符,即比前者多12个字符,这在如上所述分成几行时是清楚的


我真的很感谢有人在这个问题上提出一些见解,我需要理解和纠正。我需要在dart中实现该解决方案,除了用于测试之外,我不能使用签名者脚本。

dart bip32包似乎没有以DER格式编码签名,而是以简单的(r,s)编码。但是,比特币需要DER。有关更多信息,请参阅:


您可以根据r和s自己添加DER额外字节,或者检查dart bip32库中是否有DER编码。

太好了,Matthieu,这让我走上了正确的轨道。我应用了DER签名,效果很好。我甚至在考虑对bip32 dart进行公关,也许其他人会从中获利。谢谢
String toSign = txSkel['tosign'][0];
var uToSign = crypto.hexToBytes(toSign);
var signed = fromNode.sign(uToSign);
var signedHex = bufferToHex(signed);
var signedHexNo0x = signedHex.substring(2);
Blockcypher signer output (I split it into several lines for you to see it clearly):
30440220
2711792b72547d2a1730a319bd219854f0892451b8bc2ab8c17ec0c6cba4ecc4
0220
58f675ca0af3db455913e59dadc7c5e0bd0bf1b8ef8c13e830a627a18ac375ab
bip32 output (also intentionally split):
2711792b72547d2a1730a319bd219854f0892451b8bc2ab8c17ec0c6cba4ecc4
58f675ca0af3db455913e59dadc7c5e0bd0bf1b8ef8c13e830a627a18ac375ab