3

What is the best way to encrypt and decrypt a variable in Solidity so only the msg.sender and contract can see that variable?

ethereal
  • 1,805
  • 2
  • 14
  • 25

1 Answers1

3

Practical answer: You can't. If the contract can see it when it executes, everyone who has the blockchain can see it.

Theoretical answer that won't help you: Homomorphic encryption. See Can smart contracts compute on encrypted data?

Edmund Edgar
  • 16,897
  • 1
  • 29
  • 58