protocol.proof#

STARK proof data structures and serialization.

Attributes#

Classes#

MerkleProof

Merkle authentication path: leaf values and sibling hashes.

ProofTree

Merkle tree commitment with query proofs.

FriProof

FRI opening proof: folding trees and final polynomial.

STARKProof

Complete STARK proof for a single AIR.

Functions#

proof_to_json(→ dict[str, Any])

Convert STARK proof to JSON-serializable dictionary.

load_proof_from_json(→ tuple[STARKProof, dict[str, Any]])

Load STARK proof from JSON file.

from_vadcop_final_bytes(→ tuple[STARKProof, numpy.ndarray])

Parse a VadcopFinal proof binary with embedded publics header.

from_bytes_full(→ STARKProof)

Deserialize binary proof to STARKProof structure.

to_bytes_partial(→ tuple[bytes, bytes])

Serialize proof header and footer (without query proofs) for partial comparison.

to_bytes_full(→ bytes)

Serialize complete STARK proof to binary format (requires query proofs).

to_bytes_full_from_dict(→ bytes)

Serialize proof dictionary to binary format matching C++ proof2pointer().

validate_proof_structure(→ list[str])

Validate that proof structure matches STARK configuration.

Module Contents#

protocol.proof.Hash[source]#
class protocol.proof.MerkleProof[source]#

Merkle authentication path: leaf values and sibling hashes.

v: list[list[int]] = [][source]#
mp: list[list[int]] = [][source]#
class protocol.proof.ProofTree[source]#

Merkle tree commitment with query proofs.

root: Hash = [][source]#
last_levels: list[int] = [][source]#
pol_queries: list[list[MerkleProof]] = [][source]#
class protocol.proof.FriProof[source]#

FRI opening proof: folding trees and final polynomial.

trees: ProofTree[source]#
trees_fri: list[ProofTree] = [][source]#
pol: list[list[int]] = [][source]#
class protocol.proof.STARKProof[source]#

Complete STARK proof for a single AIR.

Contains all components needed to verify that a prover knows a valid execution trace satisfying the AIR constraints.

Attributes:
roots: Merkle roots for each stage commitment (stages 1 to n_stages+1).

roots[0] is stage 1 (witness), roots[-1] is quotient polynomial.

last_levels: Pre-verified Merkle nodes for last_level_verification optimization.

Indexed by tree: [stage_0, …, stage_n, const_tree].

evals: Polynomial evaluations at challenge point xi. Each entry is

[c0, c1, c2] coefficients of an FF3 extension field element.

airgroup_values: Values shared across all AIRs in an airgroup (e.g., gsum_result).

Used for cross-AIR boundary constraints. Each is [c0, c1, c2].

air_values: Values specific to this individual AIR instance.

Stage 1 values are single FF, stage 2+ are FF3 [c0, c1, c2].

custom_commits: Names of custom commitment schemes used (if any). fri: FRI protocol data - folding trees, query proofs, and final polynomial. nonce: Grinding nonce satisfying the grinding constraint.

roots: list[Hash] = [][source]#
last_levels: list[list[int]] = [][source]#
evals: list[list[int]] = [][source]#
airgroup_values: list[list[int]] = [][source]#
air_values: list[list[int]] = [][source]#
custom_commits: list[str] = [][source]#
fri: FriProof[source]#
nonce: int = 0[source]#
protocol.proof.proof_to_json(proof: STARKProof, n_stages: int, n_field_elements: int = HASH_SIZE) dict[str, Any][source]#

Convert STARK proof to JSON-serializable dictionary.

protocol.proof.load_proof_from_json(path: str) tuple[STARKProof, dict[str, Any]][source]#

Load STARK proof from JSON file.

protocol.proof.from_vadcop_final_bytes(data: bytes, stark_info: Any) tuple[STARKProof, numpy.ndarray][source]#

Parse a VadcopFinal proof binary with embedded publics header.

VadcopFinal proofs prepend [n_publics: u64] [publics: n_publics * u64] before the standard proof body (ref: recursion.rs lines 622-627).

Returns:

Tuple of (STARKProof, publics_array) where publics_array is numpy uint64.

protocol.proof.from_bytes_full(data: bytes, stark_info: Any) STARKProof[source]#

Deserialize binary proof to STARKProof structure.

Parses the binary format produced by C++ proof2pointer() into a structured STARKProof dataclass with typed fields for all proof components.

protocol.proof.to_bytes_partial(proof_dict: dict[str, Any], stark_info: Any) tuple[bytes, bytes][source]#

Serialize proof header and footer (without query proofs) for partial comparison.

protocol.proof.to_bytes_full(proof: STARKProof, stark_info: Any) bytes[source]#

Serialize complete STARK proof to binary format (requires query proofs).

protocol.proof.to_bytes_full_from_dict(proof_dict: dict[str, Any], stark_info: Any) bytes[source]#

Serialize proof dictionary to binary format matching C++ proof2pointer().

protocol.proof.validate_proof_structure(proof: STARKProof, stark_info: Any) list[str][source]#

Validate that proof structure matches STARK configuration.