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

Sumcheck IOP for LogUp-GKR #295

Merged
merged 28 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8ac25c7
feat: math utilities needed for sum-check protocol
Al-Kindi-0 Aug 6, 2024
5e06378
feat: add sum-check prover and verifier
Al-Kindi-0 Aug 6, 2024
16389d6
tests: add sanity tests for utils
Al-Kindi-0 Aug 6, 2024
380aa1a
doc: document sumcheck_round
Al-Kindi-0 Aug 6, 2024
7a1a99e
feat: use SmallVec
Al-Kindi-0 Aug 7, 2024
1901066
docs: improve documentation of sum-check
Al-Kindi-0 Aug 8, 2024
8a57216
feat: add remaining functions for sum-check verifier
Al-Kindi-0 Aug 9, 2024
ff9e6fa
chore: move prover into sub-mod
Al-Kindi-0 Aug 9, 2024
7e24f8f
chore: remove utils mod
Al-Kindi-0 Aug 9, 2024
23044e8
chore: remove utils mod
Al-Kindi-0 Aug 9, 2024
ad0497d
chore: move logup evaluator trait to separate file
Al-Kindi-0 Aug 9, 2024
d721bc2
feat: add multi-threading support and simplify input sum-check
Al-Kindi-0 Aug 15, 2024
2e5a704
chore: fix Sync issue
Al-Kindi-0 Aug 15, 2024
06454d9
chore: pacify clippy
Al-Kindi-0 Aug 15, 2024
2c07857
chore: fix toml formatting
Al-Kindi-0 Aug 19, 2024
2e02f1f
feat: add benchmarks and address feedback
Al-Kindi-0 Aug 19, 2024
e7a50c0
feat: address feedback and add benchmarks
Al-Kindi-0 Aug 19, 2024
2b64dbf
feat: simplify sum-check bench
Al-Kindi-0 Aug 19, 2024
ea7cb84
feat: add sum-check benchmarks
Al-Kindi-0 Aug 19, 2024
dae27e6
doc: improve documentation
Al-Kindi-0 Aug 19, 2024
9543e1a
chore: pacify clippy
Al-Kindi-0 Aug 20, 2024
60c8591
chore: pacify clippy
Al-Kindi-0 Aug 20, 2024
7338caf
chore: pacify clippy
Al-Kindi-0 Aug 20, 2024
43c7441
chore: pacify clippy
Al-Kindi-0 Aug 20, 2024
f85e44f
feat: reduce memory allocation in bind least signi
Al-Kindi-0 Aug 20, 2024
be0c2cd
doc: add docs to logup evaluator trait
Al-Kindi-0 Aug 20, 2024
1847d0d
chore: improve var naming
Al-Kindi-0 Aug 20, 2024
3adc855
doc: improve
Al-Kindi-0 Aug 20, 2024
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ members = [
"verifier",
"winterfell",
"examples"
]
, "sumcheck"]
irakliyk marked this conversation as resolved.
Show resolved Hide resolved
resolver = "2"

[profile.release]
Expand Down
74 changes: 74 additions & 0 deletions air/src/air/logup_gkr.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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 alloc::vec::Vec;

use super::EvaluationFrame;
use math::{ExtensionOf, FieldElement, StarkField, ToElements};

pub trait LogUpGkrEvaluator: Clone + Sync {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a docstring here? This trait does a lot of things and it's a little bit hard to get a handle on exactly what

/// Defines the base field of the evaluator.
type BaseField: StarkField;

/// Public inputs need to compute the final claim.
type PublicInputs: ToElements<Self::BaseField> + Send;

/// Gets a list of all oracles involved in LogUp-GKR; this is intended to be used in construction of
/// MLEs.
fn get_oracles(&self) -> Vec<LogUpGkrOracle<Self::BaseField>>;

/// Returns the number of random values needed to evaluate a query.
fn get_num_rand_values(&self) -> usize;

/// Returns the number of fractions in the LogUp-GKR statement.
fn get_num_fractions(&self) -> usize;
irakliyk marked this conversation as resolved.
Show resolved Hide resolved

/// Returns the maximal degree of the multi-variate associated to the input layer.
fn max_degree(&self) -> usize;
irakliyk marked this conversation as resolved.
Show resolved Hide resolved

/// Builds a query from the provided main trace frame and periodic values.
///
/// Note: it should be possible to provide an implementation of this method based on the
/// information returned from `get_oracles()`. However, this implementation is likely to be
/// expensive compared to the hand-written implementation. However, we could provide a test
/// which verifies that `get_oracles()` and `build_query()` methods are consistent.
fn build_query<E>(&self, frame: &EvaluationFrame<E>, periodic_values: &[E]) -> Vec<E>
irakliyk marked this conversation as resolved.
Show resolved Hide resolved
where
E: FieldElement<BaseField = Self::BaseField>;

/// Evaluates the provided query and writes the results into the numerators and denominators.
///
/// Note: it is also possible to combine `build_query()` and `evaluate_query()` into a single
/// method to avoid the need to first build the query struct and then evaluate it. However:
/// - We assume that the compiler will be able to optimize this away.
/// - Merging the methods will make it more difficult avoid inconsistencies between
/// `evaluate_query()` and `get_oracles()` methods.
fn evaluate_query<F, E>(
&self,
query: &[F],
rand_values: &[E],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would rename this to logup_randomness

numerator: &mut [E],
denominator: &mut [E],
irakliyk marked this conversation as resolved.
Show resolved Hide resolved
) where
F: FieldElement<BaseField = Self::BaseField>,
E: FieldElement<BaseField = Self::BaseField> + ExtensionOf<F>;

/// Computes the final claim for the LogUp-GKR circuit.
///
/// The default implementation of this method returns E::ZERO as it is expected that the
/// fractional sums will cancel out. However, in cases when some boundary conditions need to
/// be imposed on the LogUp-GKR relations, this method can be overridden to compute the final
/// expected claim.
fn compute_claim<E>(&self, inputs: &Self::PublicInputs, rand_values: &[E]) -> E
where
E: FieldElement<BaseField = Self::BaseField>;
irakliyk marked this conversation as resolved.
Show resolved Hide resolved
}

#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, Ord)]
pub enum LogUpGkrOracle<B: StarkField> {
CurrentRow(usize),
NextRow(usize),
PeriodicValue(Vec<B>),
}
3 changes: 3 additions & 0 deletions air/src/air/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ pub use lagrange::{
LagrangeKernelRandElements, LagrangeKernelTransitionConstraints,
};

mod logup_gkr;
pub use logup_gkr::{LogUpGkrEvaluator, LogUpGkrOracle};

mod coefficients;
pub use coefficients::{
ConstraintCompositionCoefficients, DeepCompositionCoefficients,
Expand Down
4 changes: 2 additions & 2 deletions air/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ pub use air::{
DeepCompositionCoefficients, EvaluationFrame, GkrRandElements, GkrVerifier,
LagrangeConstraintsCompositionCoefficients, LagrangeKernelBoundaryConstraint,
LagrangeKernelConstraints, LagrangeKernelEvaluationFrame, LagrangeKernelRandElements,
LagrangeKernelTransitionConstraints, TraceInfo, TransitionConstraintDegree,
TransitionConstraints,
LagrangeKernelTransitionConstraints, LogUpGkrEvaluator, LogUpGkrOracle, TraceInfo,
TransitionConstraintDegree, TransitionConstraints,
};
31 changes: 31 additions & 0 deletions sumcheck/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "winter-sumcheck"
version = "0.1.0"
description = "Implementation of the sum-check protocol for the LogUp-GKR protocol"
authors = ["winterfell contributors"]
readme = "README.md"
license = "MIT"
repository = "https://github.com/novifinancial/winterfell"
documentation = "https://docs.rs/winter-sumcheck/0.1.0"
categories = ["cryptography", "no-std"]
keywords = ["crypto", "sumcheck", "iop"]
edition = "2021"
rust-version = "1.78"

[features]
concurrent = ["utils/concurrent", "dep:rayon", "std"]
default = ["std"]
std = ["utils/std"]

[dependencies]
air = { version = "0.9", path = "../air", package = "winter-air", default-features = false }
crypto = { version = "0.9", path = "../crypto", package = "winter-crypto", default-features = false }
math = { version = "0.9", path = "../math", package = "winter-math", default-features = false }
utils = { version = "0.9", path = "../utils/core", package = "winter-utils", default-features = false }
rayon = { version = "1.8", optional = true }
smallvec = { version = "1.13", default-features = false }
thiserror = { version = "1.0", git = "https://github.com/bitwalker/thiserror", branch = "no-std", default-features = false }
irakliyk marked this conversation as resolved.
Show resolved Hide resolved

[dev-dependencies]
criterion = "0.5"
rand-utils = { version = "0.9", path = "../utils/rand", package = "winter-rand-utils" }
Loading
Loading