# Function privacy in zkVMs

**URL:** <https://forum.anoma.net/t/function-privacy-in-zkvms/1220>\
**Category:** Cryptography Zoo\
**Created:** [February 21, 2025, 3:19pm UTC](https://forum.anoma.net/t/function-privacy-in-zkvms/1220 "2025-02-21T15:19:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kike](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.anoma.net/kike/32/745_2.png) [@kike](https://forum.anoma.net/u/kike)\
**Post date:** [February 21, 2025, 3:19pm UTC](https://forum.anoma.net/t/function-privacy-in-zkvms/1220/1 "2025-02-21T15:19:58Z")

</div>

## Context

**[ZEXE](https://eprint.iacr.org/2018/962.pdf).** Function privacy in ZEXE is achieved by producing inner proofs \pi\_b,\pi\_d to the satisfiability of the birth and death predicates \Phi\_b,\Phi\_b with a succinct pre-processing SNARK with prover and verifier keys (pk\_{b},vk\_{b}), (pk\_{d},vk\_{d}), respectively. An outer prover verifies the inner proofs \pi\_b,\pi\_d using the verifying keys vk\_b,vk\_d. Both, the proofs and the verifying keys are passed as witness to the outer prover, and the instances of the birth and death predicates are passed as instances. The outer proof system is zero-knowledge, hence the outer proof yields no information on what predicates have been verified.

This approach is expensive because the logic of the inner verifier must be arithmetized, resulting in large circuits.

**[VERIZEXE](https://eprint.iacr.org/2022/802.pdf).** Avoids running SNARK verification logic in zero-knowledge by instead using accumulation schemes. Thus, all the expensive logic of the inner verifier is postponed by pushing it into an accumulator. This already yields outer provers with lighter verification logic. The second point of improvement over ZEXE is to postpone the expensive logic of the accumulation scheme verifier to an outsider decider (i.e. the ledger)

Both approaches follow the same paradigm: verify in zero-knowledge the logic of _some_ verifier, that attests to the validity of the inner (and private) predicates.

## Function privacy in Cairo

The Cairo paper describes an alternative: loading programs for their hash, and running them.

Thus, the bootloader from [Cairo paper, Section 2.2.1](https://eprint.iacr.org/2021/1063.pdf) would take the role of the ‘outer prover’ in the (veri)ZEXE approach. But, now there is no verification of ‘inner proofs’. The logic of the bootloader is:

1. compute the hash of the predicate,
2. write the bytecode of the predicate to memory, and set the program counter to that memory segment,
3. run the predicate bytecode.

The output of the bootloader is the output of the predicate, as well as the hash of the predicate bytecode. To ensure function privacy:

- the hash must be salted with a secret value,
- and the AIR of the bootloader cannot leak any information about the executed predicate. At the very least, all predicates should give computational traces with the same length (e.g. by adding dummy instruction at the end)

## Open questions

We could investigate further. Under what circumstances can we dispense the (veri)ZEXE approach and go with the Cairo approach.

More generally, under what circumstances we can move onto a zkVM approach. For example, what about using [RISC Zero](https://dev.risczero.com/proof-system-in-detail.pdf)?

---

<div class="post-metadata">

**Author:** ![vveiln](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.anoma.net/vveiln/32/60_2.png) [@vveiln](https://forum.anoma.net/u/vveiln)\
**Post date:** [February 24, 2025, 10:19am UTC](https://forum.anoma.net/t/function-privacy-in-zkvms/1220/2 "2025-02-24T10:19:29Z")

</div>

> [@kike](#):
>
> loading programs for their hash, and running them.

So as I understand, the prover loads the program to memory and gives the hash to the verifier. Then verifier can call the verification by hash. Doesn’t it only work when both the prover and all verifiers have access to the same zkVM instance with the same state containing the program?

Or does the bootloader correspond to the outer circuit, the memory content is a part of private input, the hash is the public input, and so the prover can run the bootloader on the memory, output the hash, and let the verifier verify the resulting proof with just the hash?

---

<div class="post-metadata">

**Author:** ![kike](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.anoma.net/kike/32/745_2.png) [@kike](https://forum.anoma.net/u/kike)\
**Post date:** [February 24, 2025, 11:07am UTC](https://forum.anoma.net/t/function-privacy-in-zkvms/1220/3 "2025-02-24T11:07:23Z")

</div>

> [@vveiln](#):
>
> Or does the bootloader correspond to the outer circuit, the memory content is a part of private input, the hash is the public input, and so the prover can run the bootloader on the memory, output the hash, and let the verifier verify the resulting proof with just the hash?

Yes, the Cairo paper describes this setting. The bootloader is the logic of the ‘outer’ prover. The verifier will use the hash of the predicate and the public inputs of the predicate.
