-
Notifications
You must be signed in to change notification settings - Fork 36
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
Zeromorph EvaluationEngine trait #71
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c26af9c
fix: add doctest for evaluate_opt
huitseeker f44d6b5
fix: remove obsolete comments
huitseeker cce289d
chore: move UniPoly methods where they should be
huitseeker aa6d7b4
test: make clear current zeromorph operates in monomial basis
huitseeker 4555c50
refactor TranscriptReprTrait impl for compat with Commitments
huitseeker 8f9421e
feat: Implement KZG commitment trait and serialization features
huitseeker fe7dc73
Use the ZMPCS Evaluation Engine and the KZG Commitment Engine in tests.
huitseeker d7ba2cf
feat: Improve `prove` and `verify` methods in `ZMPCS` struct
huitseeker 4123abc
refactor: split ZM test with spark compression
huitseeker 136810c
fix evaluation reversal bug
huitseeker 186d486
fix: remove superfluous eval functions
huitseeker fd62444
fix: parallellize pp generation
huitseeker 4c233e4
fixup! fix evaluation reversal bug
huitseeker 06bdefa
fixup! Use the ZMPCS Evaluation Engine and the KZG Commitment Engine …
huitseeker 2d373e9
fix: remove endianness shenanigans
huitseeker 83950c5
test: add evaluation unit test
huitseeker fd172b8
fixup! fix: remove endianness shenanigans
huitseeker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
//! Commitment engine for KZG commitments | ||
//! | ||
|
||
use std::marker::PhantomData; | ||
|
||
use group::{prime::PrimeCurveAffine, Curve}; | ||
use pairing::Engine; | ||
use rand::rngs::StdRng; | ||
use rand_core::SeedableRng; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::traits::{ | ||
commitment::{CommitmentEngineTrait, Len}, | ||
Group, | ||
}; | ||
|
||
use super::{ | ||
non_hiding_kzg::{UVKZGCommitment, UVUniversalKZGParam}, | ||
pedersen::Commitment, | ||
}; | ||
|
||
/// Provides a commitment engine | ||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
pub struct KZGCommitmentEngine<E: Engine> { | ||
_p: PhantomData<E>, | ||
} | ||
|
||
impl<E: Engine> CommitmentEngineTrait<E::G1> for KZGCommitmentEngine<E> | ||
where | ||
E::G1: Group<PreprocessedGroupElement = E::G1Affine>, | ||
E::G1Affine: Serialize + for<'de> Deserialize<'de>, | ||
E::G2Affine: Serialize + for<'de> Deserialize<'de>, | ||
{ | ||
type CommitmentKey = UVUniversalKZGParam<E>; | ||
type Commitment = Commitment<E::G1>; | ||
|
||
fn setup(label: &'static [u8], n: usize) -> Self::CommitmentKey { | ||
// TODO: this is just for testing, replace by grabbing from a real setup for production | ||
let mut bytes = [0u8; 32]; | ||
let len = label.len().min(32); | ||
bytes[..len].copy_from_slice(&label[..len]); | ||
let rng = &mut StdRng::from_seed(bytes); | ||
UVUniversalKZGParam::gen_srs_for_testing(rng, n.next_power_of_two()) | ||
} | ||
|
||
fn commit(ck: &Self::CommitmentKey, v: &[<E::G1 as Group>::Scalar]) -> Self::Commitment { | ||
assert!(ck.length() >= v.len()); | ||
Commitment { | ||
comm: E::G1::vartime_multiscalar_mul(v, &ck.powers_of_g[..v.len()]), | ||
} | ||
} | ||
} | ||
|
||
impl<E: Engine> From<Commitment<E::G1>> for UVKZGCommitment<E> | ||
where | ||
E::G1: Group, | ||
{ | ||
fn from(c: Commitment<E::G1>) -> Self { | ||
UVKZGCommitment(c.comm.to_affine()) | ||
} | ||
} | ||
|
||
impl<E: Engine> From<UVKZGCommitment<E>> for Commitment<E::G1> | ||
where | ||
E::G1: Group, | ||
{ | ||
fn from(c: UVKZGCommitment<E>) -> Self { | ||
Commitment { | ||
comm: c.0.to_curve(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This translates the former
test_ivc_nontrivial_with_zm_compression