diff --git a/src/core/fri.rs b/src/core/fri.rs index dc49ccfa2..e5653d8be 100644 --- a/src/core/fri.rs +++ b/src/core/fri.rs @@ -20,7 +20,7 @@ use super::queries::{Queries, SparseSubCircleDomain}; use crate::commitment_scheme::hasher::Hasher; use crate::commitment_scheme::merkle_decommitment::MerkleDecommitment; use crate::commitment_scheme::merkle_tree::MerkleTree; -use crate::core::backend::{Col, Column}; +use crate::core::backend::Column; use crate::core::circle::Coset; use crate::core::fft::ibutterfly; use crate::core::poly::line::LineDomain; @@ -76,7 +76,7 @@ impl FriConfig { pub struct FriProver { config: FriConfig, inner_layers: Vec>, - last_layer_poly: LinePoly, + last_layer_coeffs: Vec, /// Unique sizes of committed columns sorted in descending order. column_log_sizes: Vec, } @@ -115,7 +115,7 @@ impl> FriProver { assert!(columns.iter().all(|e| e.domain.is_canonic()), "not canonic"); let (inner_layers, last_layer_evaluation) = Self::commit_inner_layers(channel, config, columns); - let last_layer_poly = Self::commit_last_layer(channel, config, last_layer_evaluation); + let last_layer_coeffs = Self::commit_last_layer(channel, config, last_layer_evaluation); let column_log_sizes = columns .iter() @@ -125,7 +125,7 @@ impl> FriProver { Self { config, inner_layers, - last_layer_poly, + last_layer_coeffs, column_log_sizes, } } @@ -196,21 +196,22 @@ impl> FriProver { channel: &mut impl Channel, config: FriConfig, evaluation: LineEvaluation, - ) -> LinePoly { + ) -> Vec { assert_eq!(evaluation.len(), config.last_layer_domain_size()); let evaluation = evaluation.bit_reverse(); - let mut coeffs = evaluation.interpolate().into_ordered_coefficients(); + let mut coeffs = evaluation + .interpolate() + .into_ordered_coefficients() + .to_vec(); let last_layer_degree_bound = 1 << config.log_last_layer_degree_bound; let zeros = coeffs.split_off(last_layer_degree_bound); assert!(zeros.iter().all(SecureField::is_zero), "invalid degree"); - let last_layer_poly = LinePoly::from_ordered_coefficients(coeffs); - let last_layer_coeffs: &Col = &last_layer_poly.coeffs; - channel.mix_felts(&last_layer_coeffs.to_vec()); + channel.mix_felts(&coeffs); - last_layer_poly + coeffs } /// Samples queries and decommits on them. Returns the FRI proof and the positions of the value @@ -243,11 +244,9 @@ impl> FriProver { }) .collect(); - let last_layer_poly = self.last_layer_poly; - FriProof { inner_layers, - last_layer_poly, + last_layer_coeffs: self.last_layer_coeffs, } } } @@ -330,13 +329,13 @@ impl> FriVerifier { } let last_layer_domain = layer_domain; - let last_layer_poly = proof.last_layer_poly; + let last_layer_coeffs = proof.last_layer_coeffs; - if last_layer_poly.len() > (1 << config.log_last_layer_degree_bound) { + if last_layer_coeffs.len() > (1 << config.log_last_layer_degree_bound) { return Err(VerificationError::LastLayerDegreeInvalid); } - channel.mix_felts(&last_layer_poly.coeffs); + channel.mix_felts(&last_layer_coeffs); Ok(Self { config, @@ -345,7 +344,7 @@ impl> FriVerifier { expected_query_log_domain_size, inner_layers, last_layer_domain, - last_layer_poly, + last_layer_poly: LinePoly::from_ordered_coefficients(last_layer_coeffs), queries: None, }) } @@ -511,7 +510,7 @@ pub trait FriChannel { fn reseed_with_inner_layer(&mut self, commitment: &Self::Digest); /// Reseeds the channel with the FRI last layer polynomial. - fn reseed_with_last_layer(&mut self, last_layer: &LinePoly); + fn reseed_with_last_layer(&mut self, last_layer: &[Self::Field]); /// Draws a random field element. fn draw(&mut self) -> Self::Field; @@ -582,7 +581,7 @@ impl LinePolyDegreeBound { /// A FRI proof. pub struct FriProof { pub inner_layers: Vec>, - pub last_layer_poly: LinePoly, + pub last_layer_coeffs: Vec, } /// Number of folds for univariate polynomials. @@ -964,7 +963,7 @@ mod tests { CIRCLE_TO_LINE_FOLD_STEP, }; use crate::core::poly::circle::{CircleDomain, CircleEvaluation}; - use crate::core::poly::line::{LineDomain, LineEvaluation, LinePoly}; + use crate::core::poly::line::{LineDomain, LineEvaluation}; use crate::core::poly::{BitReversedOrder, NaturalOrder}; use crate::core::queries::{Queries, SparseSubCircleDomain}; @@ -1192,7 +1191,7 @@ mod tests { let bound = vec![CirclePolyDegreeBound::new(LOG_DEGREE)]; let mut proof = prover.decommit_on_queries(&queries); let bad_last_layer_coeffs = vec![One::one(); 1 << (LOG_MAX_LAST_LAYER_DEGREE + 1)]; - proof.last_layer_poly = LinePoly::new(bad_last_layer_coeffs); + proof.last_layer_coeffs = bad_last_layer_coeffs; let verifier = FriVerifier::commit(&mut test_channel(), config, proof, bound); @@ -1214,7 +1213,7 @@ mod tests { let bound = vec![CirclePolyDegreeBound::new(LOG_DEGREE)]; let mut proof = prover.decommit_on_queries(&queries); // Compromise the last layer polynomial's first coefficient. - proof.last_layer_poly.coeffs[0] += BaseField::one(); + proof.last_layer_coeffs[0] += BaseField::one(); let verifier = FriVerifier::commit(&mut test_channel(), config, proof, bound).unwrap(); let verification_result = verifier.decommit_on_queries(&queries, vec![decommitment_value]);