Skip to content

Commit

Permalink
Rest
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratyush committed Aug 11, 2021
1 parent d71692b commit 329e839
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub mod groups;

/// This module implements gadgets related to computing pairings in bilinear
/// groups.
// pub mod pairing;
pub mod pairing;

/// This module describes a trait for allocating new variables in a constraint
/// system.
Expand All @@ -63,7 +63,7 @@ pub mod prelude {
eq::*,
fields::{FieldOpsBounds, FieldVar},
groups::{CurveVar, GroupOpsBounds},
pairing::PairingVar,
pairing::PairingGadget,
select::*,
R1CSVar,
};
Expand Down
33 changes: 18 additions & 15 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ macro_rules! impl_bounded_ops {
#[tracing::instrument(target = "r1cs", skip(self))]
#[allow(unused_braces, clippy::redundant_closure_call)]
fn $fn(self, other: Self) -> Self::Output {
($impl)(self, other)
let mut result = self.clone();
core::ops::$assign_trait::$assign_fn(&mut result, other);
result
}
}

Expand All @@ -77,8 +79,9 @@ macro_rules! impl_bounded_ops {

#[tracing::instrument(target = "r1cs", skip(self))]
#[allow(unused_braces)]
fn $fn(self, other: &'a $type) -> Self::Output {
core::ops::$trait::$fn(&self, other)
fn $fn(mut self, other: &'a $type) -> Self::Output {
core::ops::$assign_trait::$assign_fn(&mut self, other);
self
}
}

Expand All @@ -91,8 +94,9 @@ macro_rules! impl_bounded_ops {

#[tracing::instrument(target = "r1cs", skip(self))]
#[allow(unused_braces)]
fn $fn(self, other: $type) -> Self::Output {
core::ops::$trait::$fn(&self, &other)
fn $fn(mut self, other: $type) -> Self::Output {
core::ops::$assign_trait::$assign_fn(&mut self, &other);
self
}
}

Expand All @@ -104,8 +108,7 @@ macro_rules! impl_bounded_ops {
#[tracing::instrument(target = "r1cs", skip(self))]
#[allow(unused_braces)]
fn $assign_fn(&mut self, other: $type) {
let result = core::ops::$trait::$fn(&*self, &other);
*self = result
core::ops::$assign_trait::$assign_fn(self, &other);
}
}

Expand All @@ -117,8 +120,7 @@ macro_rules! impl_bounded_ops {
#[tracing::instrument(target = "r1cs", skip(self))]
#[allow(unused_braces)]
fn $assign_fn(&mut self, other: &'a $type) {
let result = core::ops::$trait::$fn(&*self, other);
*self = result
($impl)(self, other)
}
}

Expand All @@ -132,7 +134,9 @@ macro_rules! impl_bounded_ops {
#[tracing::instrument(target = "r1cs", skip(self))]
#[allow(unused_braces, clippy::redundant_closure_call)]
fn $fn(self, other: $native) -> Self::Output {
($constant_impl)(self, other)
let mut result = self.clone();
core::ops::$assign_trait::$assign_fn(&mut result, other);
result
}
}

Expand All @@ -145,8 +149,9 @@ macro_rules! impl_bounded_ops {

#[tracing::instrument(target = "r1cs", skip(self))]
#[allow(unused_braces)]
fn $fn(self, other: $native) -> Self::Output {
core::ops::$trait::$fn(&self, other)
fn $fn(mut self, other: $native) -> Self::Output {
core::ops::$assign_trait::$assign_fn(&mut self, other);
self
}
}

Expand All @@ -155,12 +160,10 @@ macro_rules! impl_bounded_ops {

$($bounds)*
{

#[tracing::instrument(target = "r1cs", skip(self))]
#[allow(unused_braces)]
fn $assign_fn(&mut self, other: $native) {
let result = core::ops::$trait::$fn(&*self, other);
*self = result
($constant_impl)(self, other)
}
}
}
Expand Down

0 comments on commit 329e839

Please sign in to comment.