帖子
分享您的知识。
How to convert a public key to a Sui address?
I'm trying to convert a public key to a Sui address, but I'm unsure how to do this with Sui Move. I found some information about using BLAKE2b hashing function, but I'm not clear on why Sui Move doesn't provide a straightforward function for such an important task. How can I go about this conversion?
- Move CLI
答案
3要将公钥转换为 Sui 地址,您需要使用 Blake2B 哈希函数对与公钥字节串联的签名方案标志字节进行哈希处理. Sui 地址将是 32 字节的哈希值. 你可以在 sui lib 中找到 Blake2B 哈希函数. 如果你正在寻找 Rust 示例,可以在 这里 查看.
尽管Sui Move不直接提供此功能,但如上所述使用Blake2B哈希函数应该可以获得所需的Sui地址. 将标志字节与您的公钥字节串联起来是此过程中的关键步骤.
要将公钥转换为 Sui 地址,只需使用 blake2B-256 对单字节签名方案标志进行哈希处理,然后是原始公钥字节即可. 这会给你一个 32 字节的 Sui 地址. 该过程确保每个地址都对密钥类型及其数据进行编码. 这就是 Sui 区分 Ed25519、secp256K1 或 Secp256R1 等密钥的方式.
在 Rust 中,你通常会使用 Sui SDK 的加密工具,其中已经包含了这个逻辑. 如果你是从头开始构建,可以使用 blake2 箱子对旗帜 + 公钥组合进行哈希处理.
你知道答案吗?
请登录并分享。
Move is an executable bytecode language used to implement custom transactions and smart contracts.

- ... SUITucker+165
- ... SUIDpodium.js+156
- ... SUIGifted.eth+148
- ... SUIacher+107
- ... SUIcasey+88
- ... SUIMiniBob+65
- ... SUItheking+55