A question about public and private functions, and how they relate to private and public state. Can private functions read/write public state (maybe read only historical public state, or update state only via CRDT-like operations)? And can public functions push notes into private state, or read them if the owner “reveals” them somehow?
The VM circuit is significantly more compute intensive and RAM intensive. (All of those extra columns versus a ‘normal’ circuit mean lots more polynomials to compute and hold in memory). So it wouldn’t be practical to execute such a circuit on user hardware. It needs a beast computer (which only a sequencer would have). It’s also harder to design and build!
Private functions are special in that only they may read private state. That’s their main distinguishing feature.
The Noir compiler (eventually) should disallow (or at least warn the dev) a public function from reading private state (because by definition a private state must not be read by the public).
Private functions can:
- read/write private state
- read constant public state (not yet supported in our struct definitions, but it’s a simple update)
- read historic public state (against some historic root) (not yet supported in our struct definitions, but it’s a simple update)
- The current plan is for private functions to call a public function if they want to update/write public state.
- It might be worth exploring whether CRDT operations would be possible in some circumstances.
Public functions can:
- read/write public state
- push new notes (private state) to the private data tree
- we weren’t planning on easily facilitating private state reads from a public function (because it’s a bit of a privacy footgun for inexperienced devs…).
- a private function can always pass private values to a public function, though, which is effectively a ‘read’
- perform additively homomorphic computations on private state (if it’s been encrypted in the right way), without learning the private values - we do this in aztec connect
Hi Mike, is this still same design as blog Aztec: the Hybrid zkRollup?
Yep. The blog is a high-level simplification of the spec, some of which is being clarified in this thread