如何将ed25519字节转换为Tezos公钥
-
-
这回答了你的问题了吗?[如何对Tezos公钥进行哈希处理](https://tezos.stackexchange.com/questions/2016/how-to-hash-a-tezos-public-key)Does this answer your question? [How to hash a Tezos public key](https://tezos.stackexchange.com/questions/2016/how-to-hash-a-tezos-public-key)
- 0
- 2020-01-17
- utdrmac
-
并不是的.我也是链接问题的作者;).链接的是关于创建公钥的哈希,而这是关于创建公钥本身的-这是之前的一步.Not really. I am an author of the linked question as well ;) . The linked one is about creating a hash of a public key while this one is about creating a public key itself - it's a step before that.
- 0
- 2020-01-17
- K SS
-
1 个回答
- 投票数
-
- 2020-01-17
您可以在文件底部找到这些字节
https://gitlab.com/tezos/tezos/blob/master/src/lib_crypto/base58.ml
您的情况是" \ 013 \ 015 \ 037 \ 217"
You can find those bytes at the bottom of this file
https://gitlab.com/tezos/tezos/blob/master/src/lib_crypto/base58.ml
In your case, "\013\015\037\217"
-
我试过了我的base58编码了我的36个字节,并得到49个base58字符.然后除了前缀,我还附加了4个随机字节.我从`edpk`开始有54个`base58`字符.这意味着前缀显然是正确的-但是我应该从哪里获得剩余的4个字节来替换随机的呢?I tried that. I `base58` encoded my 36 bytes and got 49 `base58` characters. Then apart from the prefix, I also appended 4 random bytes. I got 54 `base58` characters, starting from `edpk`. This means that prefix is clearly correct - but where do I get remaining 4 bytes to replace my random ones from?
- 0
- 2020-01-17
- K SS
-
您必须使用base58Check,它将从二进制数据的哈希中追加一些字节作为校验和.You have to use base58Check which appends some bytes from a hash of the binary data as a checksum.
- 0
- 2020-01-17
- Arthur B
-
真好这给了我一个以`1edpk`开头的55字符串.我删除了开头的" 1"(我应该这样做吗?),并且得到了看起来像有效的Tezos公钥的东西.但是,在尝试使用[sotez](https://www.npmjs.com/package/sotez)为此公钥创建哈希之后,出现了"错误:无效的校验和".这是否表明ed25519字节是错误的?Tezos是否使用一些自定义的"ed25519"变体?我用来生成ed25519字节的实现是[this](https://www.npmjs.com/package/ed25519).Nice. This gives me a 55 character string starting with `1edpk` . I removed leading `1` (am I supposed to do that?) and got something that looks like a valid Tezos public key. However, after attempting to create a hash for this public key using [sotez](https://www.npmjs.com/package/sotez) I got `Error: Invalid checksum` . Does this suggest that `ed25519` bytes are wrong? Does Tezos use some custom `ed25519` variant? Implementation that I'm using to generate `ed25519` bytes is [this one](https://www.npmjs.com/package/ed25519) .
- 0
- 2020-01-17
- K SS
-
我不确定该特定模块,但是Sotez使用[libsodium-wrappers](https://www.npmjs.com/package/libsodium-wrappers)来执行其ed25519加密功能.例如,您可以参考[this](https://github.com/AndrewKishino/sotez/blob/master/src/crypto.ts#L163).I'm not sure about that specific module, but Sotez uses [libsodium-wrappers](https://www.npmjs.com/package/libsodium-wrappers) to perform its ed25519 crypto functions. You can reference [this](https://github.com/AndrewKishino/sotez/blob/master/src/crypto.ts#L163) for example.
- 0
- 2020-01-18
- AKISH
-
使用libsodium生成ed25519字节给了我同样的错误.前导1似乎是base58check校验和的一部分,因此不应删除它.但是如果不删除,密钥以1edpk开头,因此毫不奇怪,我得到了Error:Invalidprefix.我不知道该如何解决O_OUsing `libsodium` to generate `ed25519` bytes gave me the same error. It seems that leading `1` is a part of `base58check` checksum so it should not be removed. But if not removed, the key starts with `1edpk` so, unsurprisingly I'm getting `Error: Invalid prefix` . I have no idea how to work that out O_O
- 0
- 2020-01-20
- K SS
我试图通过
base58
编码ed255191
公钥字节来做到这一点.考虑以下代码示例:它打印:
我得到的
base58
字符串比实际的Tezos公钥短10个字符.这以及该主题建议我在使用base58
对其进行编码之前,需要给我的base58
数据加上一些神奇的字节作为前缀.那些神奇的字节是什么?是否有关于此的文档?谢谢.
在亚瑟·B回答后编辑:
我尝试在
base58
对其进行编码之前,将前缀前缀ed25519
附加到base58
字节.但是,当真正的Tezos公钥包含54个字符时,我还是得到了49个字符.附加了4个随机字节后,我需要54个字符和一个以edpk
开头的值.显然,这意味着前缀是正确的-但是我从哪里得到剩余的4个字节?在评论中进行讨论后编辑:
由于我使用base58
而不是具有额外4个字节作为校验和的base58check
,因此缺少4个字节.使用
base58check
后,我得到了以1edpk
开头的55个字节-这样看起来像是一个有效的公共Tezos地址,前缀为1
.当前问题是:当使用键(特别是-计算其哈希)时,我删除了前导
1
并获得了54个字符.结果,我正在使用的用于散列密钥的库引发了Invalid checksum
错误.显然,1
是base58check
校验和的一部分.不过,如果未删除,则密钥将具有无效的前缀.更新的代码示例如下所示:它打印:
对此的任何进一步帮助将不胜感激,因为尽管阅读了很多有关该主题的知识,但我不知道如何使它起作用;)