Let's say that I have a smart contract A with a public function f that can be called by anyone and this public function will return a number. In the smart contract there is also a private function p which returns a list of numbers.

Now if f calls p during its execution and then uses p's return value to generate its return value would every node in the network know the return value of p?

My main goal is to keep the return values of p not accessible by every node in the network


Solidity functions - private visibility

The purpose of private functions is not to keep data private, it is to keep external accounts or contract addresses from executing that function. You should assume all data is public.

In this particular case, an account calling the function f would not see the return value of p explicitly, but as each node in the network will be executing the function, it is effectively accessible.


1)"return value" doesn't mean "store" on blockchain. So if P is pure function - then it's result depends on arguments and state and clients can call it with their params locally so params wil not be exposed to whole ethereum net.

2)Also you can split your process into two pices:

  1. compute some data with pure P from private params locally (or download some other bytecode from eth wasm for example and execute it locally)
  2. encrypt result with asymmetric encryption and store it on blockchain
  • Your statement is incorrect, every node that executes the transaction will have access to the intermediate values from P. – Ismael Jan 21 '18 at 7:51
  • "every node that executes the transaction will have blah-blah-blah" True. That's why offer to split calculation process in two steps with off-chain calling dispatch and use prure function to allow local-node execute it out of transaction. – alatushkin Jan 21 '18 at 15:07

Your Answer

