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

add ceno pcs trait #3

Merged
merged 15 commits into from
Dec 5, 2024
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"
69 changes: 69 additions & 0 deletions src/ceno_binding/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
mod pcs;

use ark_ff::FftField;
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
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;
type CommitmentWithData;
type Proof: Clone + CanonicalSerialize + CanonicalDeserialize;
type Poly: Clone;
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