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

Adapt the WHIR code to match traits required in Ceno. #26

Closed
wants to merge 5 commits into from
Closed
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
170 changes: 168 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ nimue-pow = { git = "https://github.com/arkworks-rs/nimue" }
lazy_static = "1.4"
rayon = { version = "1.10.0", optional = true }

goldilocks = { git = "https://github.com/scroll-tech/ceno-Goldilocks" }
thiserror = "1"

[profile.release]
debug = true

[features]
default = ["parallel"]
#default = []
default = ["parallel", "ceno"]
parallel = [
"dep:rayon",
"ark-poly/parallel",
"ark-ff/parallel",
"ark-crypto-primitives/parallel",
]
rayon = ["dep:rayon"]


ceno = []
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly-2024-10-03"
71 changes: 71 additions & 0 deletions src/ceno_binding/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
mod pcs;
pub use pcs::Whir;

use ark_ff::FftField;
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use serde::{de::DeserializeOwned, Serialize};
use std::fmt::Debug;

#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
ProofError(#[from] nimue::ProofError),
}

pub trait PolynomialCommitmentScheme<E: FftField>: Clone {
type Param: Clone + Debug + Serialize + DeserializeOwned;
type CommitmentWithData: Clone + Debug + Serialize + DeserializeOwned;
type Proof: Clone + CanonicalSerialize + CanonicalDeserialize + Serialize + DeserializeOwned;
type Poly: Clone + Debug + Serialize + DeserializeOwned;
type Transcript;

fn setup(poly_size: usize) -> Self::Param;

fn commit_and_write(
pp: &Self::Param,
poly: &Self::Poly,
transcript: &mut Self::Transcript,
) -> Result<Self::CommitmentWithData, Error>;

fn batch_commit(
pp: &Self::Param,
polys: &[Self::Poly],
) -> Result<Self::CommitmentWithData, Error>;

fn open(
pp: &Self::Param,
comm: Self::CommitmentWithData,
point: &[E],
eval: &E,
transcript: &mut Self::Transcript,
) -> Result<Self::Proof, Error>;

/// This is a simple version of batch open:
/// 1. Open at one point
/// 2. All the polynomials share the same commitment.
/// 3. The point is already a random point generated by a sum-check.
fn batch_open(
pp: &Self::Param,
polys: &[Self::Poly],
comm: Self::CommitmentWithData,
point: &[E],
evals: &[E],
transcript: &mut Self::Transcript,
) -> Result<Self::Proof, Error>;

fn verify(
vp: &Self::Param,
point: &[E],
eval: &E,
proof: &Self::Proof,
transcript: &Self::Transcript,
) -> Result<(), Error>;

fn batch_verify(
vp: &Self::Param,
point: &[E],
evals: &[E],
proof: &Self::Proof,
transcript: &mut Self::Transcript,
) -> Result<(), Error>;
}
Loading
Loading