Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 src/groups/curves/short_weierstrass/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,14 @@ where
}
}

impl<P, F> CurveVar<SWProjective<P>, BasePrimeField<P>, F> for ProjectiveVar<P, F>
impl<P, F> CurveVar<SWProjective<P>, BasePrimeField<P>> for ProjectiveVar<P, F>
where
P: SWCurveConfig,
F: FieldVar<P::BaseField, BasePrimeField<P>>,
for<'a> &'a F: FieldOpsBounds<'a, P::BaseField, F>,
{
type F = F;

fn constant(g: SWProjective<P>) -> Self {
let cs = ConstraintSystemRef::None;
Self::new_variable_omit_on_curve_check(cs, || Ok(g), AllocationMode::Constant).unwrap()
Expand Down
4 changes: 3 additions & 1 deletion src/groups/curves/twisted_edwards/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,15 @@ where
}
}

impl<P, F> CurveVar<TEProjective<P>, BasePrimeField<P>, F> for AffineVar<P, F>
impl<P, F> CurveVar<TEProjective<P>, BasePrimeField<P>> for AffineVar<P, F>
where
P: TECurveConfig,
F: FieldVar<P::BaseField, BasePrimeField<P>>
+ TwoBitLookupGadget<BasePrimeField<P>, TableConstant = P::BaseField>,
for<'a> &'a F: FieldOpsBounds<'a, P::BaseField, F>,
{
type F = F;

fn constant(g: TEProjective<P>) -> Self {
let cs = ConstraintSystemRef::None;
Self::new_variable_omit_on_curve_check(cs, || Ok(g), AllocationMode::Constant).unwrap()
Expand Down
10 changes: 6 additions & 4 deletions src/groups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub trait GroupOpsBounds<'a, G, T: 'a>:

/// A variable that represents a curve point for
/// the curve `C`.
pub trait CurveVar<C: CurveGroup, ConstraintF: PrimeField, F: FieldVar<C::BaseField, ConstraintF>>:
pub trait CurveVar<C: CurveGroup, ConstraintF: PrimeField>:
'static
+ Sized
+ Clone
Expand All @@ -53,6 +53,8 @@ pub trait CurveVar<C: CurveGroup, ConstraintF: PrimeField, F: FieldVar<C::BaseFi
+ for<'a> Mul<&'a EmulatedFpVar<C::ScalarField, ConstraintF>, Output = Self>
+ MulAssign<EmulatedFpVar<C::ScalarField, ConstraintF>>
{
type F: FieldVar<C::BaseField, ConstraintF>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please rename this to BaseFieldVar?


/// Returns the constant `F::zero()`. This is the identity
/// of the group.
fn zero() -> Self;
Expand All @@ -69,15 +71,15 @@ pub trait CurveVar<C: CurveGroup, ConstraintF: PrimeField, F: FieldVar<C::BaseFi
fn constant(other: C) -> Self;

/// Returns the x and y coordinates in Affine representation.
fn affine_xy(&self) -> Result<(F, F), SynthesisError>;
fn affine_xy(&self) -> Result<(Self::F, Self::F), SynthesisError>;

/// Returns the x coordinate in Affine representation.
fn affine_x(&self) -> Result<F, SynthesisError> {
fn affine_x(&self) -> Result<Self::F, SynthesisError> {
self.affine_xy().map(|(x, _)| x)
}

/// Returns the y coordinate in Affine representation.
fn affine_y(&self) -> Result<F, SynthesisError> {
fn affine_y(&self) -> Result<Self::F, SynthesisError> {
self.affine_xy().map(|(_, y)| y)
}

Expand Down
5 changes: 1 addition & 4 deletions src/pairing/bls12/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ impl<P: Bls12Config> PairingVar<P> {
}
}

impl<P: Bls12Config>
PG<Bls12<P>, FpVar<<P as Bls12Config>::Fp>, Fp2Var<<P as Bls12Config>::Fp2Config>>
for PairingVar<P>
{
impl<P: Bls12Config> PG<Bls12<P>> for PairingVar<P> {
type G1Var = G1Var<P>;
type G2Var = G2Var<P>;
type G1PreparedVar = G1PreparedVar<P>;
Expand Down
4 changes: 1 addition & 3 deletions src/pairing/mnt4/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,7 @@ impl<P: MNT4Config> PairingVar<P> {
}
}

impl<P: MNT4Config> PG<MNT4<P>, FpVar<<P as MNT4Config>::Fp>, Fp2Var<<P as MNT4Config>::Fp2Config>>
for PairingVar<P>
{
impl<P: MNT4Config> PG<MNT4<P>> for PairingVar<P> {
type G1Var = G1Var<P>;
type G2Var = G2Var<P>;
type G1PreparedVar = G1PreparedVar<P>;
Expand Down
4 changes: 1 addition & 3 deletions src/pairing/mnt6/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ impl<P: MNT6Config> PairingVar<P> {
}
}

impl<P: MNT6Config> PG<MNT6<P>, FpVar<<P as MNT6Config>::Fp>, Fp3Var<<P as MNT6Config>::Fp3Config>>
for PairingVar<P>
{
impl<P: MNT6Config> PG<MNT6<P>> for PairingVar<P> {
type G1Var = G1Var<P>;
type G2Var = G2Var<P>;
type G1PreparedVar = G1PreparedVar<P>;
Expand Down
11 changes: 3 additions & 8 deletions src/pairing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,14 @@ type BasePrimeField<E> = <<E as Pairing>::BaseField as ark_ff::Field>::BasePrime

/// Specifies the constraints for computing a pairing in the yybilinear group
/// `E`.
pub trait PairingVar<
E: Pairing,
F1: FieldVar<<E::G1 as ark_ec::CurveGroup>::BaseField, E::BaseField>,
F2: FieldVar<<E::G2 as ark_ec::CurveGroup>::BaseField, E::BaseField>,
>
{
pub trait PairingVar<E: Pairing> {
/// An variable representing an element of `G1`.
/// This is the R1CS equivalent of `E::G1Projective`.
type G1Var: CurveVar<E::G1, BasePrimeField<E>, F1>;
type G1Var: CurveVar<E::G1, BasePrimeField<E>>;

/// An variable representing an element of `G2`.
/// This is the R1CS equivalent of `E::G2Projective`.
type G2Var: CurveVar<E::G2, BasePrimeField<E>, F2>;
type G2Var: CurveVar<E::G2, BasePrimeField<E>>;

/// An variable representing an element of `GT`.
/// This is the R1CS equivalent of `E::GT`.
Expand Down