Skip to content

Commit b6c3619

Browse files
committed
Simplify FieldElement::square_n() and protect against zero
1 parent 972302a commit b6c3619

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

ed448-goldilocks/src/field/element.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,9 @@ impl FieldElement {
277277

278278
/// Squares a field element `n` times
279279
fn square_n<const N: u32>(&self) -> FieldElement {
280-
let mut result = self.square();
280+
let mut result = *self;
281281

282-
// Decrease value by 1 since we just did a squaring
283-
let n = N - 1;
284-
285-
for _ in 0..n {
282+
for _ in 0..N {
286283
result = result.square();
287284
}
288285

0 commit comments

Comments
 (0)