Skip to content

Commit

Permalink
Add Mersene31Field (#1781)
Browse files Browse the repository at this point in the history
Adds Plonky3's implementation of the Mersenne-31 field.

To test:
```
cargo run pil test_data/pil/fibonacci.pil -o output -f --field m31
```

The implementation is basically the same wrapper as for BabyBear, so I
moved the code to a macro and used it for both fields.
  • Loading branch information
georgwiese authored Sep 10, 2024
1 parent 4f190b9 commit 41a61b1
Show file tree
Hide file tree
Showing 9 changed files with 485 additions and 397 deletions.
6 changes: 5 additions & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use env_logger::{Builder, Target};
use log::{max_level, LevelFilter};
use powdr_backend::BackendType;
use powdr_number::{buffered_write_file, read_polys_csv_file, CsvRenderMode};
use powdr_number::{BabyBearField, BigUint, Bn254Field, FieldElement, GoldilocksField};
use powdr_number::{
BabyBearField, BigUint, Bn254Field, FieldElement, GoldilocksField, Mersenne31Field,
};
use powdr_pipeline::Pipeline;
use std::io;
use std::path::PathBuf;
Expand Down Expand Up @@ -61,6 +63,8 @@ fn bind_cli_args<F: FieldElement>(
pub enum FieldArgument {
#[strum(serialize = "bb")]
Bb,
#[strum(serialize = "m31")]
M31,
#[strum(serialize = "gl")]
Gl,
#[strum(serialize = "bn254")]
Expand Down
1 change: 1 addition & 0 deletions cli/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ macro_rules! call_with_field {
($function:ident::<$field:ident>($($args:expr),*) ) => {
match $field {
FieldArgument::Bb => $function::<BabyBearField>($($args),*),
FieldArgument::M31 => $function::<Mersenne31Field>($($args),*),
FieldArgument::Gl => $function::<GoldilocksField>($($args),*),
FieldArgument::Bn254 => $function::<Bn254Field>($($args),*),
}
Expand Down
1 change: 1 addition & 0 deletions number/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ark-bn254 = { version = "0.4.0", default-features = false, features = [
ark-ff = "0.4.2"
ark-serialize = "0.4.2"
p3-baby-bear = { git = "https://github.com/powdr-labs/Plonky3.git", branch = "main" }
p3-mersenne-31 = { git = "https://github.com/powdr-labs/Plonky3.git", branch = "main" }
p3-field = { git = "https://github.com/powdr-labs/Plonky3.git", branch = "main" }
num-bigint = { version = "0.4.3", features = ["serde"] }
num-traits = "0.2.15"
Expand Down
Loading

0 comments on commit 41a61b1

Please sign in to comment.