Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unified Recursion Circuit for Multi-Degree Starky Proof Verification #1635

Merged
merged 39 commits into from
Nov 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
56bc632
add test
sai-deng Oct 26, 2024
3d7c443
wip
sai-deng Oct 30, 2024
78d3851
update witness util
sai-deng Oct 30, 2024
b4213bb
degree_bits: usize->target
sai-deng Oct 31, 2024
fc46e07
wip
sai-deng Nov 1, 2024
99c3ccb
fix
sai-deng Nov 1, 2024
8561399
opt
sai-deng Nov 1, 2024
8ea1952
passed 3 tests
sai-deng Nov 1, 2024
c231038
fix
sai-deng Nov 1, 2024
cff4da4
convert g to g_ext
sai-deng Nov 1, 2024
13801e4
hack observe final poly coeffs
sai-deng Nov 2, 2024
de75e83
wip
sai-deng Nov 6, 2024
33836d5
poc works
sai-deng Nov 6, 2024
e685b9a
wip
sai-deng Nov 7, 2024
02548a0
pass tests
sai-deng Nov 7, 2024
c9ea54c
more in test
sai-deng Nov 7, 2024
999532c
better test
sai-deng Nov 8, 2024
9667294
fix ci
sai-deng Nov 8, 2024
773b695
clippy
sai-deng Nov 8, 2024
58196b8
fix
sai-deng Nov 8, 2024
dcd973d
fix
sai-deng Nov 8, 2024
b9c3365
start on multi steps
sai-deng Nov 9, 2024
1eb7053
wip
sai-deng Nov 9, 2024
d94800f
set all zeros
sai-deng Nov 9, 2024
104ed57
wip
sai-deng Nov 9, 2024
a6fbf7c
challenge passes
sai-deng Nov 10, 2024
6368726
work
sai-deng Nov 12, 2024
309ecaa
poc done
sai-deng Nov 12, 2024
de1c230
fix non std build
sai-deng Nov 12, 2024
9508927
add comments
sai-deng Nov 12, 2024
bafcf74
update stark verifier
sai-deng Nov 15, 2024
1e3c8b9
fix clippy
sai-deng Nov 15, 2024
f31babe
fix test build
sai-deng Nov 15, 2024
8572c81
fix tests
sai-deng Nov 15, 2024
93ba39c
add comments
sai-deng Nov 15, 2024
853acb4
add checks
sai-deng Nov 15, 2024
281d738
polish the checks
sai-deng Nov 15, 2024
1e32adf
more checks
sai-deng Nov 15, 2024
32314ea
comments
sai-deng Nov 22, 2024
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
Prev Previous commit
Next Next commit
more in test
  • Loading branch information
sai-deng committed Nov 7, 2024
commit c9ea54cb443ef099f5c61d13c186dd1d7b8a2be0
99 changes: 40 additions & 59 deletions starky/src/fibonacci_stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl<F: RichField + Extendable<D>, const D: usize> Stark<F, D> for FibonacciStar
#[cfg(test)]
mod tests {
use anyhow::Result;
use itertools::Itertools;
use plonky2::field::extension::Extendable;
use plonky2::field::types::Field;
use plonky2::hash::hash_types::RichField;
Expand Down Expand Up @@ -235,8 +236,6 @@ mod tests {
stark: S,
inner_proof: StarkProofWithPublicInputs<F, InnerC, D>,
inner_config: &StarkConfig,
degree_bits: usize,
min_degree_bits_to_support: Option<usize>,
print_gate_counts: bool,
) -> Result<()>
where
Expand All @@ -245,25 +244,12 @@ mod tests {
let circuit_config = CircuitConfig::standard_recursion_config();
let mut builder = CircuitBuilder::<F, D>::new(circuit_config);
let mut pw = PartialWitness::new();
let degree_bits = inner_proof.proof.recover_degree_bits(inner_config);
let pt =
add_virtual_stark_proof_with_pis(&mut builder, &stark, inner_config, degree_bits, 0, 0);
let proof_degree_bits = inner_proof.proof.recover_degree_bits(inner_config);
set_stark_proof_with_pis_target(
&mut pw,
&pt,
&inner_proof,
proof_degree_bits,
builder.zero(),
)?;
set_stark_proof_with_pis_target(&mut pw, &pt, &inner_proof, builder.zero())?;

verify_stark_proof_circuit::<F, InnerC, S, D>(
&mut builder,
stark,
pt,
inner_config,
degree_bits,
min_degree_bits_to_support,
);
verify_stark_proof_circuit::<F, InnerC, S, D>(&mut builder, stark, pt, inner_config);

if print_gate_counts {
builder.print_gate_counts(0);
Expand All @@ -283,49 +269,44 @@ mod tests {
init_logger();

let mut config = StarkConfig::standard_fast_config();
config.fri_config.num_query_rounds = 8;

let degree_bits0 = 7;
let degree_bits1 = 8;

// Test first STARK
let num_rows = 1 << degree_bits0;
let public_inputs = [F::ZERO, F::ONE, fibonacci(num_rows - 1, F::ZERO, F::ONE)];
let stark0 = S::new(num_rows);
let trace = stark0.generate_trace(public_inputs[0], public_inputs[1]);
let proof0 = prove::<F, C, S, D>(
stark0,
&config,
trace,
&public_inputs,
Some(degree_bits1),
&mut TimingTree::default(),
)?;
config.fri_config.num_query_rounds = 1;

let degree_bits = [7, 8, 9, 10];
let verifier_degree_bits = 10;

let proofs = degree_bits.iter().map(|degree_bits|{
let num_rows = 1 << degree_bits;
let public_inputs = [F::ZERO, F::ONE, fibonacci(num_rows - 1, F::ZERO, F::ONE)];
let stark = S::new(num_rows);
let trace = stark.generate_trace(public_inputs[0], public_inputs[1]);
prove::<F, C, S, D>(
stark,
&config,
trace,
&public_inputs,
Some(verifier_degree_bits),
&mut TimingTree::default(),
).unwrap()
}).collect();

// Generate the second STARK proof
let num_rows = 1 << verifier_degree_bits;
let stark = S::new(num_rows);

// Test second STARK
let num_rows = 1 << degree_bits1;
let public_inputs = [F::ZERO, F::ONE, fibonacci(num_rows - 1, F::ZERO, F::ONE)];
let stark1 = S::new(num_rows);
let trace = stark1.generate_trace(public_inputs[0], public_inputs[1]);
let proof1 = prove::<F, C, S, D>(
stark1,
&config,
trace,
&public_inputs,
None,
&mut TimingTree::default(),
)?;
verify_stark_proof(stark1, proof1.clone(), &config)?;
let circuit_config = CircuitConfig::standard_recursion_config();
let mut builder = CircuitBuilder::<F, D>::new(circuit_config);
let pt =
add_virtual_stark_proof_with_pis(&mut builder, &stark, &config, verifier_degree_bits, 0, 0);
verify_stark_proof_circuit::<F, C, S, D>(&mut builder, stark, pt, &config, verifier_degree_bits, Some(degree_bits[0]));
builder.print_gate_counts(0);

// Verify proof0 with the recursion circuit at different degree.
recursive_proof::<F, C, S, C, D>(
stark1,
proof0,
&config,
degree_bits1,
Some(degree_bits0),
true,
)?;
let data = builder.build::<C>();
degree_bits.iter().zip_eq(proofs).map(|(degree_bits, proof)|{
let mut pw = PartialWitness::new();
set_stark_proof_with_pis_target(&mut pw, &pt, &proof, degree_bits, builder.zero())?;
let proof = data.prove(pw)?;
data.verify(proof)?;
});
Ok(())
}
}