mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-10 01:33:07 +00:00
* Halo2 style lookup arguments in System Zero It's a really nice and simple protocol, particularly for the verifier since the constraints are trivial (aside from the underlying batched permutation checks, which we already support). See the [Halo2 book](https://zcash.github.io/halo2/design/proving-system/lookup.html) and this [talk](https://www.youtube.com/watch?v=YlTt12s7vGE&t=5237s) by @daira. Previously we generated the whole trace in row-wise form, but it's much more efficient to generate these "permuted" columns column-wise. So I changed our STARK framework to accept the trace in column-wise form. STARK impls now have the flexibility to do some generation row-wise and some column-wise (without extra costs; there's a single transpose as before). * sorting * fixes * PR feedback * into_iter * timing
17 lines
646 B
Rust
17 lines
646 B
Rust
use itertools::Itertools;
|
|
use plonky2::field::field_types::Field;
|
|
use plonky2::field::polynomial::PolynomialValues;
|
|
use plonky2::util::transpose;
|
|
|
|
/// A helper function to transpose a row-wise trace and put it in the format that `prove` expects.
|
|
pub fn trace_rows_to_poly_values<F: Field, const COLUMNS: usize>(
|
|
trace_rows: Vec<[F; COLUMNS]>,
|
|
) -> Vec<PolynomialValues<F>> {
|
|
let trace_row_vecs = trace_rows.into_iter().map(|row| row.to_vec()).collect_vec();
|
|
let trace_col_vecs: Vec<Vec<F>> = transpose(&trace_row_vecs);
|
|
trace_col_vecs
|
|
.into_iter()
|
|
.map(|column| PolynomialValues::new(column))
|
|
.collect()
|
|
}
|