55
66use alloc:: vec:: Vec ;
77
8- use crypto:: ElementHasher ;
98use math:: FieldElement ;
109use utils:: {
1110 ByteReader , ByteWriter , Deserializable , DeserializationError , Serializable , SliceReader ,
@@ -38,8 +37,7 @@ impl OodFrame {
3837 // UPDATERS
3938 // --------------------------------------------------------------------------------------------
4039
41- /// Updates the trace state portion of this out-of-domain frame, and returns the hash of the
42- /// trace states.
40+ /// Updates the trace state portion of this out-of-domain frame.
4341 ///
4442 /// The out-of-domain frame is stored as one vector built from the concatenation of values of
4543 /// two vectors, the current row vector and the next row vector. Given the input frame
@@ -58,10 +56,9 @@ impl OodFrame {
5856 ///
5957 /// # Panics
6058 /// Panics if evaluation frame has already been set.
61- pub fn set_trace_states < E , H > ( & mut self , trace_ood_frame : & TraceOodFrame < E > ) -> H :: Digest
59+ pub fn set_trace_states < E > ( & mut self , trace_ood_frame : & TraceOodFrame < E > )
6260 where
6361 E : FieldElement ,
64- H : ElementHasher < BaseField = E :: BaseField > ,
6562 {
6663 assert ! ( self . trace_states. is_empty( ) , "trace sates have already been set" ) ;
6764
@@ -72,8 +69,6 @@ impl OodFrame {
7269 let frame_size: u8 = 2 ;
7370 self . trace_states . write_u8 ( frame_size) ;
7471 self . trace_states . write_many ( & main_and_aux_trace_states) ;
75-
76- H :: hash_elements ( & main_and_aux_trace_states)
7772 }
7873
7974 /// Updates constraints composition polynomials (i.e., quotient polynomials) state portion of
@@ -97,13 +92,9 @@ impl OodFrame {
9792 /// # Panics
9893 /// Panics if:
9994 /// * Constraint evaluations have already been set.
100- pub fn set_quotient_states < E , H > (
101- & mut self ,
102- quotients_ood_frame : & QuotientOodFrame < E > ,
103- ) -> H :: Digest
95+ pub fn set_quotient_states < E > ( & mut self , quotients_ood_frame : & QuotientOodFrame < E > )
10496 where
10597 E : FieldElement ,
106- H : ElementHasher < BaseField = E :: BaseField > ,
10798 {
10899 assert ! ( self . quotient_states. is_empty( ) , "constraint evaluations have already been set" ) ;
109100
@@ -114,8 +105,6 @@ impl OodFrame {
114105 let frame_size: u8 = 2 ;
115106 self . quotient_states . write_u8 ( frame_size) ;
116107 self . quotient_states . write_many ( & quotient_states) ;
117-
118- H :: hash_elements ( & quotient_states)
119108 }
120109
121110 // PARSER
@@ -281,22 +270,14 @@ impl<E: FieldElement> TraceOodFrame<E> {
281270 }
282271 }
283272
284- /// Hashes the main, auxiliary frames in a manner consistent with
285- /// [`OodFrame::set_trace_states`], with the purpose of reseeding the public coin.
286- pub fn hash < H : ElementHasher < BaseField = E :: BaseField > > ( & self ) -> H :: Digest {
287- let trace_states = self . to_trace_states ( ) ;
288-
289- H :: hash_elements ( & trace_states)
290- }
291-
292273 /// Returns true if an auxiliary frame is present
293274 fn has_aux_frame ( & self ) -> bool {
294275 self . current_row . len ( ) > self . main_trace_width
295276 }
296277
297278 /// Returns the main/aux frames as a vector of elements described in
298279 /// [`OodFrame::set_trace_states`].
299- fn to_trace_states ( & self ) -> Vec < E > {
280+ pub fn to_trace_states ( & self ) -> Vec < E > {
300281 let mut main_and_aux_frame_states = Vec :: new ( ) ;
301282 main_and_aux_frame_states. extend_from_slice ( & self . current_row ) ;
302283 main_and_aux_frame_states. extend_from_slice ( & self . next_row ) ;
@@ -335,19 +316,36 @@ impl<E: FieldElement> QuotientOodFrame<E> {
335316 & self . next_row
336317 }
337318
338- /// Hashes the frame with the purpose of reseeding the public coin.
339- pub fn hash < H : ElementHasher < BaseField = E :: BaseField > > ( & self ) -> H :: Digest {
340- let trace_states = self . to_trace_states ( ) ;
341-
342- H :: hash_elements ( & trace_states)
343- }
344-
345319 /// Returns the frame as a vector of elements.
346- fn to_trace_states ( & self ) -> Vec < E > {
320+ pub fn to_trace_states ( & self ) -> Vec < E > {
347321 let mut quotients_frame_states = Vec :: new ( ) ;
348322 quotients_frame_states. extend_from_slice ( & self . current_row ) ;
349323 quotients_frame_states. extend_from_slice ( & self . next_row ) ;
350324
351325 quotients_frame_states
352326 }
353327}
328+
329+ // HELPER
330+ // ================================================================================================
331+
332+ /// Given trace and constraints polynomials OOD evaluations, returns the vector containing their
333+ /// concatenation, with the evaluations at `z` grouped together and coming first and followed
334+ /// by the evaluations at `z * g`.
335+ pub fn merge_ood_evaluations < E > (
336+ trace_ood_frame : & TraceOodFrame < E > ,
337+ constraints_ood_frame : & QuotientOodFrame < E > ,
338+ ) -> Vec < E >
339+ where
340+ E : FieldElement ,
341+ {
342+ let mut current_row = trace_ood_frame. current_row ( ) . to_vec ( ) ;
343+ current_row. extend_from_slice ( constraints_ood_frame. current_row ( ) ) ;
344+ let mut next_row = trace_ood_frame. next_row ( ) . to_vec ( ) ;
345+ next_row. extend_from_slice ( constraints_ood_frame. next_row ( ) ) ;
346+
347+ let mut ood_evals = current_row;
348+ ood_evals. extend_from_slice ( & next_row) ;
349+
350+ ood_evals
351+ }
0 commit comments