From 336b0fa1dee449a2caaca9254851cf7f93002a3d Mon Sep 17 00:00:00 2001 From: Irakliy Khaburzaniya Date: Tue, 12 Apr 2022 10:16:22 -0700 Subject: [PATCH] addressed comments --- air/src/air/boundary/constraint_group.rs | 2 +- air/src/air/boundary/mod.rs | 2 +- air/src/air/context.rs | 4 ++-- air/src/air/mod.rs | 15 +++++++-------- air/src/air/trace_info.rs | 2 +- prover/src/constraints/boundary.rs | 3 +-- prover/src/constraints/evaluator.rs | 2 +- prover/src/lib.rs | 2 +- prover/src/trace/commitment.rs | 2 +- prover/src/trace/mod.rs | 18 +++++++++--------- verifier/src/lib.rs | 8 ++++---- winterfell/src/lib.rs | 8 ++++---- 12 files changed, 33 insertions(+), 35 deletions(-) diff --git a/air/src/air/boundary/constraint_group.rs b/air/src/air/boundary/constraint_group.rs index c33f9897f..9cc296ad7 100644 --- a/air/src/air/boundary/constraint_group.rs +++ b/air/src/air/boundary/constraint_group.rs @@ -27,7 +27,7 @@ use super::{ /// * `F` could be the base field of the protocol, in which case `E` is the extension field used. /// * `F` could be the extension field, in which case `F` and `E` are the same type. /// -/// The above arrangement allows use to describe boundary constraints for main and auxiliary +/// The above arrangement allows us to describe boundary constraints for main and auxiliary /// segments of the execution trace. Specifically: /// * For the constraints against columns of the main execution trace, `F` is set to the base field /// of the protocol, and `E` is set to the extension field. diff --git a/air/src/air/boundary/mod.rs b/air/src/air/boundary/mod.rs index c4ecd22e2..1df700f8b 100644 --- a/air/src/air/boundary/mod.rs +++ b/air/src/air/boundary/mod.rs @@ -86,7 +86,7 @@ impl BoundaryConstraints { let main_trace_width = context.trace_info.layout().main_trace_width(); let aux_trace_width = context.trace_info.layout().aux_trace_width(); - // make sure the assertions are valid in he context of their respective trace segments; + // make sure the assertions are valid in the context of their respective trace segments; // also, sort the assertions in the deterministic order so that changing the order of // assertions does not change random coefficients that get assigned to them. let main_assertions = prepare_assertions(main_assertions, main_trace_width, trace_length); diff --git a/air/src/air/context.rs b/air/src/air/context.rs index 03daad559..2c6ff6935 100644 --- a/air/src/air/context.rs +++ b/air/src/air/context.rs @@ -37,10 +37,10 @@ impl AirContext { /// # Panics /// Panics if /// * `transition_constraint_degrees` is an empty vector. - /// * `num_main_assertions` is zero. + /// * `num_assertions` is zero. /// * Blowup factor specified by the provided `options` is too small to accommodate degrees /// of the specified transition constraints. - /// * `trace_info` describes an multi-segment execution trace. + /// * `trace_info` describes a multi-segment execution trace. pub fn new( trace_info: TraceInfo, transition_constraint_degrees: Vec, diff --git a/air/src/air/mod.rs b/air/src/air/mod.rs index 771f352df..8a5389938 100644 --- a/air/src/air/mod.rs +++ b/air/src/air/mod.rs @@ -198,17 +198,17 @@ pub trait Air: Send + Sync { /// Evaluates transition constraints over the specified evaluation frames for the main and /// auxiliary trace segments. /// - /// The evaluations should be written into the `results` slice in the same order as the - /// the order of auxiliary transition constraint degree descriptors used to instantiate - /// [AirContext] for this AIR. Thus, the length of the `result` slice will equal to the number - /// of auxiliary transition constraints defined for this computation. + /// The evaluations should be written into the `results` slice in the same order as the order + /// of auxiliary transition constraint degree descriptors used to instantiate [AirContext] for + /// this AIR. Thus, the length of the `result` slice will equal to the number of auxiliary + /// transition constraints defined for this computation. /// /// The default implementation of this function panics. It must be overridden for AIRs /// describing computations which require multiple trace segments. /// /// The types for main and auxiliary trace evaluation frames are defined as follows: /// * When the entire protocol is executed in a prime field, types `F` and `E` are the same, - /// and thus, both the main and the auxiliary trace frames are defined over the base filed. + /// and thus, both the main and the auxiliary trace frames are defined over the base field. /// * When the protocol is executed in an extension field, the main trace frame is defined /// over the base field, while the auxiliary trace frame is defined over the extension field. /// @@ -227,8 +227,7 @@ pub trait Air: Send + Sync { periodic_values: &[F], aux_rand_elements: &AuxTraceRandElements, result: &mut [E], - ) -> Vec> - where + ) where F: FieldElement, E: FieldElement + ExtensionOf, { @@ -325,7 +324,7 @@ pub trait Air: Send + Sync { /// Convert assertions returned from [get_assertions()](Air::get_assertions) and /// [get_aux_assertions()](Air::get_aux_assertions) methods into boundary constraints. /// - /// This function also assign composition coefficients to each constraint, and group the + /// This function also assigns composition coefficients to each constraint, and groups the /// constraints by their divisors. The coefficients will be used to compute random linear /// combination of boundary constraints during constraint merging. fn get_boundary_constraints>( diff --git a/air/src/air/trace_info.rs b/air/src/air/trace_info.rs index ea1f70af1..a5c533251 100644 --- a/air/src/air/trace_info.rs +++ b/air/src/air/trace_info.rs @@ -226,7 +226,7 @@ impl TraceLayout { // PUBLIC ACCESSORS // -------------------------------------------------------------------------------------------- - /// Returns the number of column in the main segment of an execution trace. + /// Returns the number of columns in the main segment of an execution trace. /// /// This is guaranteed to be between 1 and 255. pub fn main_trace_width(&self) -> usize { diff --git a/prover/src/constraints/boundary.rs b/prover/src/constraints/boundary.rs index 008d5d098..32a104140 100644 --- a/prover/src/constraints/boundary.rs +++ b/prover/src/constraints/boundary.rs @@ -422,8 +422,7 @@ where .iter() .rev() .fold(F::ZERO, |acc, &coeff| acc.mul_base(x) + coeff); - - //let assertion_value = polynom::eval(&self.poly, x); + // evaluate the constraint let evaluation = state[self.column] - assertion_value; (self.coefficients.0 + self.coefficients.1.mul_base(xp)).mul_base(evaluation) } diff --git a/prover/src/constraints/evaluator.rs b/prover/src/constraints/evaluator.rs index 0cbbcd9e3..31a0e201e 100644 --- a/prover/src/constraints/evaluator.rs +++ b/prover/src/constraints/evaluator.rs @@ -90,7 +90,7 @@ impl<'a, A: Air, E: FieldElement> ConstraintEvaluator< // allocate space for constraint evaluations; when we are in debug mode, we also allocate // memory to hold all transition constraint evaluations (before they are merged into a - // single value) so that we can check their degrees late + // single value) so that we can check their degrees later #[cfg(not(debug_assertions))] let mut evaluation_table = ConstraintEvaluationTable::::new(domain, divisors); #[cfg(debug_assertions)] diff --git a/prover/src/lib.rs b/prover/src/lib.rs index c95ff886e..58ab53d13 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -47,7 +47,7 @@ pub use air::{ proof::StarkProof, Air, AirContext, Assertion, AuxTraceRandElements, BoundaryConstraint, BoundaryConstraintGroup, ConstraintCompositionCoefficients, ConstraintDivisor, DeepCompositionCoefficients, EvaluationFrame, FieldExtension, HashFunction, ProofOptions, - TraceInfo, TransitionConstraintDegree, TransitionConstraintGroup, + TraceInfo, TraceLayout, TransitionConstraintDegree, TransitionConstraintGroup, }; pub use utils::{ iterators, ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable, diff --git a/prover/src/trace/commitment.rs b/prover/src/trace/commitment.rs index a86be00d0..3924da00d 100644 --- a/prover/src/trace/commitment.rs +++ b/prover/src/trace/commitment.rs @@ -16,7 +16,7 @@ use super::TraceLde; /// Execution trace commitment. /// -/// The described one or more trace segments, each consisting of the following components: +/// The describes one or more trace segments, each consisting of the following components: /// * Evaluations of a trace segment's polynomials over the LDE domain. /// * Merkle tree where each leaf in the tree corresponds to a row in the trace LDE matrix. pub struct TraceCommitment> { diff --git a/prover/src/trace/mod.rs b/prover/src/trace/mod.rs index b8de8096f..10184df47 100644 --- a/prover/src/trace/mod.rs +++ b/prover/src/trace/mod.rs @@ -71,6 +71,14 @@ pub trait Trace: Sized { where E: FieldElement; + /// Reads an evaluation frame from the main trace segment at the specified row. + fn read_main_frame(&self, row_idx: usize, frame: &mut EvaluationFrame); + + /// Reads an evaluation frame from auxiliary trace segments at the specified row. + fn read_aux_frame(&self, row_idx: usize, frame: &mut EvaluationFrame) + where + E: FieldElement; + // PROVIDED METHODS // -------------------------------------------------------------------------------------------- @@ -86,17 +94,9 @@ pub trait Trace: Sized { /// Returns the number of columns in all auxiliary trace segments. fn aux_trace_width(&self) -> usize { - self.layout().main_trace_width() + self.layout().aux_trace_width() } - /// Reads an evaluation frame from the main trace segment at the specified row. - fn read_main_frame(&self, row_idx: usize, frame: &mut EvaluationFrame); - - /// Reads an evaluation frame from auxiliary trace segments at the specified row. - fn read_aux_frame(&self, row_idx: usize, frame: &mut EvaluationFrame) - where - E: FieldElement; - // VALIDATION // -------------------------------------------------------------------------------------------- /// Checks if this trace is valid against the specified AIR, and panics if not. diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index d6de1ad6b..e991ac595 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -178,12 +178,12 @@ where H: ElementHasher, { // 1 ----- trace commitment ------------------------------------------------------------------- - // read the commitments to evaluations of the trace polynomials over the LDE domain sent by the - // prover. the commitments are used to update the public coin, and draw sets of random elements + // Read the commitments to evaluations of the trace polynomials over the LDE domain sent by the + // prover. The commitments are used to update the public coin, and draw sets of random elements // from the coin (in the interactive version of the protocol the verifier sends these random - // elements to the prover after each commitment is made). when there are multiple trace + // elements to the prover after each commitment is made). When there are multiple trace // commitments (i.e., the trace consists of more than one segment), each previous commitment is - // used to draw random elements needed to construct the next trace segment. the last trace + // used to draw random elements needed to construct the next trace segment. The last trace // commitment is used to draw a set of random coefficients which the prover uses to compute // constraint composition polynomial. let trace_commitments = channel.read_trace_commitments(); diff --git a/winterfell/src/lib.rs b/winterfell/src/lib.rs index be8bd5e72..6a3ac223b 100644 --- a/winterfell/src/lib.rs +++ b/winterfell/src/lib.rs @@ -526,11 +526,11 @@ #![cfg_attr(not(feature = "std"), no_std)] pub use prover::{ - crypto, iterators, math, Air, AirContext, Assertion, BoundaryConstraint, + crypto, iterators, math, Air, AirContext, Assertion, AuxTraceRandElements, BoundaryConstraint, BoundaryConstraintGroup, ByteReader, ByteWriter, ConstraintCompositionCoefficients, ConstraintDivisor, DeepCompositionCoefficients, Deserializable, DeserializationError, - EvaluationFrame, FieldExtension, HashFunction, ProofOptions, Prover, ProverError, Serializable, - StarkProof, Trace, TraceInfo, TraceTable, TraceTableFragment, TransitionConstraintDegree, - TransitionConstraintGroup, + EvaluationFrame, FieldExtension, HashFunction, Matrix, ProofOptions, Prover, ProverError, + Serializable, StarkProof, Trace, TraceInfo, TraceLayout, TraceTable, TraceTableFragment, + TransitionConstraintDegree, TransitionConstraintGroup, }; pub use verifier::{verify, VerifierError};