Plonky3 Documentation

repository·main·Indexed 21 days ago

https://github.com/plonky3/plonky3

A high-performance toolkit of cryptographic primitives, including polynomial commitment schemes, hashes, and fields, used to implement Polynomial IOPs (PIOPs) for STARK-based zkVMs. The ecosystem includes crates for Algebraic Intermediate Representation (p3-air), batched STARK proving (p3-batch-stark), circle-group STARKs (p3-circle), commitment frameworks (p3-commit), Discrete Fourier Transforms (p3-dft), finite field arithmetic (p3-field), FRI low-degree tests (p3-fri), lookup arguments (p3-lookup), matrix operations (p3-matrix), and Merkle-tree commitments (p3-merkle-tree).

Tokens
91.3K
Snippets
264
Records
409
Agent score
73%

What's inside Plonky3

  1. Overview of p3-batch-stark

    main
    p3-batch-stark provides batched STARK proving and verification capabilities built on top of p3-uni-stark. It allows you to prove multiple Algebraic Intermediate Representation (AIR) instances—which may have different heights—using a single commitment and a shared FRI (Fast Reed-Solomon Interactive Oracle Proof of Proximity) opening. It also supports optional cross-instance lookups.
  2. Overview of p3-merkle-tree

    main

    The p3-merkle-tree crate provides a Merkle-tree implementation of the Mmcs (Multi-Matrix Commitment Scheme) interface. It is specifically designed to commit to batches of trace and LDE (Low Degree Extension) matrices.

    Key abstractions include:

    • MerkleTree: An N-ary Merkle tree (utilizing binary bridge levels) built over the rows of multiple matrices that may have differing heights.
    • MerkleTreeMmcs: An implementation of the p3_commit::Mmcs interface, featuring verify_batch for performing opening verifications.
    • MerkleTreeHidingMmcs: A variant of the commitment scheme that provides hiding properties by salting leaves with randomness provided by the caller.
    • PrunedMerklePaths and PrunedBatchOpening: Structures used for de-duplicated multi-opening proofs to optimize data transfer.

    The implementation is generic over hash and compression functions from the p3-symmetric crate. Additionally, digests can be truncated using MerkleCap.

  3. Overview of p3-circle

    main

    p3-circle is a STARK framework built over the unit circle of a finite field. It implements the techniques described in the Circle STARKs paper by Haböck, Levit, and Papini.

    This framework is specifically designed to enable fields like Mersenne-31 (which lacks a large two-adic multiplicative subgroup) to be used as STARK fields by utilizing circle-group evaluation domains.

  4. Overview of Plonky3

    main
    Plonky3 is a toolkit providing primitives, such as polynomial commitment schemes, for implementing polynomial IOPs (PIOPs). It is primarily designed to power STARK-based zkVMs, but can also be used for PLONK-based circuits or other PIOPs. It supports various fields (Mersenne31, BabyBear, KoalaBear, Goldilocks), hash functions (Rescue, Poseidon, BLAKE3, etc.), and interpolation methods.
  5. Overview of the p3-field framework

    main

    The p3-field crate provides a modular framework for finite field arithmetic. It defines the core algebraic trait hierarchy used across the Plonky3 ecosystem and provides abstractions for generic binomial extension fields and SIMD-packed field arithmetic.

    Note that p3-field contains the traits and abstractions; concrete field implementations (such as p3-baby-bear, p3-koala-bear, p3-goldilocks, p3-mersenne-31, and p3-bn254) are located in their own dedicated crates.

  6. Overview of the p3-commit framework

    main

    The p3-commit crate provides a framework for cryptographic commitment schemes, including non-hiding variants. It serves as the abstraction layer that connects proof systems to their specific commitment backends.

    Key abstractions include:

    • Pcs / MultilinearPcs: Interfaces for polynomial commitment schemes used by STARK provers and verifiers.
    • Mmcs (Mixed Matrix Commitment Scheme): A vector-commitment abstraction designed to handle batches of matrices with differing heights.
    • PolynomialSpace and TwoAdicMultiplicativeCoset: Abstractions for evaluation domains.
    • periodic: Helpers for periodic-column evaluation.
    • testing: Mock implementations available for downstream testing.

    Common implementations of these interfaces can be found in the p3-merkle-tree, p3-fri, p3-circle, and p3-whir crates.

  7. Overview of p3-fri

    main

    The p3-fri package provides an implementation of the FRI (Fast Reed-Solomon Interactive Oracle Proof of Proximity) low-degree test (LDT) and a FRI-based polynomial commitment scheme (PCS). It is a core component of the Plonky3 ecosystem used for verifying polynomial properties efficiently.

    Key components include:

    • TwoAdicFriPcs: An instantiation of the p3_commit::Pcs trait using two-adic multiplicative cosets.
    • HidingFriPcs: A zero-knowledge variant of the PCS that achieves hiding by padding traces with randomness provided by the caller.
    • FriParameters: Configuration for the protocol, including blowup factor, query count, proof-of-work (grinding), and arity.
    • prover / verifier: The underlying FRI folding protocol which allows for configurable per-round arities.
  8. Discrete Fourier Transform (DFT) implementations in p3-dft

    main

    The p3-dft package provides Discrete Fourier Transform implementations over finite fields. These implementations are primarily used for low-degree extensions (LDEs) of trace matrices.

    Key components include:

    • TwoAdicSubgroupDft: The core trait providing (inverse) DFTs and coset LDEs over two-adic subgroups. It supports batched column-wise operations over matrices.
    • Radix-2 Variants: Optimized implementations with different trade-offs for parallelism and cache efficiency:
      • Radix2Dit
      • Radix2DitParallel
      • Radix2Bowers
      • Radix2DFTSmallBatch
    • NaiveDft: A quadratic-time reference implementation intended for testing and verification purposes.
  9. Understand the p3-lookup protocol and components

    main

    p3-lookup implements the LogUp protocol, which provides lookup arguments for STARKs. It supports both intra-AIR (local) and cross-AIR (global) lookups.

    Key components include:

    • LogUpGadget / LookupProtocol: Responsible for generating permutation columns and enforcing constraints.
    • LookupBus and PermutationCheckBus: Domain-separated buses used for managing cross-AIR interactions.
    • InteractionBuilder and InteractionSymbolicBuilder: Integration tools for AIR-builders that allow you to declare 'send' and 'receive' operations.
    • debug_util: Provides out-of-circuit multiset balance checks, which are useful for debugging lookup implementations.
  10. Use p3-challenger for Fiat–Shamir transcripts

    main

    The p3-challenger crate provides a framework for generating random challenges from an IOP (Interactive Oracle Proof) transcript using the Fiat–Shamir heuristic.

    Core Concepts

    • Transcript Consistency: To ensure valid proofs, the Prover and the Verifier must observe and sample from the transcript in the exact same order.
    • Binding: Every proof object must be bound to the transcript before any challenge it influences is sampled.

    Key Components

    • Observe/Sample Traits: The CanObserve, CanSample, CanSampleBits, and FieldChallenger traits define how the transcript is interacted with.
    • Challenger Types:
      • DuplexChallenger: A sponge-based challenger built over a cryptographic permutation.
      • HashChallenger: A challenger built from a generic hash function.
      • MultiField32Challenger: Bridges fields of different sizes.
      • SerializingChallenger32/64: Bridges fields of different sizes.
      • GrindingChallenger: Used for proof-of-work witness generation and verification.
  11. Core components of p3-uni-stark

    main

    The p3-uni-stark package is a minimal univariate STARK framework designed for proving and verifying a single Algebraic Intermediate Representation (AIR) over a two-adic field. It is generic over the Polynomial Commitment Scheme (PCS).

    Key abstractions include:

    • Prover/Verifier Entry Points: prove and verify (along with their *_with_preprocessed variants).
    • Configuration: StarkConfig and StarkGenericConfig which integrate the field, PCS, and challenger.
    • Constraint Building: SymbolicAirBuilder for symbolic constraint evaluation to infer degrees.
    • Data Types: Proof for the resulting proof object and VerificationError for typed error handling during verification.
  12. What is p3-whir?

    main
    p3-whir is an IOP (Interactive Oracle Proof) of proximity for constrained Reed–Solomon codes. It is designed for super-fast verification and serves as a multilinear polynomial commitment scheme. It implements the p3_commit::MultilinearPcs interface, allowing it to be used within the Plonky3 ecosystem for polynomial commitments.