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

initial implemetation of Sumcheck protocol #7

Merged
merged 20 commits into from
May 12, 2022
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: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[workspace]
members = [
"hyperplonk"
"hyperplonk",
"pcs",
"poly-iop"
]
8 changes: 8 additions & 0 deletions pcs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "pcs"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
3 changes: 3 additions & 0 deletions pcs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
KZG based multilinear polynomial commitment
-----

8 changes: 8 additions & 0 deletions pcs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
let result = 2 + 2;
assert_eq!(result, 4);
}
}
32 changes: 32 additions & 0 deletions poly-iop/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[package]
name = "poly-iop"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

ark-ff = { version = "^0.3.0", default-features = false }
ark-std = { version = "^0.3.0", default-features = false }
ark-poly = { version = "^0.3.0", default-features = false }
ark-serialize = { version = "^0.3.0", default-features = false }
ark-bls12-381 = { version = "0.3.0", default-features = false, features = [ "curve" ] }

rand_chacha = { version = "0.3.0", default-features = false }
merlin = { version = "3.0.0", default-features = false }
displaydoc = { version = "0.2.3", default-features = false }

rayon = { version = "1.5.2", default-features = false, optional = true }

[features]
default = [ "parallel" ]
parallel = [
"rayon",
"ark-std/parallel",
"ark-ff/parallel",
"ark-poly/parallel"
]
print-trace = [
"ark-std/print-trace"
]
7 changes: 7 additions & 0 deletions poly-iop/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Poly IOP
-----

Implements the following protocols

- [ ] sum checks
- [ ] zero checks
27 changes: 27 additions & 0 deletions poly-iop/src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//! Error module.

use ark_std::string::String;
use displaydoc::Display;

/// A `enum` specifying the possible failure modes of the PolyIOP.
#[derive(Display, Debug)]
pub enum PolyIOPErrors {
/// Invalid Prover
InvalidProver(String),
/// Invalid Verifier
InvalidVerifier(String),
/// Invalid Proof
InvalidProof(String),
/// Invalid parameters
InvalidParameters(String),
/// Invalid Transcript
InvalidTranscript(String),
/// An error during (de)serialization
SerializationError(ark_serialize::SerializationError),
}

impl From<ark_serialize::SerializationError> for PolyIOPErrors {
fn from(e: ark_serialize::SerializationError) -> Self {
Self::SerializationError(e)
}
}
23 changes: 23 additions & 0 deletions poly-iop/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#![allow(dead_code)]

use std::marker::PhantomData;

use ark_ff::PrimeField;

mod errors;
mod structs;
mod sum_check;
mod transcript;
mod utils;
mod virtual_poly;
// mod zero_check;

pub use virtual_poly::VirtualPolynomial;

/// Struct for PolyIOP protocol.
/// It is instantiated with
/// - SumCheck protocol.
/// - ZeroCheck protocol. (WIP)
pub struct PolyIOP<F: PrimeField> {
phantom: PhantomData<F>,
}
40 changes: 40 additions & 0 deletions poly-iop/src/structs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//! Structs for polynomials and extensions.

use ark_ff::PrimeField;
use std::marker::PhantomData;

#[derive(Clone, Debug, Default, PartialEq)]
/// Auxiliary information about the multilinear polynomial
pub struct DomainInfo<F: PrimeField> {
/// max number of multiplicands in each product
zhenfeizhang marked this conversation as resolved.
Show resolved Hide resolved
pub max_degree: usize,
/// number of variables of the polynomial
pub num_variables: usize,
/// Associated field
#[doc(hidden)]
pub(crate) phantom: PhantomData<F>,
}

/// Subclaim when verifier is convinced
pub struct SubClaim<F: PrimeField> {
/// the multi-dimensional point that this multilinear extension is evaluated
/// to
pub point: Vec<F>,
/// the expected evaluation
pub expected_evaluation: F,
}

/// An IOP proof is a list of messages from prover to verifier
/// through the interactive protocol.
/// It is a shared struct for both sumcheck and zerocheck protocols.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct IOPProof<F: PrimeField> {
zhenfeizhang marked this conversation as resolved.
Show resolved Hide resolved
pub proofs: Vec<IOPProverMessage<F>>,
}

/// A message from the prover to the verifier at a given round
/// is a list of evaluations.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct IOPProverMessage<F: PrimeField> {
chancharles92 marked this conversation as resolved.
Show resolved Hide resolved
pub(crate) evaluations: Vec<F>,
}
Loading