[Ethereum] What are effective techniques to encrypt/decrypt data stored in a smart contract

contract-designencryptionprivacySecurityweb3js

Rather than sending and storing plain text in a smart contract, the use case objective is to encrypt first and then subsequently access the data and decrypt at the point of use.

What is the most effective and efficient way of achieving this data security, ideally using web3js?

Best Answer

Since all transactions and data on the blockchain are public, you need to encrypt the data outside of Ethereum and insert the already encrypted data. Similarly you need to pull the encrypted data and decrypt it locally. I'm sure there are a lot of crypto libraries for javascript that will allow you to do this, web3 I doubt contains such functionality as it's out of scope for it.

Related Topic