Christopher
Christopher

Reputation: 142

Solidity the visibility of mapping 'Value'

After reading from some docs and online tutorials, my understanding is that the key of the Mapping is not stored in the storage. How about the value? If I would like a store a value that should be confidential or private, as long as no one has the key, the value will be safe? Or I still need to encrypt the value?

Upvotes: 0

Views: 341

Answers (1)

Petr Hejda
Petr Hejda

Reputation: 43561

You can't store it completely privately on a public chain.

There are few ways to make it accessible in a more complicated way, such as

  • not publishing the source code
  • "obfuscating" the bytecode by overly jumping between functions, using bitwise operations, etc., making it purposely hard to understand by a human
  • sending the transaction storing the "private" data as an internal transaction to your target contract, so that most blockchain explorers don't show it as related to your target contract (see this answer and its attached links for better explanation)

But the key (or storage slot) and value are always going to be determinable, because the transaction that stored the data is public, as well as the contract bytecode is public.

Upvotes: 2

Related Questions