Make Field::double take &self and return Self

This commit is contained in:
Jack Grigg
2019-12-12 22:59:18 +00:00
parent 91c32f1c7c
commit 9dac748224
23 changed files with 87 additions and 111 deletions

View File

@@ -144,8 +144,8 @@ impl Field for Fr {
self.0 = (self.0 * self.0) % MODULUS_R;
}
fn double(&mut self) {
self.0 = (self.0 << 1) % MODULUS_R;
fn double(&self) -> Self {
Fr((self.0 << 1) % MODULUS_R)
}
fn inverse(&self) -> Option<Self> {
@@ -406,7 +406,7 @@ impl CurveProjective for Fr {
}
fn double(&mut self) {
<Fr as Field>::double(self);
self.0 = <Fr as Field>::double(self).0;
}
fn add_assign(&mut self, other: &Self) {