Skip to content

Commit d7ab759

Browse files
Switch Poseidon2 -> Poseidon1
Co-authored-by: Thomas Coratger <thomas.coratger@gmail.com>
2 parents a7e1806 + b897f1e commit d7ab759

84 files changed

Lines changed: 2259 additions & 3627 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 34 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ members = [
1818
"crates/backend/air",
1919
"crates/backend/fiat-shamir",
2020
"crates/backend/sumcheck",
21-
"crates/whir",
2221
]
2322

2423
[workspace.lints]
@@ -60,39 +59,42 @@ sub_protocols = { path = "crates/sub_protocols" }
6059
lean_compiler = { path = "crates/lean_compiler" }
6160
lean_prover = { path = "crates/lean_prover" }
6261
rec_aggregation = { path = "crates/rec_aggregation" }
62+
backend = { path = "crates/backend" }
6363

6464
# External
6565
clap = { version = "4.5.59", features = ["derive"] }
66-
rand = "0.10"
66+
rand = "0.10.0"
6767
rayon = "1.11.0"
6868
pest = "2.7"
6969
pest_derive = "2.7"
7070
itertools = "0.14.0"
7171
tracing = "0.1.26"
7272
serde_json = "1.0.145"
7373
serde = { version = "1.0.228", features = ["derive"] }
74-
tracing-subscriber = { version = "0.3.19", features = ["std", "env-filter"] }
74+
tracing-subscriber = { version = "0.3.23", features = ["std", "env-filter"] }
7575
tracing-forest = { version = "0.3.0", features = ["ansi", "smallvec"] }
7676
postcard = { version = "1.1.3", features = ["alloc"] }
77-
lz4_flex = "0.12.0"
78-
79-
backend = { path = "crates/backend" }
77+
lz4_flex = "0.13.0"
78+
leansig = { git = "https://github.com/leanEthereum/leanSig", branch = "devnet4" }
79+
leansig_fast_keygen = { git = "https://github.com/TomWambsgans/leanSig", branch = "devnet4-fast-keygen" }
8080

8181
[features]
8282
prox-gaps-conjecture = ["rec_aggregation/prox-gaps-conjecture"]
8383

8484
[dependencies]
8585
clap.workspace = true
8686
rec_aggregation.workspace = true
87-
xmss.workspace = true
8887
air.workspace = true
8988
rand.workspace = true
9089
sub_protocols.workspace = true
9190
utils.workspace = true
92-
9391
lean_vm.workspace = true
92+
xmss.workspace = true
9493
backend.workspace = true
9594

95+
[dev-dependencies]
96+
serde_json.workspace = true
97+
9698

9799
[profile.release]
98100
lto = "thin"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ cargo run --release -- recursion --n 2
5252

5353
| Proven | Conjectured |
5454
| --------------- | --------------- |
55-
| 0.75s - 188 KiB | 0.57s - 116 KiB |
55+
| 0.8s - 188 KiB | 0.57s - 116 KiB |
5656

5757

5858
### Bonus: unbounded recursive aggregation

crates/backend/fiat-shamir/src/verifier.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
};
1010
use field::PrimeCharacteristicRing;
1111
use field::{ExtensionField, PrimeField64};
12-
use koala_bear::{KoalaBear, default_koalabear_poseidon2_16};
12+
use koala_bear::{KoalaBear, default_koalabear_poseidon1_16};
1313
use symetric::Compression;
1414

1515
pub struct VerifierState<EF: ExtensionField<PF<EF>>, P> {
@@ -71,7 +71,7 @@ where
7171
assert_eq!(TypeId::of::<PF<EF>>(), TypeId::of::<KoalaBear>());
7272
// SAFETY: We've confirmed PF<EF> == KoalaBear
7373
let paths: PrunedMerklePaths<KoalaBear, KoalaBear> = unsafe { std::mem::transmute(paths) };
74-
let perm = default_koalabear_poseidon2_16();
74+
let perm = default_koalabear_poseidon1_16();
7575
let hash_fn = |data: &[KoalaBear]| symetric::hash_slice::<_, _, 16, 8, DIGEST_LEN_FE>(&perm, data);
7676
let combine_fn = |left: &[KoalaBear; DIGEST_LEN_FE], right: &[KoalaBear; DIGEST_LEN_FE]| {
7777
symetric::compress(&perm, [*left, *right])
Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use koala_bear::{
2-
ExternalLayerConstants, KOALABEAR_RC16_EXTERNAL_FINAL, KOALABEAR_RC16_EXTERNAL_INITIAL, KOALABEAR_RC16_INTERNAL,
3-
Poseidon2KoalaBear, QuinticExtensionFieldKB,
4-
};
1+
use koala_bear::{QuinticExtensionFieldKB, default_koalabear_poseidon1_16};
52
use mt_fiat_shamir::{FSProver, FSVerifier, ProverState, VerifierState};
63
use std::time::Instant;
74

@@ -11,25 +8,18 @@ type EF = QuinticExtensionFieldKB;
118
#[ignore]
129
fn bench_grinding() {
1310
let n_reps = 100;
14-
for grinding_bits in 10..=20 {
15-
let mut prover_state = ProverState::<EF, _>::new(get_poseidon16());
11+
for grinding_bits in 20..=20 {
12+
let mut prover_state = ProverState::<EF, _>::new(default_koalabear_poseidon1_16());
1613
let time = Instant::now();
1714
for _ in 0..n_reps {
1815
prover_state.pow_grinding(grinding_bits);
1916
}
2017
let elapsed = time.elapsed();
21-
let mut verifier_state = VerifierState::<EF, _>::new(prover_state.into_proof(), get_poseidon16()).unwrap();
18+
let mut verifier_state =
19+
VerifierState::<EF, _>::new(prover_state.into_proof(), default_koalabear_poseidon1_16()).unwrap();
2220
for _ in 0..n_reps {
2321
verifier_state.check_pow_grinding(grinding_bits).unwrap()
2422
}
2523
println!("Grinding {grinding_bits} bits: {:?}", elapsed / n_reps);
2624
}
2725
}
28-
29-
pub fn get_poseidon16() -> Poseidon2KoalaBear<16> {
30-
let external_constants = ExternalLayerConstants::new(
31-
KOALABEAR_RC16_EXTERNAL_INITIAL.to_vec(),
32-
KOALABEAR_RC16_EXTERNAL_FINAL.to_vec(),
33-
);
34-
Poseidon2KoalaBear::new(external_constants, KOALABEAR_RC16_INTERNAL.to_vec())
35-
}

crates/backend/field/src/field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ pub trait PrimeCharacteristicRing:
337337

338338
// For `N <= 8` we implement a tree sum structure and for `N > 8` we break the input into
339339
// chunks of `8`, perform a tree sum on each chunk and sum the results. The parameter `8`
340-
// was determined experimentally by testing the speed of the poseidon2 internal layer computations.
340+
// was determined experimentally by testing the speed of the poseidon internal layer computations.
341341
// This is a useful benchmark as we have a mix of summations of size 15, 23 with other work in between.
342342
// I only tested this on `AVX2` though so there might be a better value for other architectures.
343343
match N {
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Credits: Plonky3 (https://github.com/Plonky3/Plonky3) (MIT and Apache-2.0 licenses).
22

33
mod packing;
4-
mod poseidon2;
54

65
pub use packing::*;

0 commit comments

Comments
 (0)