Tezos交易的无效签名
2 个回答
- 投票数
-
- 2020-04-24
有两个有效的EC点对应于相同的签名,但是一些区块链将用法限制为这两个EC点之一,以避免延展性(=容易将签名转换为另一个签名值,从而创建第二个有效交易,该交易将具有不同的交易ID,而无需访问私钥).
编辑: 相应的有效交易是:
008f1d96e2783258ff663f03dacfe946c026a5d194c73d1987b3da73fadea7d46b01549a0cde570a49b9200680341a6c78e87635480f940adc85a001f44eac02010238244743822921db1661fc7306c3044faac1e373906fdb5582d9454352b3b31c6c01549a0cde570a49b9200680341a6c78e87635480ff00bdd85a0018452ac02e0a712000153957451d3cc83a71e26b65ea2391a1b16713d2d0049ff4a47599e0c65447182eca4c900893a74de3ca24c26708fc9d4bf79891ca384b0d5f98618bc3acec4f0c6bffd002de6fd839a418f47e83404aed285fc0235结果 它是在没有重新签名且无法访问私钥的情况下创建的.There are two valid EC points that correspond to the same signature, but some blockchains restrict the usage to one of those two EC points to avoid malleability (= it is easy to convert the signature to the other signature value, and thus create a second valid transaction which would have a different transaction id without haveing access to the private key).
Edit: The corresponding valid transaction is:
008f1d96e2783258ff663f03dacfe946c026a5d194c73d1987b3da73fadea7d46b01549a0cde570a49b9200680341a6c78e87635480f940adc85a001f44eac02010238244743822921db1661fc7306c3044faac1e373906fdb5582d9454352b3b31c6c01549a0cde570a49b9200680341a6c78e87635480ff00bdd85a0018452ac02e0a712000153957451d3cc83a71e26b65ea2391a1b16713d2d0049ff4a47599e0c65447182eca4c900893a74de3ca24c26708fc9d4bf79891ca384b0d5f98618bc3acec4f0c6bffd002de6fd839a418f47e83404aed285fc0235
This was created without re-signing and without access to the private key. -
- 2020-04-19
确保您只公开了一次公钥,并确保正确增加柜台数量.
此外,请查看C#Tezos SDK Netezos .这是有关如何进行伪造,签名和发送交易的示例:
var key = Key.FromBase58("edskS9DjUKo8ogBBU8LeU..."); var rpc = new TezosRpc("https://rpc.tzkt.io/carthagenet/"); var head = await rpc.Blocks.Head.Hash.GetAsync<string>(); var counter = await rpc.Blocks.Head.Context.Contracts[key.PubKey.Address].Counter.GetAsync<int>(); var forge = new LocalForge(); var bytes = await forge.ForgeOperationAsync(head, new TransactionContent { Source = key.PubKey.Address, Counter = ++counter, Fee = 10_000, GasLimit = 20_000, StorageLimit = 20_000, Amount = 1_000_000, Destination = "tz1KhnTgw...", }); var sig = key.Sign(new byte[] { 3 }.Concat(bytes).ToArray()); var op = bytes.Concat(sig.ToBytes()).ToArray(); var tx = await rpc.Inject.Operation.PostAsync(Hex.Convert(op));
如果即使使用Netezos也无法使用,请检查您的RPC节点是否已同步并且是最新的.
Make sure you revealed public key just once and make sure you properly incement counter.
Also, take a look at Netezos, C# Tezos SDK. Here is an example of how to forge, sign and send a transaction:
var key = Key.FromBase58("edskS9DjUKo8ogBBU8LeU..."); var rpc = new TezosRpc("https://rpc.tzkt.io/carthagenet/"); var head = await rpc.Blocks.Head.Hash.GetAsync<string>(); var counter = await rpc.Blocks.Head.Context.Contracts[key.PubKey.Address].Counter.GetAsync<int>(); var forge = new LocalForge(); var bytes = await forge.ForgeOperationAsync(head, new TransactionContent { Source = key.PubKey.Address, Counter = ++counter, Fee = 10_000, GasLimit = 20_000, StorageLimit = 20_000, Amount = 1_000_000, Destination = "tz1KhnTgw...", }); var sig = key.Sign(new byte[] { 3 }.Concat(bytes).ToArray()); var op = bytes.Concat(sig.ToBytes()).ToArray(); var tx = await rpc.Inject.Operation.PostAsync(Hex.Convert(op));
If it doesn't work even with Netezos, check if your RPC node is synced and up to date.
-
基于原始问题中的JSON和发件人地址的状态[link](https://tezos.id/accounts/tz2G2Zy3sgYCuh1EQqrx9Q62CcpSkgcLPPDt),计数器和显示是否正常?Based on the JSON in the original question and the status of the sender address [link](https://tezos.id/accounts/tz2G2Zy3sgYCuh1EQqrx9Q62CcpSkgcLPPDt), does counter & reveal look ok?
- 0
- 2020-04-20
- Felix Laufenberg
-
我建议您使用TzKT资源管理器,因为它显示了更多有用的信息,包括mempool https://tzkt.io/tz2G2Zy3sgYCuh1EQqrx9Q62CcpSkgcLPPDt/operations中失败的操作.因此,我看到的是在Mempool操作中有两个失败,分别来自UTC时间12:01:49的计数器..72`,.. 73`.在您的问题中,我看到与分支https://tzkt.io/BKiXcfN1ZTXnNNbTWSRArSWzVFc6om7radWq5mTqGX6rY4P2Uhe-从`12:55:12 UTC`开始具有相同计数器的JSON.因此,我假设您尝试使用已经在内存池中的计数器..72`和..73发送操作.I suggest you use TzKT explorer, because it shows more useful info, including operations failed in mempool https://tzkt.io/tz2G2Zy3sgYCuh1EQqrx9Q62CcpSkgcLPPDt/operations. So, what I see is two failed in mempool operations with counters `..72`, `..73` from `12:01:49 UTC`. In your question I see JSON with the same counters BUT with the branch https://tzkt.io/BKiXcfN1ZTXnNNbTWSRArSWzVFc6om7radWq5mTqGX6rY4P2Uhe - from `12:55:12 UTC`. So, I assume that you tried to send the operations with the counters `..72`, `..73` which had already been in mempool.
- 1
- 2020-04-20
- Groxan
-
一般来说,您的JSON看起来不错,但是内存池中的"克隆"失败的事实可能会导致您描述的错误.Generally speaking, your JSON looks fine, but the fact that there were failed "clones" in the mempool may cause the error you described.
- 0
- 2020-04-20
- Groxan
-
感谢您及时的回复.内存池中的事务是我所指的成功事务,但是现在无效,因为分支已经过时,如果要阻止将来的事务,它将完成阻止该帐户的操作,因此应该在Tezos节点中成为严重错误,所以我不认为这应该是错误的原因.Thanks for the quick response. The transaction in the mempool is the successfull transaction that I was referring to, however it is now invalid because the branch is outdated, if that were to block future transactions it would complete block the account and should be rendered a critical bug in the Tezos node, so I don't think that it should be the cause of the error.
- 0
- 2020-04-20
- Felix Laufenberg
-
不幸的是,由于我从HSM检索签名并且无法访问私钥,因此我将无法使用Netezos测试签名.Unfortunately I won't be able to test signing with Netezos since I retrieve the signature from an HSM and can not get access to the private key.
- 0
- 2020-04-21
- Felix Laufenberg
我正在用C#为Tezos编写完整的自定义钱包软件,并获得了以下原始交易:
未签名的十六进制: 008f1d96e2783258ff663f03dacfe946c026a5d194c73d1987b3da73fadea7d46b01549a0cde570a49b9200680341a6c78e87635480f940adc85a001f44eac02010238244743822921db1661fc7306c3044faac1e373906fdb5582d9454352b3b31c6c01549a0cde570a49b9200680341a6c78e87635480ff00bdd85a0018452ac02e0a712000153957451d3cc83a71e26b65ea2391a1b16713d2d00
哈希图片: 03008f1d96e2783258ff663f03dacfe946c026a5d194c73d1987b3da73fadea7d46b01549a0cde570a49b9200680341a6c78e87635480f940adc85a001f44eac02010238244743822921db1661fc7306c3044faac1e373906fdb5582d9454352b3b31c6c01549a0cde570a49b9200680341a6c78e87635480ff00bdd85a0018452ac02e0a712000153957451d3cc83a71e26b65ea2391a1b16713d2d00
哈希: 8541434de6c77aaa3e6a4d4e341717a5c96b14e990183fd33e8157ef53f38579
签名: 008f1d96e2783258ff663f03dacfe946c026a5d194c73d1987b3da73fadea7d46b01549a0cde570a49b9200680341a6c78e87635480f940adc85a001f44eac02010238244743822921db1661fc7306c3044faac1e373906fdb5582d9454352b3b31c6c01549a0cde570a49b9200680341a6c78e87635480ff00bdd85a0018452ac02e0a712000153957451d3cc83a71e26b65ea2391a1b16713d2d0049ff4a47599e0c65447182eca4c900893a74de3ca24c26708fc9d4bf79891ca384b0d5f98618bc3acec4f0c6bffd002de6fd839a418f47e83404aed285fc0235
当我尝试向节点rpc注入原始签名的事务(" Signed")时,得到响应:
[
{
" kind":"临时",
"id":"失败",
"msg":"应用操作时发生错误oozXCEKTUFcw8PHcrskvuWphiH1kNz12eohX1mp8AKinJU9fPYS:\nrefused(错误:\n操作签名无效\n)"
}
]
我可以对照第三方工具验证交易的签名(secp256k1)并验证(纯粹是正确地对"哈希"值进行了签名).我使用节点rpc'Forge'端点通过以下JSON验证了正确的序列化:
{"branch":" BKiXcfN1ZTXnNNbTWSRArSWzVFc6om7radWq5mTqGX6rY4P2Uhe",
"内容":[{
"种类":"揭露",
"fee":" 1300",
"gas_limit":" 10100",
" storage_limit":" 300",
"public_key":" sppk7ZjMvKgUwnjYZKoQEYaNhorr1NJxmqgHLjExsP3uq98XKChFius",
"计数器":" 2622172",
"源":"tz2G2Zy3sgYCuh1EQqrx9Q62CcpSkgcLPPDt"},{
"种类":"交易",
"fee":" 1520",
"gas_limit":" 10500",
" storage_limit":" 300",
" amount":" 300000",
"计数器":" 2622173",
"目标":"tz2FwBnXhuXvPAUcr1aF3uX84Z6JELxrdYxD",
"源":"tz2G2Zy3sgYCuh1EQqrx9Q62CcpSkgcLPPDt"}]
}
并且还能够使用python代码验证UnsignedRaw=>哈希:
来自pyblake2的这似乎是一条错误的错误消息.谁能帮我弄清楚我的交易出了什么问题?
P.s.在同一软件第二次运行我能够产生一个完全有效的事务: 007fc1ecd6a56046aaaeab78bbfa1c889eb8f502b66c720bf1ac3b40ee9ecf6d6b01549a0cde570a49b9200680341a6c78e87635480f940adc85a001f44eac02010238244743822921db1661fc7306c3044faac1e373906fdb5582d9454352b3b31c6c01549a0cde570a49b9200680341a6c78e87635480ff00bdd85a0018452ac02c09a0c000153957451d3cc83a71e26b65ea2391a1b16713d2d00231176ec0cf55e3f04d5de633c33b38a6370ad2c37fd31c4c45e12ec9f1466753c8137f5dee8105bd5cc3d4ce780f51ec01d5adb21893e75eef4b960189818a3 的
第三轮再次被视为无效.