1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
use super::{ColMatrix, EvaluationFrame, FieldElement, TracePolyTable};
use crate::StarkDomain;
use air::{proof::Queries, TraceInfo, TraceLayout};
use alloc::vec::Vec;
use crypto::{ElementHasher, Hasher};
mod default;
pub use default::DefaultTraceLde;
// TRACE LOW DEGREE EXTENSION
// ================================================================================================
/// Contains all segments of the extended execution trace and their commitments.
///
/// Segments are stored in two groups:
/// - Main segment: this is the first trace segment generated by the prover. Values in this segment
/// will always be elements in the base field (even when an extension field is used).
/// - Auxiliary segments: a list of 0 or more segments for traces generated after the prover
/// commits to the first trace segment. Currently, at most 1 auxiliary segment is possible.
pub trait TraceLde<E: FieldElement>: Sync {
/// The hash function used for building the Merkle tree commitments to trace segment LDEs.
type HashFn: ElementHasher<BaseField = E::BaseField>;
/// Returns the commitment to the low-degree extension of the main trace segment.
fn get_main_trace_commitment(&self) -> <Self::HashFn as Hasher>::Digest;
/// Takes auxiliary trace segment columns as input, interpolates them into polynomials in
/// coefficient form, evaluates the polynomials over the LDE domain, and commits to the
/// polynomial evaluations.
///
/// Returns a tuple containing the column polynomials in coefficient form and the commitment
/// to the polynomial evaluations over the LDE domain.
///
/// # Panics
///
/// This function is expected to panic if any of the following are true:
/// - the number of rows in the provided `aux_trace` does not match the main trace.
/// - this segment would exceed the number of segments specified by the trace layout.
fn add_aux_segment(
&mut self,
aux_trace: &ColMatrix<E>,
domain: &StarkDomain<E::BaseField>,
) -> (ColMatrix<E>, <Self::HashFn as Hasher>::Digest);
/// Reads current and next rows from the main trace segment into the specified frame.
fn read_main_trace_frame_into(
&self,
lde_step: usize,
frame: &mut EvaluationFrame<E::BaseField>,
);
/// Reads current and next rows from the auxiliary trace segment into the specified frame.
fn read_aux_trace_frame_into(&self, lde_step: usize, frame: &mut EvaluationFrame<E>);
/// Returns trace table rows at the specified positions along with Merkle authentication paths
/// from the commitment root to these rows.
fn query(&self, positions: &[usize]) -> Vec<Queries>;
/// Returns the number of rows in the execution trace.
fn trace_len(&self) -> usize;
/// Returns blowup factor which was used to extend original execution trace into trace LDE.
fn blowup(&self) -> usize;
/// Returns the trace layout of the execution trace.
fn trace_layout(&self) -> &TraceLayout;
}