mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-08 08:43:06 +00:00
Merge pull request #464 from mir-protocol/observe_fri_openings
Replace `observe_opening_set` by `observe_openings` taking a `FriOpenings`
This commit is contained in:
commit
c1d519806d
@ -146,7 +146,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
// Size of the LDE domain.
|
||||
let n = params.lde_size();
|
||||
|
||||
challenger.observe_opening_set(os);
|
||||
challenger.observe_openings(&os.to_fri_openings());
|
||||
|
||||
// Scaling factor to combine polynomials.
|
||||
let alpha = challenger.get_extension_challenge(self);
|
||||
|
||||
@ -5,6 +5,7 @@ use plonky2_field::extension_field::{Extendable, FieldExtension};
|
||||
use plonky2_field::polynomial::PolynomialCoeffs;
|
||||
|
||||
use crate::fri::proof::FriChallenges;
|
||||
use crate::fri::structure::{FriOpenings, FriOpeningsTarget};
|
||||
use crate::fri::FriConfig;
|
||||
use crate::hash::hash_types::RichField;
|
||||
use crate::hash::hash_types::{HashOut, HashOutTarget, MerkleCapTarget};
|
||||
@ -14,7 +15,6 @@ use crate::iop::ext_target::ExtensionTarget;
|
||||
use crate::iop::target::Target;
|
||||
use crate::plonk::circuit_builder::CircuitBuilder;
|
||||
use crate::plonk::config::{AlgebraicHasher, GenericConfig, GenericHashOut, Hasher};
|
||||
use crate::plonk::proof::{OpeningSet, OpeningSetTarget};
|
||||
|
||||
/// Observes prover messages, and generates challenges by hashing the transcript, a la Fiat-Shamir.
|
||||
#[derive(Clone)]
|
||||
@ -72,29 +72,12 @@ impl<F: RichField, H: Hasher<F>> Challenger<F, H> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn observe_opening_set<const D: usize>(&mut self, os: &OpeningSet<F, D>)
|
||||
pub fn observe_openings<const D: usize>(&mut self, openings: &FriOpenings<F, D>)
|
||||
where
|
||||
F: RichField + Extendable<D>,
|
||||
{
|
||||
let OpeningSet {
|
||||
constants,
|
||||
plonk_sigmas,
|
||||
wires,
|
||||
plonk_zs,
|
||||
plonk_zs_right,
|
||||
partial_products,
|
||||
quotient_polys,
|
||||
} = os;
|
||||
for v in &[
|
||||
constants,
|
||||
plonk_sigmas,
|
||||
wires,
|
||||
plonk_zs,
|
||||
plonk_zs_right,
|
||||
partial_products,
|
||||
quotient_polys,
|
||||
] {
|
||||
self.observe_extension_elements(v);
|
||||
for v in &openings.batches {
|
||||
self.observe_extension_elements(&v.values);
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,26 +252,9 @@ impl<F: RichField + Extendable<D>, H: AlgebraicHasher<F>, const D: usize>
|
||||
}
|
||||
}
|
||||
|
||||
pub fn observe_opening_set(&mut self, os: &OpeningSetTarget<D>) {
|
||||
let OpeningSetTarget {
|
||||
constants,
|
||||
plonk_sigmas,
|
||||
wires,
|
||||
plonk_zs,
|
||||
plonk_zs_right,
|
||||
partial_products,
|
||||
quotient_polys,
|
||||
} = os;
|
||||
for v in &[
|
||||
constants,
|
||||
plonk_sigmas,
|
||||
wires,
|
||||
plonk_zs,
|
||||
plonk_zs_right,
|
||||
partial_products,
|
||||
quotient_polys,
|
||||
] {
|
||||
self.observe_extension_elements(v);
|
||||
pub fn observe_openings(&mut self, openings: &FriOpeningsTarget<D>) {
|
||||
for v in &openings.batches {
|
||||
self.observe_extension_elements(&v.values);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ fn get_challenges<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, cons
|
||||
challenger.observe_cap(quotient_polys_cap);
|
||||
let plonk_zeta = challenger.get_extension_challenge::<D>();
|
||||
|
||||
challenger.observe_opening_set(openings);
|
||||
challenger.observe_openings(&openings.to_fri_openings());
|
||||
|
||||
Ok(ProofChallenges {
|
||||
plonk_betas,
|
||||
|
||||
@ -196,7 +196,7 @@ pub(crate) fn prove<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, co
|
||||
common_data,
|
||||
)
|
||||
);
|
||||
challenger.observe_opening_set(&openings);
|
||||
challenger.observe_openings(&openings.to_fri_openings());
|
||||
|
||||
let opening_proof = timed!(
|
||||
timing,
|
||||
|
||||
@ -33,7 +33,7 @@ fn get_challenges<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, cons
|
||||
challenger.observe_cap(quotient_polys_cap);
|
||||
let stark_zeta = challenger.get_extension_challenge::<D>();
|
||||
|
||||
openings.observe(&mut challenger);
|
||||
challenger.observe_openings(&openings.to_fri_openings());
|
||||
|
||||
Ok(StarkProofChallenges {
|
||||
stark_alphas,
|
||||
|
||||
@ -4,8 +4,7 @@ use plonky2::fri::proof::{CompressedFriProof, FriChallenges, FriProof};
|
||||
use plonky2::fri::structure::{FriOpeningBatch, FriOpenings};
|
||||
use plonky2::hash::hash_types::RichField;
|
||||
use plonky2::hash::merkle_tree::MerkleCap;
|
||||
use plonky2::iop::challenger::Challenger;
|
||||
use plonky2::plonk::config::{GenericConfig, Hasher};
|
||||
use plonky2::plonk::config::GenericConfig;
|
||||
use rayon::prelude::*;
|
||||
|
||||
pub struct StarkProof<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize> {
|
||||
@ -92,27 +91,6 @@ impl<F: RichField + Extendable<D>, const D: usize> StarkOpeningSet<F, D> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Replace with a `observe_fri_openings` function.
|
||||
// Note: Can't implement this directly on `Challenger` as it's in a different crate.
|
||||
pub fn observe<H: Hasher<F>>(&self, challenger: &mut Challenger<F, H>) {
|
||||
let StarkOpeningSet {
|
||||
local_values,
|
||||
next_values,
|
||||
permutation_zs,
|
||||
permutation_zs_right,
|
||||
quotient_polys,
|
||||
} = self;
|
||||
for v in &[
|
||||
local_values,
|
||||
next_values,
|
||||
permutation_zs,
|
||||
permutation_zs_right,
|
||||
quotient_polys,
|
||||
] {
|
||||
challenger.observe_extension_elements(v);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn to_fri_openings(&self) -> FriOpenings<F, D> {
|
||||
let zeta_batch = FriOpeningBatch {
|
||||
values: [
|
||||
|
||||
@ -113,7 +113,7 @@ where
|
||||
"Opening point is in the subgroup."
|
||||
);
|
||||
let openings = StarkOpeningSet::new(zeta, g, &trace_commitment, "ient_commitment);
|
||||
openings.observe(&mut challenger);
|
||||
challenger.observe_openings(&openings.to_fri_openings());
|
||||
|
||||
// TODO: Add permuation checks
|
||||
let initial_merkle_trees = &[&trace_commitment, "ient_commitment];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user