Skip to content

apollo_starknet_os_program,starknet_os: add the Cairo0 proof-fact fold tree - #15093

Open
einat-starkware wants to merge 1 commit into
claude/privacy-proof-os-verify-gsxf2h-3-cairo-leaf-digestfrom
claude/privacy-proof-os-verify-gsxf2h-4-cairo-tree-fold
Open

einat-starkware wants to merge 1 commit into
claude/privacy-proof-os-verify-gsxf2h-3-cairo-leaf-digestfrom
claude/privacy-proof-os-verify-gsxf2h-4-cairo-tree-fold

Conversation

@einat-starkware

Copy link
Copy Markdown
Contributor

Fourth PR of the privacy proof-fact fold stack. Adds the fold tree above the leaf digest in Cairo0: fold_block_proof_facts folds a block's ProofFactsReference array into the block's root fold entry (leaf entries, pairwise folding with a carried trailing entry, single-transaction self-fold), and compute_fold_digest computes the digest the Cairo circuit verifier outputs for that entry. Still not reachable from the OS program — the OS output wiring lands in #15064.

Tested for bit-exact agreement with the Rust mirror across tree shapes exercising the pairing and carry rules (N = 1, 2, 3, 4, 5, 7).

Stack: leaf digest (#15090) ← rust tree fold (#15091) ← cairo leaf digest (#15092) ← this PR ← OS output wiring (#15064) ← registry pin (#15086) ← verifier task (#15088).

🤖 Generated with Claude Code

https://claude.ai/code/session_01XmPJM3Wph4QLmFmhcxVsh4


Generated by Claude Code

@cursor

cursor Bot commented Sep 2, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Introduces protocol-sensitive fold/digest logic that must match the prover; risk is mitigated by bit-exact Rust tests but integration is still pending.

Overview
Adds the Cairo0 mirror of the privacy proof-fact fold tree so the OS can reproduce the proving side’s recursive digests bit-for-bit.

proof_fact_fold.cairo now exposes fold_block_proof_facts (per-transaction ProofFactsReference → block root fold entry), compute_fold_digest (verifier public output over a 16-word entry), and the supporting leaf build / pairwise fold pipeline—including self-fold for one tx and carry of an unpaired trailing entry. Leaf entries still pair the leaf-verifier circuit hash with compute_leaf_output_digest; internal nodes use the multiverifier hash and BLAKE2s over child entries.

proof_fact_fold_test.rs runs those Cairo entry points through the VM and asserts exact agreement with the existing Rust mirror for tree sizes 1–7 (pairing/carry cases) and for compute_fold_digest. This code is not wired into the main OS program yet (per stack note).

Reviewed by Cursor Bugbot for commit 6c70dbe. Bugbot is set up for automated code reviews on this repo. Configure here.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

…d tree

Add the fold-tree layer above the leaf digest to proof_fact_fold.cairo:
fold_block_proof_facts folds a block's recorded proof-fact references
into the block's root fold entry (leaf entries, pairwise folding with a
carried trailing entry, single-transaction self-fold), and
compute_fold_digest computes the digest the Cairo circuit verifier
outputs for that entry. Tested for bit-exact agreement with the Rust
mirror across tree shapes exercising the pairing and carry rules.

The fold is not yet reachable from the OS program; the OS output wiring
lands separately.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmPJM3Wph4QLmFmhcxVsh4
@einat-starkware
einat-starkware force-pushed the claude/privacy-proof-os-verify-gsxf2h-4-cairo-tree-fold branch from 42977ca to 6c70dbe Compare September 17, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants