Skip to content

Commit 5bc9950

Browse files
committed
Remove suspicious mutation
1 parent ebbb710 commit 5bc9950

File tree

1 file changed

+6
-6
lines changed
  • src/backends/plonky2/primitives/ec

1 file changed

+6
-6
lines changed

src/backends/plonky2/primitives/ec/curve.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,14 @@ impl AddAssign<Self> for Point {
257257
impl Mul<Point> for &BigUint {
258258
type Output = Point;
259259
fn mul(self, rhs: Point) -> Self::Output {
260-
let mut ans = Point::ZERO;
261-
for bit_pos in (0..self.bits()).rev() {
262-
ans = ans.double();
260+
(0..self.bits()).rev().fold(Point::ZERO, |prod, bit_pos| {
261+
let double = prod.double();
263262
if self.bit(bit_pos) {
264-
ans += rhs;
263+
double + rhs
264+
} else {
265+
double
265266
}
266-
}
267-
ans
267+
})
268268
}
269269
}
270270

0 commit comments

Comments
 (0)