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

Make proof_with_pis a reference #828

Merged
merged 2 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion evm/src/recursive_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
.enumerate()
{
builder.verify_proof::<C>(
recursive_proof,
&recursive_proof,
&verifier_data_target,
&verifier_data[i].common,
);
Expand Down
9 changes: 5 additions & 4 deletions plonky2/examples/bench_recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,14 @@ where
{
let (inner_proof, inner_vd, inner_cd) = inner;
let mut builder = CircuitBuilder::<F, D>::new(config.clone());
let mut pw = PartialWitness::new();
let pt = builder.add_virtual_proof_with_pis::<InnerC>(inner_cd);
pw.set_proof_with_pis_target(&pt, inner_proof);

let inner_data = VerifierCircuitTarget {
constants_sigmas_cap: builder.add_virtual_cap(inner_cd.config.fri_config.cap_height),
circuit_digest: builder.add_virtual_hash(),
};
pw.set_verifier_data_target(&inner_data, inner_vd);

builder.verify_proof::<InnerC>(pt, &inner_data, inner_cd);
builder.verify_proof::<InnerC>(&pt, &inner_data, inner_cd);
builder.print_gate_counts(0);

if let Some(min_degree_bits) = min_degree_bits {
Expand All @@ -131,6 +128,10 @@ where

let data = builder.build::<C>();

let mut pw = PartialWitness::new();
pw.set_proof_with_pis_target(&pt, inner_proof);
pw.set_verifier_data_target(&inner_data, inner_vd);

let mut timing = TimingTree::new("prove", Level::Debug);
let proof = prove(&data.prover_only, &data.common, pw, &mut timing)?;
timing.print();
Expand Down
2 changes: 1 addition & 1 deletion plonky2/src/recursion/conditional_recursive_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
),
};

self.verify_proof::<C>(selected_proof, &selected_verifier_data, inner_common_data);
self.verify_proof::<C>(&selected_proof, &selected_verifier_data, inner_common_data);
}

/// Conditionally verify a proof with a new generated dummy proof.
Expand Down
4 changes: 2 additions & 2 deletions plonky2/src/recursion/cyclic_recursion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ mod tests {
constants_sigmas_cap: builder.add_virtual_cap(data.common.config.fri_config.cap_height),
circuit_digest: builder.add_virtual_hash(),
};
builder.verify_proof::<C>(proof, &verifier_data, &data.common);
builder.verify_proof::<C>(&proof, &verifier_data, &data.common);
let data = builder.build::<C>();

let config = CircuitConfig::standard_recursion_config();
Expand All @@ -308,7 +308,7 @@ mod tests {
constants_sigmas_cap: builder.add_virtual_cap(data.common.config.fri_config.cap_height),
circuit_digest: builder.add_virtual_hash(),
};
builder.verify_proof::<C>(proof, &verifier_data, &data.common);
builder.verify_proof::<C>(&proof, &verifier_data, &data.common);
while builder.num_gates() < 1 << 12 {
builder.add_gate(NoopGate, vec![]);
}
Expand Down
14 changes: 7 additions & 7 deletions plonky2/src/recursion/recursive_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
/// Recursively verifies an inner proof.
pub fn verify_proof<C: GenericConfig<D, F = F>>(
&mut self,
proof_with_pis: ProofWithPublicInputsTarget<D>,
proof_with_pis: &ProofWithPublicInputsTarget<D>,
inner_verifier_data: &VerifierCircuitTarget,
inner_common_data: &CommonCircuitData<F, D>,
) where
Expand All @@ -36,7 +36,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
);

self.verify_proof_with_challenges::<C>(
proof_with_pis.proof,
&proof_with_pis.proof,
public_inputs_hash,
challenges,
inner_verifier_data,
Expand All @@ -47,7 +47,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
/// Recursively verifies an inner proof.
fn verify_proof_with_challenges<C: GenericConfig<D, F = F>>(
&mut self,
proof: ProofTarget<D>,
proof: &ProofTarget<D>,
public_inputs_hash: HashOutTarget,
challenges: ProofChallengesTarget<D>,
inner_verifier_data: &VerifierCircuitTarget,
Expand Down Expand Up @@ -106,9 +106,9 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {

let merkle_caps = &[
inner_verifier_data.constants_sigmas_cap.clone(),
proof.wires_cap,
proof.plonk_zs_partial_products_cap,
proof.quotient_polys_cap,
proof.wires_cap.clone(),
proof.plonk_zs_partial_products_cap.clone(),
proof.quotient_polys_cap.clone(),
];

let fri_instance = inner_common_data.get_fri_instance_target(self, challenges.plonk_zeta);
Expand Down Expand Up @@ -376,7 +376,7 @@ mod tests {
);
pw.set_hash_target(inner_data.circuit_digest, inner_vd.circuit_digest);

builder.verify_proof::<InnerC>(pt, &inner_data, &inner_cd);
builder.verify_proof::<InnerC>(&pt, &inner_data, &inner_cd);

if print_gate_counts {
builder.print_gate_counts(0);
Expand Down