Skip to content

Conversation

@Al-Kindi-0
Copy link

@Al-Kindi-0 Al-Kindi-0 commented Dec 17, 2025

This PR merges changes from the original Plonky3. It also renames our version of FRI to p3-miden-fri which will ease our transition to lifted FRI.

More precisely, we add the following

Crated Based On Purpose
p3-miden-goldilocks p3-goldilocks Goldilocks field with Miden compatibility APIs
p3-miden-uni-stark p3-uni-stark Extended Entry enum with Aux/Periodic variants
p3-miden-fri p3-fri Miden naive FRI implementation with higher folding factors
p3-miden-air p3-air Miden AIR traits and types
p3-miden-prover - Miden prover combining the above crates

1. p3-miden-goldilocks

Based on: p3-goldilocks

Purpose: Provides the Goldilocks field with additional APIs for compatibility with miden-crypto, especially const support.

Key Changes from p3-goldilocks

// Additional constructors
pub const fn new(value: u64) -> Self
pub const fn from_u64_unchecked(value: u64) -> Self
pub const fn from_u64_array<const N: usize>(values: [u64; N]) -> [Self; N]

// Accessor methods
pub const fn inner(&self) -> u64
pub const fn as_int(&self) -> u64  // Alias for as_canonical_u64()

// Validated constructor (replaces TryFrom<u64>)
pub fn try_checked(value: u64) -> Result<Self, String>

Why These Changes

  • new() and from_u64_unchecked(): Const constructors needed for compile-time field element creation
  • as_int(): Compatibility alias, should be easy to drop.
  • try_checked(): Replaces TryFrom<u64> which conflicts with the blanket impl from From<u64>

2. p3-miden-uni-stark

Based on: p3-uni-stark

Purpose: Extends the Entry enum with Miden-specific variants for auxiliary traces and periodic columns.

Key Changes from p3-uni-stark

// Extended Entry enum
pub enum Entry {
    Preprocessed { offset: usize },
    Main { offset: usize },
    Permutation { offset: usize },
    Aux { offset: usize },      // NEW: Auxiliary trace columns
    Periodic,                    // NEW: Periodic columns
    Public,
    Challenge,
}

// Updated degree_multiple for new variants
impl SymbolicVariable {
    pub const fn degree_multiple(&self) -> usize {
        match self.entry {
            Entry::Preprocessed { .. }
            | Entry::Main { .. }
            | Entry::Permutation { .. }
            | Entry::Aux { .. } => 1,           // Aux has degree 1
            Entry::Public | Entry::Periodic | Entry::Challenge => 0,  // Periodic has degree 0
        }
    }
}

Re-exports from p3-uni-stark

The crate re-exports StarkGenericConfig, StarkConfig, and related types from p3-uni-stark to ensure a single trait definition across the codebase:

// config.rs
pub use p3_uni_stark::{
    Domain, PackedChallenge, PackedVal, PcsError, StarkConfig, StarkGenericConfig, Val,
};

Why These Changes

  • Entry::Aux: Required for Miden's auxiliary trace columns used in permutation arguments
  • Entry::Periodic: Required for periodic columns (columns with values that repeat with a fixed period)

3. p3-miden-fri

Based on: p3-fri

Purpose: Miden-specific naive FRI implementation supporting higher arity folding factors.


4. p3-miden-air

Based on: p3-air

Purpose: Miden AIR (Algebraic Intermediate Representation) traits and types.

Key Components

  • AIR trait implementations for Miden VM with aux trace support

5. p3-miden-prover

Based on: Combines multiple crates

Purpose: The main Miden prover that orchestrates proof generation and supports aux trace generation.

Dependencies

p3-miden-goldilocks
p3-miden-uni-stark
p3-miden-fri
p3-miden-air
p3-air
p3-field
p3-matrix
p3-commit
p3-challenger

Key Components

  • prove() and verify() functions
  • LogUp argument implementation (could be dropped as we are not making use of it)
  • Constraint folding to handle aux constraints

Upstream Compatibility

The following core Plonky3 crates remain unchanged from upstream:

  • p3-field - Core field traits and implementations
  • p3-uni-stark - Base univariate STARK framework
  • p3-fri - Base FRI implementation
  • p3-air - Base AIR traits
  • p3-matrix - Matrix operations
  • p3-commit - Polynomial commitment schemes
  • p3-challenger - Fiat-Shamir challenger
  • p3-symmetric - Symmetric cryptography primitives
  • p3-merkle-tree - Merkle tree implementation

tcoratger and others added 30 commits November 18, 2025 22:02
…r` trait (Plonky3#1152)

* challenger: add observe_lifted to FieldChallenger trait

* change name

* fix name

* fix trait bounds

* minor change

* minor change
…nky3#1155)

* challenger: add unit tests for observe_base_as_algebra_element

* fix comments
* Update lib.rs

* Update Cargo.toml

* Update koala_bear.rs

* Update baby_bear.rs

* Update bn254.rs

* Update Cargo.toml

* Update bn254.rs

* Update baby_bear.rs

* Update bn254.rs

* Update koala_bear.rs

* Update bn254.rs

* Update baby_bear.rs

* Update Cargo.toml

* Update lib.rs

* Update lib.rs

* Update Cargo.toml

* Update Cargo.toml

* Update lib.rs

* Update koala_bear.rs

* Update baby_bear.rs

* Update lib.rs

* Update lib.rs

* Update lib.rs

* Update Cargo.toml

* Update lib.rs

* Update lib.rs

* Update field-testing/src/lib.rs

---------

Co-authored-by: AngusG <[email protected]>
* Change traits and add folders with lookups

* Apply comments

* Apply comment
* matrix: make HorizontallyTruncated more generic

* small cleanup
Updates the requirements on [criterion](https://github.com/criterion-rs/criterion.rs) to permit the latest version.
- [Release notes](https://github.com/criterion-rs/criterion.rs/releases)
- [Changelog](https://github.com/criterion-rs/criterion.rs/blob/master/CHANGELOG.md)
- [Commits](criterion-rs/criterion.rs@criterion-plot-v0.7.0...criterion-v0.8.0)

---
updated-dependencies:
- dependency-name: criterion
  dependency-version: 0.8.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* uni stark: small touchups

* Update uni-stark/src/symbolic_expression.rs

Co-authored-by: Robin Salen <[email protected]>

* small touchup

---------

Co-authored-by: Robin Salen <[email protected]>
* core: add error messages to Error enums via thiserror

* sort cargo file
* feat: add SubAirBuilder

* refactor: remove SubMatrixRowSlices and reuse HorizontallyTruncated

* chore: clippy

* chore: fmt

* Update sub_builder.rs

Co-authored-by: Thomas Coratger <[email protected]>

* Update sub_builder.rs

Co-authored-by: Thomas Coratger <[email protected]>

* Update sub_builder.rs

Co-authored-by: Thomas Coratger <[email protected]>

* Update rc_sub_builder.rs

Co-authored-by: Thomas Coratger <[email protected]>

---------

Co-authored-by: Thomas Coratger <[email protected]>
* doc: add rustdoc links

* more linking
* Allow users to impl either permute or permute_mut

* Add comment to Permutation trait method indicating the circular nature of the trait definitions.
* Integrate lookups to prover and verifier

* Apply comments

* Apply comments and Clippy
* Work on automated releases

- Added CI to trigger a crates.io release when a release PR is merged.
- Added a script to generate a release PR (and temporarily modify
  sub-crate `Cargo.toml`s.
- Added `release-plz.toml`.

* A bit more work on automated release logic

* Fixed some things

* Now only runs on main

* Cleanup

* Removed old release scripts

* `release-plz` CI now looks for the "release" label

* Docs

* Various squashed commits

Removed unused release logic

REMOVE ME!!

Now using `GIT_TOKEN` again

* (AI) Finished the logic to release

* Apply suggestions from code review

- Applied Syxton's new packages.

Co-authored-by: AngusG <[email protected]>

---------

Co-authored-by: AngusG <[email protected]>
* challenger: add observe_algebra_elements method

* Update challenger/src/lib.rs

Co-authored-by: AngusG <[email protected]>

* fix comment

* fix comment

---------

Co-authored-by: AngusG <[email protected]>
* core: small touchups

* touchups

* touchups
* challenger: use observe_algebra_slice when possible

* clippy

* chore: pacify clippy

---------

Co-authored-by: Robin Salen <[email protected]>
Add a proof-of-work phase before each commit-phase fold challenge, using
new configuration parameter `commit_proof_of_work_bits`. Note for
simplicity, there is a single `commit_proof_of_work_bits` shared across
all rounds.

We also change the `check_witness` logic to be a no-op when `bits == 0`.
…ky3#1177)

* fix(keccak-air): align state indexing with Keccak specification

  - Add transpose after transmute to convert from row-major to standard
    Keccak indexing (state[x + 5*y])
  - Add tiny-keccak as dev-dependency for reference testing
  - Add 5 unit tests comparing output against tiny-keccak reference

  Fixes Plonky3#672

* refactor(keccak-air): use p3-keccak instead of tiny-keccak for tests

Replace tiny-keccak dev-dependency with p3-keccak for testing the
keccak-air implementation. The p3-keccak crate is already validated
against tiny-keccak in its own tests, so this avoids redundant
external dependencies while maintaining test correctness.
* implement `UniformSamplingField` and `CanSampleUniformBits` traits

The former is the trait a field will implement to define the
parameters needed for the `sample_uniform_bits` function via the
`CanSampleUniformBits` (which the challengers need to implement).

* implement `UniformSamplingField` for all small fields

* implement `CanSampleUniformBits` for `DuplexChallenger`

This also adds the `uniform-sampling-may-panic` feature, which decides
whether finding a field element >= m_k will resample (rejection
sampling) or panic. In some contexts, e.g. recursive zkVMs it may be
preferable to panic and just accept a very small probability of a
proof failing.

* implement `UniformGrindingChallenger`

This goes hand in hand with the uniform sampling for the duplex
challenger. Instead of grinding using regular sampling, this one
samples using uniform sampling.

* fix regression in `sample_bits`

Accidentally cut off the normal implementation, oops

* split sampling of values into may panic / resampling approach

We'll make it so that the user can choose which variant to call.

* remove feature for sampling with panic, split into two functions

`_may_panic` suffix for functions that may trigger a panic.

* implement `_may_panic` variants for UniformGrindingChallenger

As it is now not a feature flag, but requires a different function
call, we simply add different overloads for variants that may panic to
make it clear at the callsite.

* implement UniformSamplingField for Monty31 field

Due to the orphan rule we have to implement this trait either in the
challenger trait or in the Monty31 crate.

It seems to make sense to implement this in the challenger, as the
Monty crate is more fundamental than the challenger, which anyway
requires the notion of fields.

* use `Self` for BabyBear / KoalaBear prime

* remove outdated grinding challenger code

* remove duplicated doc comments for UniformSamplingField for each field

* remove doc comment for blanket implementation

We keep a basic comment to clarify the reader as to why it exists.

* implement sampling of bits based on a strategy-like pattern

* implement uniform grinding with generic fn

* check bits are >0 in grind fns

* add doc comments to `check_witness[_may_panic]`

* fix sort order of dependencies

* apply fixes for `cargo +stable clippy --all-targets -- -D -warnings`

* address cargo +nightly fmt --all fixes

* improve doc comment about m_k

* allow `bits = 0` argument, just return zero always

* remove `_strategy` argument, use explicit generic call instead

* have single `sample_value` function with a PANIC_ON_REJECTION const

* switch to Result based API for uniform sampling of bits

In order to allow the verifier called functions to just return false
if a panic would have happened on the prover's side

* have single `sample_uniform_bits` with const generic to choose

* allow bits == 0 in grind, grind_uniform again

* add doc comment about CanSampleUniformBits trait

* rename all panic -> error

* remove bits > 0 from last grind fn as well

* address Clippy errors

* cargo fmt fixes
- Needed for the final bit of work to automate releases.
* matrix: add pad_to_power_of_two_height

* fix comments

* Update matrix/src/dense.rs

Co-authored-by: AngusG <[email protected]>

* fmt

---------

Co-authored-by: AngusG <[email protected]>
* feat: revert `builder.assert_bool` to previous impl

* Update field.rs
@Al-Kindi-0
Copy link
Author

We changed the approach to using https://github.com/0xMiden/p3-miden

@Al-Kindi-0 Al-Kindi-0 closed this Dec 17, 2025
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.