0

Let's say I have something like this:

bytes32 person;

function registerPerson(address _person) public {
   bytes32 x;
   x = sha256(abi.encodePacked(_person));
   person = x;
}

For privacy reasons, I want to store that "_person" element as a hash, so that people don't know what address it is. I know that the bytes32 value can be viewed, but now I'm wondering if there is any way people can see the raw "_person" input?

In my opinion, the answer is a no, but using Remix, it shows the inputs made to a function, and now I'm wondering if that's just the compiler's functionality for debugging or if raw input is actually visible somewhere.

Thanks a lot.

1 Answer 1

2

Yes, the _person value will be visible through the transaction data that get created to call that function. It would be completely public to anyone and everyone who saw your transaction on the network.

You would even be able to use a service like Etherscan to view the transaction input data, which would contain a hex encoded version of your input, which can easily be turned back into the raw data.

If you want to hash the address data to keep it "secret", you should do so before it gets sent to the contract.

For example, look at this transaction to a contract which allows you to store some text in a smart contract:

https://etherscan.io/tx/0xecd6399f05410c8c3d64dcacccce647c55df135f24a1632fb9bc3665e02dbf5a

If you look a the Input Data and select "View Input As: UTF-8", you will be able to read the message that got saved:

honey buns & pumpin spiced latte 3.14.2016

This is true for all input data.

2
  • Thank you. Looking back, of course the input has to be visible since the nodes have to run the code in their EVM. Commented Oct 16, 2018 at 8:53
  • That is true today. I am not very versed, but I think things like ZK-SNARKS and other Zero Knowledge proofs may allow for nodes to verify the state of the contracts without knowing the input data... But as I said, not to familiar here, and it is definitely not ready in Ethereum yet. Commented Oct 16, 2018 at 8:58

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.