diff --git a/src/field.rs b/src/field.rs index d4cdb72..0d8cc1c 100644 --- a/src/field.rs +++ b/src/field.rs @@ -146,11 +146,11 @@ impl<'b> SubAssign<&'b FieldElement> for FieldElement { fn sub_assign(&mut self, _rhs: &'b FieldElement) { // To avoid underflow, first add p // XXX how many copies should we add to preserve headroom? - self.0[0] += constants::p.0[0]; - self.0[1] += constants::p.0[1]; - self.0[2] += constants::p.0[2]; - self.0[3] += constants::p.0[3]; - self.0[4] += constants::p.0[4]; + self.0[0] += 2*constants::p.0[0]; + self.0[1] += 2*constants::p.0[1]; + self.0[2] += 2*constants::p.0[2]; + self.0[3] += 2*constants::p.0[3]; + self.0[4] += 2*constants::p.0[4]; // then subtract _rhs self.0[0] -= _rhs.0[0]; self.0[1] -= _rhs.0[1];