starknet_os: add Rust mirror of the privacy proof-fact fold - #15058
starknet_os: add Rust mirror of the privacy proof-fact fold#15058einat-starkware wants to merge 1 commit into
Conversation
Adds a Rust implementation of the recursive proof tree digest chain the proving side builds over privacy-transaction leaf proofs: the leaf output digest blake2s(encode_felt252s_to_u32s(proof_facts[2..])), the pairwise fold over raw u32 words with the odd-entry carry rule, the single-entry self-fold, and the circuit verifier's output digest. Pinned against golden values from real proven trees on the proving side (the leaf H1 golden and the four_leaves root fixture). This is the reference the upcoming Cairo0 OS fold is tested bit-for-bit against. The circuit hash constants are the canonical_small registry values, to be replaced with the production registry's before production wiring. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmPJM3Wph4QLmFmhcxVsh4
PR SummaryMedium Risk Overview
Unit tests lock leaf and four-leaf fold results to proving-side goldens ( Reviewed by Cursor Bugbot for commit 9b63da8. Bugbot is set up for automated code reviews on this repo. Configure here. |
Part 1 of 2 of the privacy proof-fact fold stack (OS side of "proving that privacy proofs were verified").
Adds
starknet_os::proof_fact_fold, a Rust implementation of the digest chain the proving side builds over privacy-transaction leaf proofs (stwo_run_and_prove_recursive_tree+ the multiverifier circuit):blake2s(encode_felt252s_to_u32s(proof_facts[2..]))— drops the proof version and variant markers, keeping[program_hash, ...virtual OS output], exactly the preimage the leaf simple bootloader hashes to its output (which the leaf cairo-verifier circuit emits verbatim as its public output).circuit_hash ‖ outputper child, no felt encoding at fold levels); a trailing unpaired entry is carried unchanged, keeping its own circuit hash; a single-entry block self-folds.blake2s(circuit_hash ‖ output_digest)of the root entry — what the Cairo circuit verifier'sget_verification_outputreturns.Tests pin the implementation against golden values from real proven trees on the proving side: the leaf
H1golden and thefour_leavesfixture's root output digest.The circuit hash constants are the
canonical_smalltest-registry values (documented as such); they must be replaced with the production registry's values before production wiring.Next in the stack: the Cairo0 implementation of the same fold, pinned bit-for-bit against this module.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XmPJM3Wph4QLmFmhcxVsh4
Generated by Claude Code