Move.

帖子

分享您的知识。

Bolke .
Jan 26, 2025
专家问答

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
3
分享
评论
.

答案

3
Xavier.eth.
Jan 27 2025, 05:55

要将公钥转换为 Sui 地址,您需要使用 Blake2B 哈希函数对与公钥字节串联的签名方案标志字节进行哈希处理. Sui 地址将是 32 字节的哈希值. 你可以在 sui lib 中找到 Blake2B 哈希函数. 如果你正在寻找 Rust 示例,可以在 这里 查看.

3
最佳答案
评论
.
skywinder.
Jan 26 2025, 10:09

尽管Sui Move不直接提供此功能,但如上所述使用Blake2B哈希函数应该可以获得所需的Sui地址. 将标志字节与您的公钥字节串联起来是此过程中的关键步骤.

2
评论
.
BigDev.
Aug 15 2025, 16:41

要将公钥转换为 Sui 地址,只需使用 blake2B-256 对单字节签名方案标志进行哈希处理,然后是原始公钥字节即可. 这会给你一个 32 字节的 Sui 地址. 该过程确保每个地址都对密钥类型及其数据进行编码. 这就是 Sui 区分 Ed25519、secp256K1 或 Secp256R1 等密钥的方式.

在 Rust 中,你通常会使用 Sui SDK 的加密工具,其中已经包含了这个逻辑. 如果你是从头开始构建,可以使用 blake2 箱子对旗帜 + 公钥组合进行哈希处理.

0
评论
.

你知道答案吗?

请登录并分享。

Move is an executable bytecode language used to implement custom transactions and smart contracts.

152帖子259答案
Sui.X.Peera.

赚取你的 1000 Sui 份额

获取声誉积分,并因帮助 Sui 社区成长而获得奖励。

奖励活动八月