solana-labs / solana-web3.js

Solana JavaScript SDK
https://solana-labs.github.io/solana-web3.js
MIT License
2.09k stars 841 forks source link

Create data encryption/decryption standard plus supporting APIs for wallets to implement #1367

Closed ozyman42 closed 1 year ago

ozyman42 commented 1 year ago

Motivation

Many potential applications might prefer to encrypt end user data via a public key the user controls rather than encrypting via a user's password (i.e. lastpass), as passwords are a poor UX compared to a web 3 wallet. Metamask currently is the only web 3 wallet I'm aware of which offers the ability to decrypt via private key. Ideally Solana wallets should support this, and ideally all the wallets would use the same algorithm for obtaining a public encryption key and the same asymmetric encryption algo too. In the linked EIP you see a proposal for wallets to offer an RPC for encryption via secp256k1 + ECIES.

Example use case

Let's say I'm making a decentralized health information exchange. Each medical record of mine is stored on-chain (if it was not stored on chain it would not be decentralized). I sign in via my wallet. Then, either after some visit to a doctor's office or when I'm ready to publish my wearable device's biometric data, I get a request from my web3 wallet to encrypt the data with a public key, then another request to store said data in a Solana account (or Arweave or Filecoin or Shadow Drive etc etc). When I view a web dapp later, I should be able to view all my data, so the wallet sends me a request to decrypt my data using my private key. In the future I may want to give access of this encrypted data to another user, which is why my account should somehow be able to generate unique encryption/decryption keypairs for different datasets. Perhaps this simply means I reencrypt the decrypted data with the recipient's public key. An example is let's say I sell my wearable device data and DNA sequencing data to an AI health tech company. In that case I should probably be uploading some copy of that data encrypted with a keypair unique to my relationship with that company.

Details

Relevant discussion in Ethereum: https://ethereum-magicians.org/t/eip-5630-encryption-and-decryption/10761/128 Metamask SDK:

Open related issue in Backpack https://github.com/coral-xyz/backpack/issues/4241 Open related issue in Solana Mobile Seed Vault https://github.com/solana-mobile/seed-vault-sdk/issues/144

jordaaash commented 1 year ago

Thanks! There's some work in progress to enable this. This repo isn't where that work is/will happen though, so could I ask you to close this issue and open it @ solana-labs/wallet-standard instead? I can follow up there.

ozyman42 commented 1 year ago

Closing in favor of https://github.com/solana-labs/wallet-standard/issues/25 as suggested by @jordansexton

github-actions[bot] commented 1 year ago

Because there has been no activity on this issue for 7 days since it was closed, it has been automatically locked. Please open a new issue if it requires a follow up.