-
Notifications
You must be signed in to change notification settings - Fork 715
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arithmetic: Pass inputs to
limbs_mul_mont
as slices.
Remove some gratuitous unsafety. In theory there are many patterns of aliasing the arguments when calling `bn_mul_mont`, but in practice we only have three: 1. r *= a (mod n) 2. r = a * b (mod n) 3. r = r * r (mod n) Rename `mul_mont` to `limbs_mul_mont` and have it handle both #1 & #2. Refactor it so that its arguments are slices. Remove the `limbs_mont_mul` and `limbs_mont_product` wrappers around `limbs_mul_mont` in favor of exposing `limbs_mul_mont` directly. Change `limbs_square_mont` to call `bn_mul_mont` directly. Although we could have `mul_mont` handle this by making the new `InOut` type more complicated, but we'd just end up undoing this when `bn_mul_mont` is split into separate squaring and non-squaring functions later.
- Loading branch information
1 parent
d963cdf
commit e8ffb44
Showing
4 changed files
with
69 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2025 Brian Smith. | ||
// | ||
// Permission to use, copy, modify, and/or distribute this software for any | ||
// purpose with or without fee is hereby granted, provided that the above | ||
// copyright notice and this permission notice appear in all copies. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES | ||
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY | ||
// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | ||
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | ||
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
|
||
pub enum InOut<'io, T: ?Sized> { | ||
InPlace(&'io mut T), | ||
#[cfg_attr(target_arch = "x86_64", allow(dead_code))] | ||
Disjoint(&'io mut T, &'io T), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters