Is there any way to encrypt/decrypt data using web3js library(or any other standard tool), so that only user having access to public/private key can store and read data onto ethereum blockchain.

Scenario could be: A user stores sensitive information in encrypted file on IPFS and then using smart contract store encrypted hash of IPFS file onto blockchain, in future when he can access encrypted hash of IPFS file from blockchain using smart contract and view information.

In this scenario user has not remembered(stored) any thing except Ethereum private key.

  • To be sure, your question is that you want to block people not having a (certain?) key pair from accessing the blockchain? (Everyone can read the blockchain, they do not need a key for this). – JBrouwer Mar 30 '18 at 12:13
  • yes, user will store encrypted secret onto public blockchain, so that only he can read it. – kherwa Mar 30 '18 at 12:34
  • Yes anyone can read, but that information will be encrypted. so only user can decrypt this information using his private key. – kherwa Mar 30 '18 at 13:09
  • Yes that is possible, choose an encrypt/decrypt algorithm, encrypt a string, put it on blockchain and let the user decrypt it (off-chain) using his private key. – JBrouwer Mar 30 '18 at 13:35
  • 2
    You now can use OpenPGPjs that now support encryption using private keys from elliptic curves (like those used by Ethereum). – Ismael Mar 30 '18 at 15:32

Browse other questions tagged or ask your own question.