Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Support importing hierarchical modules (#507).
- In Plonky3 codegen, use AirScriptAir and AirScriptBuilder traits, and generate aux constraints (#508).
- In Plonky3 codegen, use MidenAir and MidenAirBuilder from 0xMiden's Plonky3 fork instead of AirScriptAir and AirScriptBuilder (#515).
- In Plonky3 codegen, use prove/verify workflow for tests (#523).

## 0.4.0 (2025-06-20)

Expand Down
34 changes: 18 additions & 16 deletions air-script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,30 @@ log = { version = "0.4", default-features = false }
miden-diagnostics = { workspace = true }
mir = { package = "air-mir", path = "../mir", version = "0.5" }

[dev-dependencies]
expect-test = "1.4"

# 0xMiden Plonky3 Fork
p3-air = { package = "p3-air", git="https://github.com/0xMiden/Plonky3", rev = "5352d47ee57bd1b5d6008a90b64cbb7fe00aa17e", default-features = false }
p3-challenger = { package = "p3-challenger", git="https://github.com/0xMiden/Plonky3", rev = "5352d47ee57bd1b5d6008a90b64cbb7fe00aa17e", default-features = false }
p3-commit = { package = "p3-commit", git="https://github.com/0xMiden/Plonky3", rev = "5352d47ee57bd1b5d6008a90b64cbb7fe00aa17e", default-features = false }
p3-dft = { package = "p3-dft", git="https://github.com/0xMiden/Plonky3", rev = "5352d47ee57bd1b5d6008a90b64cbb7fe00aa17e", default-features = false }
p3-field = { package = "p3-field", git="https://github.com/0xMiden/Plonky3", rev = "5352d47ee57bd1b5d6008a90b64cbb7fe00aa17e", default-features = false }
p3-fri = { package = "p3-fri", git="https://github.com/0xMiden/Plonky3", rev = "5352d47ee57bd1b5d6008a90b64cbb7fe00aa17e", default-features = false }
p3-matrix = { package = "p3-matrix", git="https://github.com/0xMiden/Plonky3", rev = "5352d47ee57bd1b5d6008a90b64cbb7fe00aa17e", default-features = false }
p3-merkle-tree = { package = "p3-merkle-tree", git="https://github.com/0xMiden/Plonky3", rev = "5352d47ee57bd1b5d6008a90b64cbb7fe00aa17e", default-features = false }
p3-miden-air = { package = "miden-air", git="https://github.com/0xMiden/Plonky3", rev = "5352d47ee57bd1b5d6008a90b64cbb7fe00aa17e", default-features = false }
p3-goldilocks = { package = "p3-goldilocks", git="https://github.com/0xMiden/Plonky3", rev = "5352d47ee57bd1b5d6008a90b64cbb7fe00aa17e", default-features = false }
p3-sha256 = { package = "p3-sha256", git="https://github.com/0xMiden/Plonky3", rev = "5352d47ee57bd1b5d6008a90b64cbb7fe00aa17e", default-features = false }
p3-symmetric = { package = "p3-symmetric", git="https://github.com/0xMiden/Plonky3", rev = "5352d47ee57bd1b5d6008a90b64cbb7fe00aa17e", default-features = false }
p3-uni-stark = { package = "p3-uni-stark", git="https://github.com/0xMiden/Plonky3", rev = "5352d47ee57bd1b5d6008a90b64cbb7fe00aa17e", default-features = false }
p3-matrix = { package = "p3-matrix", git="https://github.com/0xMiden/Plonky3", rev = "f061ed111e5c160ad6e74475376b37dd2b0d61c7", default-features = false }
p3-field = { package = "p3-field", git="https://github.com/0xMiden/Plonky3", rev = "f061ed111e5c160ad6e74475376b37dd2b0d61c7", default-features = false }
p3-miden-air = { package = "miden-air", git="https://github.com/0xMiden/Plonky3", rev = "f061ed111e5c160ad6e74475376b37dd2b0d61c7", default-features = false }

# MassaLabs fork
miden-processor = { package = "miden-processor", git="https://github.com/massalabs/miden-vm", rev = "bc553af69a2543a0789830e8508b019694528181", default-features = false }
miden-air = { package = "miden-air", git="https://github.com/massalabs/miden-vm", rev = "bc553af69a2543a0789830e8508b019694528181", default-features = false }

[dev-dependencies]
expect-test = "1.4"

# 0xMiden Plonky3 Fork
p3-air = { package = "p3-air", git="https://github.com/0xMiden/Plonky3", rev = "f061ed111e5c160ad6e74475376b37dd2b0d61c7", default-features = false }
p3-challenger = { package = "p3-challenger", git="https://github.com/0xMiden/Plonky3", rev = "f061ed111e5c160ad6e74475376b37dd2b0d61c7", default-features = false }
p3-commit = { package = "p3-commit", git="https://github.com/0xMiden/Plonky3", rev = "f061ed111e5c160ad6e74475376b37dd2b0d61c7", default-features = false }
p3-dft = { package = "p3-dft", git="https://github.com/0xMiden/Plonky3", rev = "f061ed111e5c160ad6e74475376b37dd2b0d61c7", default-features = false }
p3-fri = { package = "p3-fri", git="https://github.com/0xMiden/Plonky3", rev = "f061ed111e5c160ad6e74475376b37dd2b0d61c7", default-features = false }
p3-merkle-tree = { package = "p3-merkle-tree", git="https://github.com/0xMiden/Plonky3", rev = "f061ed111e5c160ad6e74475376b37dd2b0d61c7", default-features = false }
p3-miden-prover = { package = "miden-prover", git="https://github.com/0xMiden/Plonky3", rev = "f061ed111e5c160ad6e74475376b37dd2b0d61c7", default-features = false }
p3-goldilocks = { package = "p3-goldilocks", git="https://github.com/0xMiden/Plonky3", rev = "f061ed111e5c160ad6e74475376b37dd2b0d61c7", default-features = false }
p3-sha256 = { package = "p3-sha256", git="https://github.com/0xMiden/Plonky3", rev = "f061ed111e5c160ad6e74475376b37dd2b0d61c7", default-features = false }
p3-symmetric = { package = "p3-symmetric", git="https://github.com/0xMiden/Plonky3", rev = "f061ed111e5c160ad6e74475376b37dd2b0d61c7", default-features = false }

winter-air = { package = "winter-air", version = "0.12", default-features = false }
winter-math = { package = "winter-math", version = "0.12", default-features = false }
winter-utils = { package = "winter-utils", version = "0.12", default-features = false }
Expand Down
3 changes: 3 additions & 0 deletions air-script/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ pub use air_codegen_winter::CodeGenerator as WinterfellCodeGenerator;
pub use air_ir::{Air, CompileError, compile};
pub use air_parser::{parse, parse_file, transforms};

/// Miden VM auxiliary trace generator
pub mod miden_vm_aux_trace_generator;

#[cfg(test)]
pub mod test_utils;
#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn build_aux_trace_with_miden_vm<F, EF>(
main: &RowMajorMatrix<F>,
challenges: &[EF],
module: MidenModule,
) -> RowMajorMatrix<EF>
) -> RowMajorMatrix<F>
where
F: Field + PrimeField64,
EF: ExtensionField<F>,
Expand Down Expand Up @@ -112,5 +112,6 @@ where
}
}

aux_trace
let aux_trace_f = aux_trace.flatten_to_base();
aux_trace_f
}
13 changes: 6 additions & 7 deletions air-script/src/test_utils/air_tester_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ macro_rules! generate_air_plonky3_test_with_airscript_traits {
>;
type Dft = p3_dft::Radix2DitParallel<Val>;
type Pcs = p3_fri::TwoAdicFriPcs<Val, Dft, ValMmcs, ChallengeMmcs>;
type MyConfig = p3_uni_stark::StarkConfig<Pcs, Challenge, Challenger>;
type MyConfig = p3_miden_prover::StarkConfig<Pcs, Challenge, Challenger>;

let byte_hash = ByteHash {};
let field_hash = FieldHash::new(p3_sha256::Sha256);
Expand All @@ -62,7 +62,8 @@ macro_rules! generate_air_plonky3_test_with_airscript_traits {
let challenge_mmcs = ChallengeMmcs::new(val_mmcs.clone());
let challenger = Challenger::from_hasher(vec![], byte_hash);
let dft = Dft::default();
let fri_params = p3_fri::create_benchmark_fri_params(challenge_mmcs);
let mut fri_params = p3_fri::create_benchmark_fri_params(challenge_mmcs);
fri_params.log_blowup = 4; // Use a higher blowup than default for degree 9 constraints
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we fix this now or is there something blocking it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we fix this now or is there something blocking it?

I don't think anything is blocking it. There are multiple functions in p3_fri to create params (create_test_fri_params, create_test_fri_params_zk, create_benchmark_fri_params..). Maybe we could add a create_miden_fri_params with the values we want if we know them all.

Here it generates:

    FriParameters {
        log_blowup: 4,
        log_final_poly_len: 0,
        num_queries: 100,
        proof_of_work_bits: 16,
        mmcs,
        log_folding_factor: 1,
    }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, and also a configuration with blow up factor 8 for Miden VM constraints.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, and also a configuration with blow up factor 8 for Miden VM constraints.

Did you mean like so? 0xMiden/Plonky3#19

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need log_blowup=4? I thought we only went up until 3 for our constraints, but maybe we're doing 4 for smaller proofs?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, log_blowup=3 should be enough for us in this context

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated #19 to only have a log_blow_up of 3 and one set of parameters for miden, when targetting it here I have some issues but I think just increasing the number of rows for the proof will be enough, I'll test it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also will reduce the constraints degrees for a few of the tests.

let pcs = Pcs::new(dft, val_mmcs, fri_params);
let config = MyConfig::new(pcs, challenger);

Expand All @@ -74,11 +75,9 @@ macro_rules! generate_air_plonky3_test_with_airscript_traits {

let trace = generate_trace_rows::<Val>(inputs);

check_constraints_with_airscript_traits::<Val, Challenge, $air_name>(
&$air_name {},
&trace,
&inputs_goldilocks,
);
let proof = p3_miden_prover::prove(&config, &$air_name {}, &trace, &inputs_goldilocks);
p3_miden_prover::verify(&config, &$air_name {}, &proof, &inputs_goldilocks)
.expect("Verification failed");
}
};
}
4 changes: 0 additions & 4 deletions air-script/src/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@
pub mod air_tester_macros;
/// Code generation for tests/**/*.air files.
pub mod codegen;
/// Miden VM auxiliary trace generator
pub mod miden_vm_aux_trace_generator;
/// Plonky3-specific Debug constraint builder implementation
pub mod plonky3_traits;
/// Winterfell-specific traits
pub mod winterfell_traits;
189 changes: 0 additions & 189 deletions air-script/src/test_utils/plonky3_traits.rs

This file was deleted.

5 changes: 3 additions & 2 deletions air-script/src/tests/binary/binary_plonky3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ impl<F, EF> MidenAir<F, EF> for BinaryAir {
}

fn eval<AB>(&self, builder: &mut AB)
where AB: MidenAirBuilder<F = F, EF = EF>,
where AB: MidenAirBuilder<F = F>,
{
let public_values: [_; NUM_PUBLIC_VALUES] = builder.public_values().try_into().expect("Wrong number of public values");
let periodic_values: [_; NUM_PERIODIC_VALUES] = builder.periodic_evals().try_into().expect("Wrong number of periodic values");
let preprocessed = builder.preprocessed();
// Note: for now, we do not have any preprocessed values
// let preprocessed = builder.preprocessed();
let main = builder.main();
let (main_current, main_next) = (
main.row_slice(0).unwrap(),
Expand Down
1 change: 0 additions & 1 deletion air-script/src/tests/binary/test_air_plonky3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use p3_miden_air::RowMajorMatrix;

use crate::{
generate_air_plonky3_test_with_airscript_traits,
test_utils::plonky3_traits::check_constraints_with_airscript_traits,
tests::binary::binary_plonky3::{BinaryAir, MAIN_WIDTH},
};

Expand Down
5 changes: 3 additions & 2 deletions air-script/src/tests/bitwise/bitwise_plonky3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ where F: Field,
}

fn eval<AB>(&self, builder: &mut AB)
where AB: MidenAirBuilder<F = F, EF = EF>,
where AB: MidenAirBuilder<F = F>,
{
let public_values: [_; NUM_PUBLIC_VALUES] = builder.public_values().try_into().expect("Wrong number of public values");
let periodic_values: [_; NUM_PERIODIC_VALUES] = builder.periodic_evals().try_into().expect("Wrong number of periodic values");
let preprocessed = builder.preprocessed();
// Note: for now, we do not have any preprocessed values
// let preprocessed = builder.preprocessed();
let main = builder.main();
let (main_current, main_next) = (
main.row_slice(0).unwrap(),
Expand Down
1 change: 0 additions & 1 deletion air-script/src/tests/bitwise/test_air_plonky3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use p3_miden_air::RowMajorMatrix;

use crate::{
generate_air_plonky3_test_with_airscript_traits,
test_utils::plonky3_traits::check_constraints_with_airscript_traits,
tests::bitwise::bitwise_plonky3::{BitwiseAir, MAIN_WIDTH},
};

Expand Down
10 changes: 6 additions & 4 deletions air-script/src/tests/buses/buses_complex_plonky3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ where F: Field,
AUX_WIDTH
}

fn build_aux_trace(&self, _main: &RowMajorMatrix<F>, _challenges: &[EF]) -> Option<RowMajorMatrix<EF>> {
fn build_aux_trace(&self, _main: &RowMajorMatrix<F>, _challenges: &[EF]) -> Option<RowMajorMatrix<F>> {
// Note: consider using Some(build_aux_trace_with_miden_vm::<F, EF>(_main, _challenges, module)) if you want to build the aux trace using Miden VM aux trace builders.

let num_rows = _main.height();
Expand Down Expand Up @@ -66,15 +66,17 @@ where F: Field,
rows[i+1][j] = next_row[j];
}
}
Some(trace)
let trace_f = trace.flatten_to_base();
Some(trace_f)
}

fn eval<AB>(&self, builder: &mut AB)
where AB: MidenAirBuilder<F = F, EF = EF>,
where AB: MidenAirBuilder<F = F>,
{
let public_values: [_; NUM_PUBLIC_VALUES] = builder.public_values().try_into().expect("Wrong number of public values");
let periodic_values: [_; NUM_PERIODIC_VALUES] = builder.periodic_evals().try_into().expect("Wrong number of periodic values");
let preprocessed = builder.preprocessed();
// Note: for now, we do not have any preprocessed values
// let preprocessed = builder.preprocessed();
let main = builder.main();
let (main_current, main_next) = (
main.row_slice(0).unwrap(),
Expand Down
Loading
Loading