# What's the interaction between public and private functions and state?

**URL:** <https://forum.aztec.network/t/whats-the-interaction-between-public-and-private-functions-and-state/195>\
**Category:** Aztec\
**Created:** [April 17, 2023, 1:34pm UTC](https://forum.aztec.network/t/whats-the-interaction-between-public-and-private-functions-and-state/195 "2023-04-17T13:34:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spalladino](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.aztec.network/spalladino/32/32_2.png) [@spalladino](https://forum.aztec.network/u/spalladino)\
**Post date:** [April 17, 2023, 1:34pm UTC](https://forum.aztec.network/t/whats-the-interaction-between-public-and-private-functions-and-state/195/1 "2023-04-17T13:34:26Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Mike](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.aztec.network/mike/32/7_2.png) [@Mike](https://forum.aztec.network/u/Mike)\
**Post date:** [April 17, 2023, 2:11pm UTC](https://forum.aztec.network/t/whats-the-interaction-between-public-and-private-functions-and-state/195/2 "2023-04-17T14:11:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![spartucus](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.aztec.network/spartucus/32/126_2.png) [@spartucus](https://forum.aztec.network/u/spartucus)\
**Post date:** [May 9, 2023, 6:49am UTC](https://forum.aztec.network/t/whats-the-interaction-between-public-and-private-functions-and-state/195/3 "2023-05-09T06:49:39Z")

</div>

Hi Mike, is this still same design as blog [Aztec: the Hybrid zkRollup](https://medium.com/aztec-protocol/aztec-the-hybrid-zkrollup-a90a197bf22e)?

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/aztec/original/1X/fa45b2a876f25c25132d198b4ec0238227e5eb6e.jpeg)

---

<div class="post-metadata">

**Author:** ![Mike](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.aztec.network/mike/32/7_2.png) [@Mike](https://forum.aztec.network/u/Mike)\
**Post date:** [May 10, 2023, 11:25am UTC](https://forum.aztec.network/t/whats-the-interaction-between-public-and-private-functions-and-state/195/4 "2023-05-10T11:25:14Z")

</div>

Yep. The blog is a high-level simplification of the spec, some of which is being clarified in this thread 🙂
