-
Notifications
You must be signed in to change notification settings - Fork 137
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 an Absorb
trait bound to PCCommitment
#144
base: master
Are you sure you want to change the base?
Changes from 4 commits
812ad77
b595ba2
a0a0700
7b28c06
4af4d62
99cb083
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
use crate::*; | ||
use ark_crypto_primitives::sponge::Absorb; | ||
use ark_ec::pairing::Pairing; | ||
use ark_ec::AdditiveGroup; | ||
use ark_ec::AffineRepr; | ||
|
@@ -314,7 +315,7 @@ impl<E: Pairing> PreparedVerifierKey<E> { | |
} | ||
|
||
/// `Commitment` commits to a polynomial. It is output by `KZG10::commit`. | ||
#[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)] | ||
#[derive(Derivative, CanonicalSerialize, CanonicalDeserialize, Absorb)] | ||
#[derivative( | ||
Default(bound = ""), | ||
Hash(bound = ""), | ||
|
@@ -324,12 +325,19 @@ impl<E: Pairing> PreparedVerifierKey<E> { | |
PartialEq(bound = ""), | ||
Eq(bound = "") | ||
)] | ||
pub struct Commitment<E: Pairing>( | ||
pub struct Commitment<E>( | ||
/// The commitment is a group element. | ||
pub E::G1Affine, | ||
); | ||
) | ||
where | ||
E: Pairing, | ||
E::G1Affine: Absorb; | ||
Comment on lines
+328
to
+334
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically, we don't need an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would avoid most of this churn I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I restrict |
||
|
||
impl<E: Pairing> PCCommitment for Commitment<E> { | ||
impl<E> PCCommitment for Commitment<E> | ||
where | ||
E: Pairing, | ||
E::G1Affine: Absorb, | ||
{ | ||
#[inline] | ||
fn empty() -> Self { | ||
Commitment(E::G1Affine::zero()) | ||
|
@@ -340,16 +348,21 @@ impl<E: Pairing> PCCommitment for Commitment<E> { | |
} | ||
} | ||
|
||
impl<E: Pairing> ToConstraintField<<E::TargetField as Field>::BasePrimeField> for Commitment<E> | ||
impl<E> ToConstraintField<<E::TargetField as Field>::BasePrimeField> for Commitment<E> | ||
where | ||
E::G1Affine: ToConstraintField<<E::TargetField as Field>::BasePrimeField>, | ||
E::G1Affine: ToConstraintField<<E::TargetField as Field>::BasePrimeField> + Absorb, | ||
E: Pairing, | ||
{ | ||
fn to_field_elements(&self) -> Option<Vec<<E::TargetField as Field>::BasePrimeField>> { | ||
self.0.to_field_elements() | ||
} | ||
} | ||
|
||
impl<'a, E: Pairing> AddAssign<(E::ScalarField, &'a Commitment<E>)> for Commitment<E> { | ||
impl<'a, E> AddAssign<(E::ScalarField, &'a Commitment<E>)> for Commitment<E> | ||
where | ||
E: Pairing, | ||
E::G1Affine: Absorb, | ||
{ | ||
#[inline] | ||
fn add_assign(&mut self, (f, other): (E::ScalarField, &'a Commitment<E>)) { | ||
let mut other = other.0 * f; | ||
|
@@ -373,7 +386,11 @@ pub struct PreparedCommitment<E: Pairing>( | |
pub Vec<E::G1Affine>, | ||
); | ||
|
||
impl<E: Pairing> PreparedCommitment<E> { | ||
impl<E> PreparedCommitment<E> | ||
where | ||
E: Pairing, | ||
E::G1Affine: Absorb, | ||
{ | ||
/// prepare `PreparedCommitment` from `Commitment` | ||
pub fn prepare(comm: &Commitment<E>) -> Self { | ||
let mut prepared_comm = Vec::<E::G1Affine>::new(); | ||
|
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.
@Pratyush If I'm not deriving
Absorb
, what about thedegree_bound
? I would assume this doesn't need to get absorbed.