Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WalletConnect Encrypt/Decrypt/InvokeScript #4

Closed
melanke opened this issue Jun 9, 2021 · 3 comments
Closed

WalletConnect Encrypt/Decrypt/InvokeScript #4

melanke opened this issue Jun 9, 2021 · 3 comments
Assignees

Comments

@melanke
Copy link
Contributor

melanke commented Jun 9, 2021

  • the dapp's WC library needs to have a utility method to encrypt
    • needs to accept an address list, turn it into a shared key and encrypt a message
    • using joe's idea of turning it into a shared key:

There’s no function in neon-js to encrypt/decrypt arbitrary messages, but I recommend we use the implementation from the now-defunct nOS protocol:
https://github.com/Splyse/nos-client/blob/develop/src/renderer/browser/util/decrypt.js
https://github.com/Splyse/nos-client/blob/develop/src/renderer/browser/util/encrypt.js
with one exception - we should make the change I suggested to the nOS devs in order to allow the sender to decrypt the messages that they sent: nos/client#1147

  • use the encrypt method that Tyler sent:

https://github.com/Moonlight-io/asteroid-sdk-js/blob/master/src/helpers/encryption.ts#L50

  • the wallet needs to do the invokescript method aswell
  • the wallet needs to do a decrypt method to undo the encrypt that was done via dapp
@amlwwalker
Copy link

hey @melanke
be great to wake this up again.
The way I envisage using this is to encrypt a secret with the public key through WC. Then I can send that encrypted key to the rightful owner and use the secret to encrypt a file or data or whatever.
That way I can manage the encryption of larger amounts of data symmetrically, but share the encrypted secret assymetrically.
Will follow the progress of this. Hopefully its back on the table soon...

@melanke
Copy link
Contributor Author

melanke commented May 10, 2023

I was thinking about something like this:

const userPublicKey = 'abc123'
const friendPublicKey = '321cba'
const publicKeysThatCanDecrypt = [userPublicKey , friendPublicKey]

const encryptedResp = await wcSdk.encrypt("my secret message", publicKeysThatCanDecrypt)
console.log(encryptedResp) // ["message encrypted for user's key", "message encrypted for friend's key"]

const decryptedResp = await wcSdk.decrypt(encryptedResp[0])
console.log(decryptedResp) // "my secret message"

const decryptedResp = await wcSdk.decryptFromArray(encryptedResp) // will try to decrypt all messages, might take longer
console.log(decryptedResp) // { message: "my secret message", keyIndex: 0 }

@melanke
Copy link
Contributor Author

melanke commented Apr 2, 2024

Done

@melanke melanke closed this as completed Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants