Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
65 changes: 61 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024"
authors = ["Argument Engineering <engineering@argument.xyz>"]
license = "MIT OR Apache-2.0"
rust-version = "1.88"
rust-version = "1.91"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -28,6 +28,8 @@ p3-util = { git = "https://github.com/Plonky3/Plonky3", rev = "e9d75614dd6816f9b

[dev-dependencies]
criterion = "0.5"
p3-baby-bear = { git = "https://github.com/Plonky3/Plonky3", rev = "e9d75614dd6816f9b5dbb4413c69be63536efd64" }
rand = "0.10"

[[bench]]
name = "multi_stark"
Expand Down
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ lookup arguments for shared state.
- **Lookup arguments** — push/pull interactions of arbitrary length between
circuits, enforced via accumulator-based multiset checks
- **Preprocessed tables** — commit to fixed tables once, reuse across proofs
- **Generic over field, hash, and PCS** — the protocol is parameterized by a
`StarkGenericConfig` (base field via the PCS, challenge field, challenger);
a batteries-included Goldilocks/Keccak instantiation is provided
- **Serialization** — `Proof::to_bytes` / `Proof::from_bytes` via bincode
- **Parallel proving** — opt-in via the `parallel` feature flag

## Cryptographic setup
## Reference configuration

The protocol (`system`, `prover`, `verifier` modules) is generic over
[`StarkGenericConfig`](src/config.rs). The crate ships one production
configuration, `GoldilocksKeccakConfig` in [`types`](src/types.rs):

| Component | Choice |
|-----------|-----------------------------------------------|
Expand All @@ -24,10 +31,22 @@ lookup arguments for shared state.
| Hash | Keccak-256 |
| PCS | FRI over Merkle trees |

A second instantiation (BabyBear field, degree-4 extension, Poseidon2
hashing) lives in the test suite to keep the protocol honest about its
genericity. When writing your own configuration, pick a challenge field
large enough for the target security level — the Schwartz-Zippel terms of
the soundness error scale with 1/|challenge field|.

Security level is configurable via `FriParameters`. With `log_blowup = 1` and
`num_queries = 100`, FRI provides ~2^(-100) soundness error. See the
`num_queries = 100`, FRI provides ~2^(-100) *conjectured* soundness error
(~2^(-50) under the proven Johnson bound). See the
[verifier module docs](src/verifier.rs) for the full soundness argument.

> :warning: **Not zero-knowledge.** Proofs are succinct arguments of
> knowledge, but traces are committed without blinding — FRI query responses
> reveal witness data. Do not use this when the witness must remain hidden
> from the verifier.

## Examples

**Minimal prove-and-verify** (no lookups):
Expand Down
71 changes: 36 additions & 35 deletions benches/multi_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use multi_stark::builder::symbolic::{SymbolicExpression, preprocessed_var, var};
use multi_stark::lookup::{Lookup, LookupAir};
use multi_stark::system::{System, SystemWitness};
use multi_stark::types::{CommitmentParameters, FriParameters, Val};
use multi_stark::types::{CommitmentParameters, FriParameters, GoldilocksKeccakConfig, Val};
use multi_stark::{
p3_air::{Air, AirBuilder, BaseAir, WindowAccess},
p3_field::{Field, PrimeCharacteristicRing},
Expand Down Expand Up @@ -127,7 +127,10 @@ impl U32CS {
// Witness generation
// ---------------------------------------------------------------------------

fn build_witness(num_adds: usize, system: &System<U32CS>) -> SystemWitness {
fn build_witness(
num_adds: usize,
system: &System<GoldilocksKeccakConfig, U32CS>,
) -> SystemWitness<Val> {
let byte_width = 1;
let add_width = 14;
let add_height = num_adds.next_power_of_two();
Expand Down Expand Up @@ -201,20 +204,22 @@ fn build_claims(num_adds: usize) -> Vec<[Val; 4]> {
// ---------------------------------------------------------------------------

fn bench_prove(c: &mut Criterion) {
let commitment_parameters = CommitmentParameters {
log_blowup: 1,
cap_height: 0,
};
let config = GoldilocksKeccakConfig::new(
CommitmentParameters {
log_blowup: 1,
cap_height: 0,
},
FriParameters {
log_final_poly_len: 0,
max_log_arity: 1,
num_queries: 100,
commit_proof_of_work_bits: 10,
query_proof_of_work_bits: 10,
},
);
let byte_table = LookupAir::new(U32CS::ByteTable, U32CS::ByteTable.lookups());
let u32_add = LookupAir::new(U32CS::U32Add, U32CS::U32Add.lookups());
let (system, key) = System::new(commitment_parameters, [byte_table, u32_add]);
let fri_parameters = FriParameters {
log_final_poly_len: 0,
max_log_arity: 1,
num_queries: 100,
commit_proof_of_work_bits: 10,
query_proof_of_work_bits: 10,
};
let (system, key) = System::new(config, [byte_table, u32_add]);

let mut group = c.benchmark_group("prove");
group.sample_size(10);
Expand All @@ -229,9 +234,7 @@ fn bench_prove(c: &mut Criterion) {
|b| {
b.iter_batched(
|| build_witness(num_adds, &system),
|witness| {
system.prove_multiple_claims(fri_parameters, &key, &claim_refs, witness)
},
|witness| system.prove_multiple_claims(&key, &claim_refs, witness),
criterion::BatchSize::LargeInput,
);
},
Expand All @@ -241,20 +244,22 @@ fn bench_prove(c: &mut Criterion) {
}

fn bench_verify(c: &mut Criterion) {
let commitment_parameters = CommitmentParameters {
log_blowup: 1,
cap_height: 0,
};
let config = GoldilocksKeccakConfig::new(
CommitmentParameters {
log_blowup: 1,
cap_height: 0,
},
FriParameters {
log_final_poly_len: 0,
max_log_arity: 1,
num_queries: 100,
commit_proof_of_work_bits: 10,
query_proof_of_work_bits: 10,
},
);
let byte_table = LookupAir::new(U32CS::ByteTable, U32CS::ByteTable.lookups());
let u32_add = LookupAir::new(U32CS::U32Add, U32CS::U32Add.lookups());
let (system, key) = System::new(commitment_parameters, [byte_table, u32_add]);
let fri_parameters = FriParameters {
log_final_poly_len: 0,
max_log_arity: 1,
num_queries: 100,
commit_proof_of_work_bits: 10,
query_proof_of_work_bits: 10,
};
let (system, key) = System::new(config, [byte_table, u32_add]);

let mut group = c.benchmark_group("verify");
group.sample_size(10);
Expand All @@ -265,15 +270,11 @@ fn bench_verify(c: &mut Criterion) {
let claims = build_claims(num_adds);
let claim_refs: Vec<&[Val]> = claims.iter().map(|c| c.as_slice()).collect();
let witness = build_witness(num_adds, &system);
let proof = system.prove_multiple_claims(fri_parameters, &key, &claim_refs, witness);
let proof = system.prove_multiple_claims(&key, &claim_refs, witness);
group.bench_function(
BenchmarkId::new("u32_add", format!("2^{log_height}")),
|b| {
b.iter(|| {
system
.verify_multiple_claims(fri_parameters, &claim_refs, &proof)
.unwrap()
});
b.iter(|| system.verify_multiple_claims(&claim_refs, &proof).unwrap());
},
);
}
Expand Down
32 changes: 17 additions & 15 deletions examples/lookup_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use multi_stark::builder::symbolic::{SymbolicExpression, var};
use multi_stark::lookup::{Lookup, LookupAir};
use multi_stark::system::{System, SystemWitness};
use multi_stark::types::{CommitmentParameters, FriParameters, Val};
use multi_stark::types::{CommitmentParameters, FriParameters, GoldilocksKeccakConfig, Val};
use multi_stark::{
p3_air::{Air, AirBuilder, BaseAir, WindowAccess},
p3_field::{Field, PrimeCharacteristicRing},
Expand Down Expand Up @@ -103,14 +103,23 @@ where
}

fn main() {
let commitment_parameters = CommitmentParameters {
log_blowup: 1,
cap_height: 0,
};
let config = GoldilocksKeccakConfig::new(
CommitmentParameters {
log_blowup: 1,
cap_height: 0,
},
FriParameters {
log_final_poly_len: 0,
max_log_arity: 1,
num_queries: 64,
commit_proof_of_work_bits: 0,
query_proof_of_work_bits: 0,
},
);

let even = LookupAir::new(ParityAir::Even, ParityAir::Even.lookups());
let odd = LookupAir::new(ParityAir::Odd, ParityAir::Odd.lookups());
let (system, key) = System::new(commitment_parameters, [even, odd]);
let (system, key) = System::new(config, [even, odd]);

let f = Val::from_u32;
#[rustfmt::skip]
Expand Down Expand Up @@ -142,16 +151,9 @@ fn main() {

// Claim: [even_index=0, input=4, expected_output=1] — is_even(4) should be 1
let claim = &[f(0), f(4), f(1)];
let fri_parameters = FriParameters {
log_final_poly_len: 0,
max_log_arity: 1,
num_queries: 64,
commit_proof_of_work_bits: 0,
query_proof_of_work_bits: 0,
};

let proof = system.prove(fri_parameters, &key, claim, witness);
system.verify(fri_parameters, claim, &proof).unwrap();
let proof = system.prove(&key, claim, witness);
system.verify(claim, &proof).unwrap();
println!("Lookup proof verified successfully!");

let bytes = proof.to_bytes().expect("serialization failed");
Expand Down
Loading