diff --git a/src/plonk/circuit.rs b/src/plonk/circuit.rs index 17819af1..3d6249b3 100644 --- a/src/plonk/circuit.rs +++ b/src/plonk/circuit.rs @@ -291,6 +291,70 @@ impl From<(F, F)> for Assigned { } } +impl Neg for Assigned { + type Output = Assigned; + fn neg(self) -> Self::Output { + Assigned { + numerator: -self.numerator, + denominator: self.denominator, + } + } +} + +impl Add for Assigned { + type Output = Assigned; + fn add(self, rhs: Assigned) -> Assigned { + Assigned { + numerator: self.numerator * rhs.denominator + self.denominator * rhs.numerator, + denominator: self.denominator * rhs.denominator, + } + } +} + +impl Add for Assigned { + type Output = Assigned; + fn add(self, rhs: F) -> Assigned { + Assigned { + numerator: self.numerator + self.denominator * rhs, + denominator: self.denominator, + } + } +} + +impl Sub for Assigned { + type Output = Assigned; + fn sub(self, rhs: Assigned) -> Assigned { + self + (-rhs) + } +} + +impl Sub for Assigned { + type Output = Assigned; + fn sub(self, rhs: F) -> Assigned { + self + (-rhs) + } +} + +impl Mul for Assigned { + type Output = Assigned; + fn mul(self, rhs: Assigned) -> Assigned { + Assigned { + numerator: self.numerator * rhs.numerator, + denominator: self.denominator * rhs.denominator, + } + } +} + +impl Mul for Assigned { + type Output = Assigned; + fn mul(self, rhs: F) -> Assigned { + Assigned { + numerator: self.numerator * rhs, + denominator: self.denominator, + } + } +} + impl Assigned { /// Returns the numerator. pub fn numerator(&self) -> F {