【发布时间】:2022-08-23 05:28:12
【问题描述】:
所以我目前正在尝试按照 Phantom 中的步骤来加密/解密来自我的 dapp 中的深层链接的连接响应 these docs found in Phantom
在来自深度链接的响应中,在参数中我得到数据和随机数,然后我使用 bs58 解码,如下所示:
const decodedDataUnit8 = bs58.decode(data);
const decodedNonceUnit8 = bs58.decode(nonce);
我还可以创建一个 sharedSecretKey 如下:
const sharedSecretDapp = nacl.box.before(
bs58.decode(params.get(\"phantom_encryption_public_key\")!),
dappKeyPair.secretKey
);
然后我尝试解密这些数据,以便我可以获得具有 public_key 和会话字符串的对象,如文档here 中所示
使用bs58提供的如下方法:
const decryptedData = nacl.box.after(decodedDataUnit8, decodedNonceUnit8, sharedSecretKey);
但我得到的只是一个看起来像钱包地址但更长的字符串。 有点像这样的东西:
riLscsuR5SXZriur5npKr164uPAWETAfpqBvdtB7riLscsuR5SXZriur5npKr164uPAWETAfpqBvdVNbttB7riLscsuR5SXZriur5npKr164uPAWETAfpqcsuR5SXZriur5npKr164uPAWETAfpqBvdVNbttB7riLscsuR5SXZriur5npKr164uPAWETAfpqBvdVNbttB7riLscsKr164uPAWETAfpqBvdVNbttB
我不确定为什么会发生这种情况,以及为什么我没有得到可以解析为对象或类似内容的东西。
我们在这里都是一群玻璃咀嚼者,这与现场有关,但经过 4 天的努力,我真的走到了尽头。
非常感谢所有和任何帮助!
标签: solana solana-web3js phantom-wallet