mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-09 17:23:08 +00:00
19 lines
662 B
Rust
19 lines
662 B
Rust
use alloc::vec::Vec;
|
|
|
|
use itertools::Itertools;
|
|
use plonky2::field::polynomial::PolynomialValues;
|
|
use plonky2::field::types::Field;
|
|
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()
|
|
}
|