Solana检查地址所有权



solana web3js中有任何方法可以检查地址所有权吗?

例如,在ETH中,我用PK签名一条消息,然后用消息和签名恢复地址。如果我正在检查的地址等于恢复功能的地址,我知道签署消息的人拥有特定地址。

我需要在solana中制作相同的功能。

谢谢你的帮助。

import Accounts from "web3-eth-accounts";

/**
* Check address ownership by signed message
*
* @param {string} address address to check ownership
* @param {string} message message signed by address private key
* @param {string} sign message sign
* @returns true if message was signed with this address private key, false otherwise
*/
export const checkAddressOwnership = (address, message, sign) => {
const accounts = new Accounts();
const recoveredAddress = accounts.recover(message, sign);
return address.toLowerCase() === recoveredAddress.toLowerCase();
};
/**
* Sign message with address private key
*
* @param {string} message message to sign
* @param {string} privateKey private key
* @returns signed message
*/
export const signMessage = (message, privateKey) => {
const accounts = new Accounts();
return accounts.sign(message, privateKey);
};

Solana使用Ed25519曲线进行加密,根据快速搜索,无法保证具有此公钥恢复属性。这是我能找到的最好的解释:https://crypto.stackexchange.com/questions/9936/what-signature-schemes-allow-recovering-the-public-key-from-a-signature#9939

也许密码学专家可以提供更多信息!

相关内容

  • 没有找到相关文章

最新更新