If my smart contract on the mainnet receives personal data, such as street addresses or email addresses, is there any way I can store that data, but hide from anybody other than the contract itself? (What I mean is hidden even from an industrious person examining the data in a block explorer)

I am under the impression its not possible, even if encrypted, because the the decryption key would have to be stored somewhere and that can't be hidden either.

2 Answers 2


The answer is "no".

If the data came into the contract unencrypted the transaction parameters would be recorded on the blockchain. If it came in encrypted, the smart contract would have to decrypt it first, because Ethereum virtual machine execution must be verifiable by untrusted Ethereum nodes that have no secrets so anyone could simulate the contract execution and reveal the data.

There is technology called "homomorphic encryption" that allows arbitrary calculation to be done on encrypted data (potentially even by an encrypted smart contract) without access to the key. But it is computationally expensive and can only do small amounts of encrypted computation. And the security setup and usage is unwieldy. There is research into doing this in the Ethereum blockchain ( https://eprint.iacr.org/2021/133.pdf ) but don't expect it any time soon.

  • That's what I've been hearing. Assuming the sensitive data comes from an Oracle, I'm wondering whether its possible for the Oracle to encrypt the data with the public key of msg.sender and then write it back to the chain. Then at least maybe the account owner can decrypt the data outside the blockchain with his private key. Only tricky bit is how the smart contract can get hold of public key of msg.sender. From preliminary research that seems like it might be impossible too, unless somehow, one of the parameters to the original function is the public key.
    – GGizmos
    Jul 5, 2021 at 16:25

You can store the encrypted data onchain and keep the key offchain.

  • I guess, but seems like that would make it inaccessible to the smart contract itself.
    – GGizmos
    Jul 5, 2021 at 3:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.