Skip to content

Commit

Permalink
Deleted the repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
Fitznik committed Nov 18, 2024
1 parent 28e2224 commit b03cc4f
Showing 1 changed file with 1 addition and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,7 @@ where
// well, we just mul by 1
let mut one: NonNativeFieldOverU16<F, T, N> =
Self::allocated_constant(cs, T::one(), &self.params);
let mut normalized = self.mul(cs, &mut one);

// assert that we only have "modulus limbs" moduluses in this element
assert_eq!(normalized.non_zero_limbs, normalized.params.modulus_limbs);

// sub modulus
let modulus = self
.params
.modulus
.map(|el| cs.allocate_constant(F::from_u64_unchecked(el as u64)));
// for rare case when our modulus is exactly 16 * K bits, but we use larger representation
let els_to_skip = N - self.params.modulus_limbs;
let _ =
u16_long_subtraction_noborrow_must_borrow(cs, &normalized.limbs, &modulus, els_to_skip);
assert!(normalized.form == RepresentationForm::Normalized);
normalized.tracker.max_moduluses = 1;
let normalized = self.mul(cs, &mut one);

// update self to normalized one
*self = normalized;
Expand Down

0 comments on commit b03cc4f

Please sign in to comment.