suiet / wallet-kit

The first choice to connect all wallets on Sui blockchain
https://kit.suiet.app
MIT License
166 stars 60 forks source link

How to Decrypt message by Wallet ? #311

Open wowok-ai opened 2 months ago

wowok-ai commented 2 months ago

I have a message that encrypt by Pubkey, And how to use Wallet to decrypt this message ?

Thx a lot.

bruceeewong commented 1 month ago

Hi, there should be a wallet.verifySignedMessage function for you to decrypt msg by using the signature and public key of the connected account. check details in https://kit.suiet.app/docs/Hooks/useWallet

bruceeewong commented 1 month ago

And may I ask why do you use public key instead of private key to encrypt msg?

wowok-ai commented 1 month ago

If the message I send you is encrypted with your public key, only you can see it, ensuring the privacy of data transmission on the chain.

bruceeewong commented 1 month ago

@wowok-ai That is an interesting use case though. So it would be the capability that the DApp requests a wallet to use the account's private key to decrypt the given msg. However, I just checked the Sui wallet standard and there is not such a similar method. I suppose you could submit a feature request to sui's repo https://github.com/MystenLabs/sui/issues