mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-08 16:53:07 +00:00
Further cleaning
This commit is contained in:
parent
61fcc9048e
commit
d7bdc75082
@ -75,7 +75,7 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
|
||||
common_data: &CommonCircuitData<F, C, D>,
|
||||
) -> anyhow::Result<Vec<usize>> {
|
||||
Ok(self
|
||||
.get_challenges(common_data)?
|
||||
.get_challenges(self.get_public_inputs_hash(), common_data)?
|
||||
.fri_challenges
|
||||
.fri_query_indices)
|
||||
}
|
||||
@ -83,6 +83,7 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
|
||||
/// Computes all Fiat-Shamir challenges used in the Plonk proof.
|
||||
pub(crate) fn get_challenges(
|
||||
&self,
|
||||
public_inputs_hash: <<C as GenericConfig<D>>::InnerHasher as Hasher<F>>::Hash,
|
||||
common_data: &CommonCircuitData<F, C, D>,
|
||||
) -> anyhow::Result<ProofChallenges<F, D>> {
|
||||
let Proof {
|
||||
@ -100,7 +101,7 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
|
||||
} = &self.proof;
|
||||
|
||||
get_challenges(
|
||||
self.get_public_inputs_hash(),
|
||||
public_inputs_hash,
|
||||
wires_cap,
|
||||
plonk_zs_partial_products_cap,
|
||||
quotient_polys_cap,
|
||||
@ -119,6 +120,7 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
|
||||
/// Computes all Fiat-Shamir challenges used in the Plonk proof.
|
||||
pub(crate) fn get_challenges(
|
||||
&self,
|
||||
public_inputs_hash: <<C as GenericConfig<D>>::InnerHasher as Hasher<F>>::Hash,
|
||||
common_data: &CommonCircuitData<F, C, D>,
|
||||
) -> anyhow::Result<ProofChallenges<F, D>> {
|
||||
let CompressedProof {
|
||||
@ -136,7 +138,7 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
|
||||
} = &self.proof;
|
||||
|
||||
get_challenges(
|
||||
self.get_public_inputs_hash(),
|
||||
public_inputs_hash,
|
||||
wires_cap,
|
||||
plonk_zs_partial_products_cap,
|
||||
quotient_polys_cap,
|
||||
@ -303,9 +305,6 @@ impl<const D: usize> ProofWithPublicInputsTarget<D> {
|
||||
},
|
||||
} = &self.proof;
|
||||
|
||||
let public_inputs_hash =
|
||||
builder.hash_n_to_hash_no_pad::<C::InnerHasher>(self.public_inputs.clone());
|
||||
|
||||
builder.get_challenges(
|
||||
public_inputs_hash,
|
||||
wires_cap,
|
||||
|
||||
@ -174,7 +174,7 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
|
||||
self,
|
||||
common_data: &CommonCircuitData<F, C, D>,
|
||||
) -> anyhow::Result<ProofWithPublicInputs<F, C, D>> {
|
||||
let challenges = self.get_challenges(common_data)?;
|
||||
let challenges = self.get_challenges(self.get_public_inputs_hash(), common_data)?;
|
||||
let fri_inferred_elements = self.get_inferred_elements(&challenges, common_data);
|
||||
let decompressed_proof =
|
||||
self.proof
|
||||
@ -190,16 +190,15 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
|
||||
verifier_data: &VerifierOnlyCircuitData<C, D>,
|
||||
common_data: &CommonCircuitData<F, C, D>,
|
||||
) -> anyhow::Result<()> {
|
||||
let challenges = self.get_challenges(common_data)?;
|
||||
let public_inputs_hash = self.get_public_inputs_hash();
|
||||
let challenges = self.get_challenges(public_inputs_hash, common_data)?;
|
||||
let fri_inferred_elements = self.get_inferred_elements(&challenges, common_data);
|
||||
let decompressed_proof =
|
||||
self.proof
|
||||
.decompress(&challenges, fri_inferred_elements, &common_data.fri_params);
|
||||
verify_with_challenges(
|
||||
ProofWithPublicInputs {
|
||||
public_inputs: self.public_inputs,
|
||||
proof: decompressed_proof,
|
||||
},
|
||||
decompressed_proof,
|
||||
public_inputs_hash,
|
||||
challenges,
|
||||
verifier_data,
|
||||
common_data,
|
||||
|
||||
@ -5,9 +5,9 @@ use plonky2_field::field_types::Field;
|
||||
use crate::fri::verifier::verify_fri_proof;
|
||||
use crate::hash::hash_types::RichField;
|
||||
use crate::plonk::circuit_data::{CommonCircuitData, VerifierOnlyCircuitData};
|
||||
use crate::plonk::config::GenericConfig;
|
||||
use crate::plonk::config::{GenericConfig, Hasher};
|
||||
use crate::plonk::plonk_common::reduce_with_powers;
|
||||
use crate::plonk::proof::{ProofChallenges, ProofWithPublicInputs};
|
||||
use crate::plonk::proof::{Proof, ProofChallenges, ProofWithPublicInputs};
|
||||
use crate::plonk::vanishing_poly::eval_vanishing_poly;
|
||||
use crate::plonk::vars::EvaluationVars;
|
||||
|
||||
@ -16,8 +16,19 @@ pub(crate) fn verify<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, c
|
||||
verifier_data: &VerifierOnlyCircuitData<C, D>,
|
||||
common_data: &CommonCircuitData<F, C, D>,
|
||||
) -> Result<()> {
|
||||
let challenges = proof_with_pis.get_challenges(common_data)?;
|
||||
verify_with_challenges(proof_with_pis, challenges, verifier_data, common_data)
|
||||
ensure!(
|
||||
proof_with_pis.public_inputs.len() == common_data.num_public_inputs,
|
||||
"Number of public inputs doesn't match circuit data."
|
||||
);
|
||||
let public_inputs_hash = proof_with_pis.get_public_inputs_hash();
|
||||
let challenges = proof_with_pis.get_challenges(public_inputs_hash, common_data)?;
|
||||
verify_with_challenges(
|
||||
proof_with_pis.proof,
|
||||
public_inputs_hash,
|
||||
challenges,
|
||||
verifier_data,
|
||||
common_data,
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn verify_with_challenges<
|
||||
@ -25,25 +36,18 @@ pub(crate) fn verify_with_challenges<
|
||||
C: GenericConfig<D, F = F>,
|
||||
const D: usize,
|
||||
>(
|
||||
proof_with_pis: ProofWithPublicInputs<F, C, D>,
|
||||
proof: Proof<F, C, D>,
|
||||
public_inputs_hash: <<C as GenericConfig<D>>::InnerHasher as Hasher<F>>::Hash,
|
||||
challenges: ProofChallenges<F, D>,
|
||||
verifier_data: &VerifierOnlyCircuitData<C, D>,
|
||||
common_data: &CommonCircuitData<F, C, D>,
|
||||
) -> Result<()> {
|
||||
ensure!(
|
||||
proof_with_pis.public_inputs.len() == common_data.num_public_inputs,
|
||||
"Number of public inputs doesn't match circuit data."
|
||||
);
|
||||
let public_inputs_hash = &proof_with_pis.get_public_inputs_hash();
|
||||
|
||||
let ProofWithPublicInputs { proof, .. } = proof_with_pis;
|
||||
|
||||
let local_constants = &proof.openings.constants;
|
||||
let local_wires = &proof.openings.wires;
|
||||
let vars = EvaluationVars {
|
||||
local_constants,
|
||||
local_wires,
|
||||
public_inputs_hash,
|
||||
public_inputs_hash: &public_inputs_hash,
|
||||
};
|
||||
let local_zs = &proof.openings.plonk_zs;
|
||||
let next_zs = &proof.openings.plonk_zs_right;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user