Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix partition hashing #338

Merged
merged 4 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<a href="https://github.com/novifinancial/winterfell/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
<img src="https://github.com/novifinancial/winterfell/workflows/CI/badge.svg?branch=main">
<a href="https://deps.rs/repo/github/novifinancial/winterfell"><img src="https://deps.rs/repo/github/novifinancial/winterfell/status.svg"></a>
<img src="https://img.shields.io/badge/prover-rustc_1.78+-lightgray.svg">
<img src="https://img.shields.io/badge/verifier-rustc_1.78+-lightgray.svg">
<img src="https://img.shields.io/badge/prover-rustc_1.82+-lightgray.svg">
<img src="https://img.shields.io/badge/verifier-rustc_1.82+-lightgray.svg">
<a href="https://crates.io/crates/winterfell"><img src="https://img.shields.io/crates/v/winterfell"></a>

A STARK prover and verifier for arbitrary computations.
Expand Down
4 changes: 4 additions & 0 deletions air/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,11 @@ impl PartitionOptions {

/// Returns the size of each partition used when committing to the main and auxiliary traces as
/// well as the constraint evaluation trace.
/// The returned size is given in terms of number of columns in the field `E`.
pub fn partition_size<E: FieldElement>(&self, num_columns: usize) -> usize {
if self.num_partitions == 1 && self.min_partition_size == 1 {
return num_columns;
}
let base_elements_per_partition = cmp::max(
(num_columns * E::EXTENSION_DEGREE).div_ceil(self.num_partitions as usize),
self.min_partition_size as usize,
Expand Down
2 changes: 1 addition & 1 deletion prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ air = { version = "0.10", path = "../air", package = "winter-air", default-featu
crypto = { version = "0.10", path = "../crypto", package = "winter-crypto", default-features = false }
fri = { version = "0.10", path = '../fri', package = "winter-fri", default-features = false }
math = { version = "0.10", path = "../math", package = "winter-math", default-features = false }
maybe_async = { path = "../utils/maybe_async" , package = "winter-maybe-async" }
maybe_async = { version = "0.10", path = "../utils/maybe_async" , package = "winter-maybe-async" }
tracing = { version = "0.1", default-features = false, features = ["attributes"]}
utils = { version = "0.10", path = "../utils/core", package = "winter-utils", default-features = false }

Expand Down
1 change: 1 addition & 0 deletions prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ pub trait Prover {
/// Builds and returns the auxiliary trace.
#[allow(unused_variables)]
#[maybe_async]
#[instrument(skip_all)]
fn build_aux_trace<E>(
&self,
main_trace: &Self::Trace,
Expand Down
2 changes: 1 addition & 1 deletion prover/src/matrix/row_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl<E: FieldElement> RowMatrix<E> {
// allocate vector to store row hashes
let mut row_hashes = unsafe { uninit_vector::<H::Digest>(self.num_rows()) };

if partition_size == self.num_cols() * E::EXTENSION_DEGREE {
if partition_size == self.num_cols() {
// iterate though matrix rows, hashing each row
batch_iter_mut!(
&mut row_hashes,
Expand Down
2 changes: 1 addition & 1 deletion verifier/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ where
E: FieldElement,
H: ElementHasher<BaseField = E::BaseField>,
{
if partition_size == row.len() * E::EXTENSION_DEGREE {
if partition_size == row.len() {
H::hash_elements(row)
} else {
let mut buffer = vec![H::Digest::default(); partition_size];
Expand Down