Skip to content

Commit e8f201a

Browse files
committed
use blowup factor of 2 and set extesion to 3 in p3
1 parent 278cd5a commit e8f201a

4 files changed

Lines changed: 42 additions & 11 deletions

File tree

bench_vs_plonky3/benches/stark_comparison.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ const NUM_SEQUENCES: usize = 16;
2727
const ROWS: usize = 1 << 18;
2828
const TRACE_LABEL: &str = "fib_pair_16seq_2^18";
2929

30-
/// Proof options matching Lambda's `profile_prover.rs`:
31-
/// blowup=4, 100 queries, no grinding — production-like settings.
30+
/// Production proof options: blowup=2, 219 queries (from
31+
/// `GoldilocksCubicProofOptions::with_blowup(2)`), grinding=0 (excluded
32+
/// from benchmark — identical PoW work on both sides, not informative).
3233
fn benchmark_proof_options() -> ProofOptions {
3334
ProofOptions {
34-
blowup_factor: 4,
35-
fri_number_of_queries: 100,
35+
blowup_factor: 2,
36+
fri_number_of_queries: 219,
3637
coset_offset: 3,
3738
grinding_factor: 0,
3839
}

bench_vs_plonky3/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ mod tests {
2222

2323
fn benchmark_proof_options() -> ProofOptions {
2424
ProofOptions {
25-
blowup_factor: 4,
26-
fri_number_of_queries: 100,
25+
blowup_factor: 2,
26+
fri_number_of_queries: 219,
2727
coset_offset: 3,
2828
grinding_factor: 0,
2929
}

bench_vs_plonky3/src/plonky3_config.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ use p3_symmetric::{CompressionFunctionFromHasher, PaddingFreeSponge, Serializing
1010
use p3_uni_stark::StarkConfig;
1111

1212
pub type Val = Goldilocks;
13-
pub type Challenge = BinomialExtensionField<Val, 2>;
13+
/// Degree-3 cubic extension, same as Lambda's `Degree3GoldilocksExtensionField`.
14+
/// Irreducible: x^3 - 2 (W = 2). Implemented in vendor-p3-goldilocks.
15+
pub type Challenge = BinomialExtensionField<Val, 3>;
1416

1517
type ByteHash = Keccak256Hash;
1618
type U64Hash = PaddingFreeSponge<KeccakF, 25, 17, 4>;
@@ -42,18 +44,20 @@ fn build_mmcs() -> (ValMmcs, ChallengeMmcs, ByteHash) {
4244
}
4345

4446
/// Creates a Plonky3 STARK config with parameters matched to Lambda's
45-
/// `profile_prover.rs`: blowup=4, 100 FRI queries, no grinding.
47+
/// production config `GoldilocksCubicProofOptions::with_blowup(2)`:
48+
/// blowup=2, 219 FRI queries, grinding=0 (excluded from benchmark).
4649
pub fn matched_params_config() -> P3Config {
4750
let (val_mmcs, challenge_mmcs, byte_hash) = build_mmcs();
4851
let dft = Dft::default();
4952
let challenger = Challenger::from_hasher(vec![], byte_hash);
5053

51-
// Match Lambda's profile_prover: blowup=4, queries=100, grinding=0.
54+
// Match Lambda production: blowup=2, queries=219, grinding=0.
55+
// Grinding excluded from benchmark (identical PoW on both sides).
5256
let fri_params = FriParameters {
53-
log_blowup: 2, // blowup = 4
57+
log_blowup: 1, // blowup = 2
5458
log_final_poly_len: 0,
5559
max_log_arity: 1,
56-
num_queries: 100,
60+
num_queries: 219,
5761
commit_proof_of_work_bits: 0,
5862
query_proof_of_work_bits: 0,
5963
mmcs: challenge_mmcs,

bench_vs_plonky3/vendor-p3-goldilocks/src/extension.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,32 @@ impl HasTwoAdicBinomialExtension<2> for Goldilocks {
3535
}
3636
}
3737

38+
impl BinomiallyExtendableAlgebra<Self, 3> for Goldilocks {}
39+
40+
impl BinomiallyExtendable<3> for Goldilocks {
41+
// Verifiable in Sage with
42+
// `R.<x> = GF(p)[]; assert (x^3 - 2).is_irreducible()`.
43+
// Same irreducible as Lambda's Degree3GoldilocksExtensionField.
44+
const W: Self = Self::new(2);
45+
46+
// DTH_ROOT = primitive 3rd root of unity = 7^((p-1)/3) mod p.
47+
const DTH_ROOT: Self = Self::new(18446744065119617025);
48+
49+
// Generator of GF(p^3)* = 5 + w. Verified: passes order checks for
50+
// all small prime factors of p^3 - 1.
51+
const EXT_GENERATOR: [Self; 3] = [Self::new(5), Self::ONE, Self::ZERO];
52+
}
53+
54+
impl HasTwoAdicBinomialExtension<3> for Goldilocks {
55+
// v_2(p^3 - 1) = v_2(p-1) + v_2(p^2+p+1) = 32 + 0 = 32.
56+
const EXT_TWO_ADICITY: usize = 32;
57+
58+
fn ext_two_adic_generator(bits: usize) -> [Self; 3] {
59+
assert!(bits <= 32);
60+
field_to_array(Self::two_adic_generator(bits))
61+
}
62+
}
63+
3864
impl BinomiallyExtendableAlgebra<Self, 5> for Goldilocks {}
3965

4066
impl BinomiallyExtendable<5> for Goldilocks {

0 commit comments

Comments
 (0)