Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Ensure nonnative field negate works in case of non-normalized input #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ where
}
}

assert!(self.tracker.max_moduluses <= self.params.max_mods_to_fit);
new
}

Expand Down Expand Up @@ -334,6 +335,7 @@ where
}
}

assert!(self.tracker.max_moduluses <= self.params.max_mods_to_fit);
new
}

Expand Down Expand Up @@ -713,6 +715,7 @@ where
// enforce that r is canonical
new.enforce_reduced(cs);

assert!(self.tracker.max_moduluses <= self.params.max_mods_to_fit);
new
}

Expand Down Expand Up @@ -764,7 +767,9 @@ where
let new = Self {
limbs,
non_zero_limbs: used_words,
tracker: OverflowTracker { max_moduluses: 2 }, // NOTE: if self == 0, then limbs will be == modulus, so use 2
tracker: OverflowTracker {
max_moduluses: std::cmp::max(2, self.tracker.max_moduluses),
}, // NOTE: if self == 0, then limbs will be == modulus, so use 2
form: RepresentationForm::Normalized,
params: self.params.clone(),
_marker: std::marker::PhantomData,
Expand Down Expand Up @@ -858,6 +863,7 @@ where
}
}

assert!(self.tracker.max_moduluses <= self.params.max_mods_to_fit);
new
}

Expand Down
Loading