diff --git a/crates/prover/src/core/fri.rs b/crates/prover/src/core/fri.rs index 9b0632dbb..263b8c89e 100644 --- a/crates/prover/src/core/fri.rs +++ b/crates/prover/src/core/fri.rs @@ -193,7 +193,8 @@ impl<'a, B: FriOps + MerkleOps, MC: MerkleChannel> FriProver<'a, B, MC> { /// Builds and commits to the inner FRI layers (all layers except the first and last). /// - /// All `columns` must be provided in descending order by size. + /// All `columns` must be provided in descending order by size. Note there is at most one column + /// of each size. /// /// Returns all inner layers and the evaluation of the last layer. fn commit_inner_layers( @@ -214,20 +215,26 @@ impl<'a, B: FriOps + MerkleOps, MC: MerkleChannel> FriProver<'a, B, MC> { let mut layer_evaluation = LineEvaluation::new_zero(first_inner_layer_domain); let mut columns = columns.iter().peekable(); let mut layers = Vec::new(); - let mut folding_alpha = channel.draw_felt(); + let folding_alpha = channel.draw_felt(); + + // Folding the max size column. + B::fold_circle_into_line( + &mut layer_evaluation, + columns.next().unwrap(), + folding_alpha, + twiddles, + ); while layer_evaluation.len() > config.last_layer_domain_size() { - // Check for circle polys in the first layer that should be combined in this layer. - while let Some(column) = columns.next_if(|c| folded_size(c) == layer_evaluation.len()) { - B::fold_circle_into_line(&mut layer_evaluation, column, folding_alpha, twiddles); - } - let layer = FriInnerLayerProver::new(layer_evaluation); MC::mix_root(channel, layer.merkle_tree.root()); - folding_alpha = channel.draw_felt(); - let folded_layer_evaluation = B::fold_line(&layer.evaluation, folding_alpha, twiddles); + let folding_alpha = channel.draw_felt(); + layer_evaluation = B::fold_line(&layer.evaluation, folding_alpha, twiddles); - layer_evaluation = folded_layer_evaluation; + // Check for circle polys in the first layer that should be combined in this layer. + if let Some(column) = columns.next_if(|c| folded_size(c) == layer_evaluation.len()) { + B::fold_circle_into_line(&mut layer_evaluation, column, folding_alpha, twiddles); + } layers.push(layer); }