Skip to content

Commit fdc0ac5

Browse files
authored
Merge pull request #30 from fjarri/expect-fix
Relax the `subtle` version requirement
2 parents b70250c + 8e53477 commit fdc0ac5

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
44
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

66

7+
## [0.4.1] - in development
8+
9+
### Fixed
10+
11+
- `subtle` version requirement relaxed to the (implicit) 2.4, instead of technically requiring 2.5 to compile. ([#30])
12+
13+
14+
[#30]: https://github.com/nucypher/rust-umbral/pull/30
15+
16+
717
## [0.4.0] - 2023-06-28
818

919
### Changed

src/hazmat/lucas.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,10 @@ fn decompose<const L: usize>(n: &Uint<L>) -> (u32, Uint<L>) {
187187
}
188188

189189
// This won't overflow since the original `n` was odd, so we right-shifted at least once.
190-
(s, n.checked_add(&Uint::<L>::ONE).expect("Integer overflow"))
190+
(
191+
s,
192+
Option::from(n.checked_add(&Uint::<L>::ONE)).expect("Integer overflow"),
193+
)
191194
}
192195

193196
/// The checks to perform in the Lucas test.

src/hazmat/miller_rabin.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ impl<const L: usize> MillerRabin<L> {
106106
let range_nonzero = NonZero::new(range).unwrap();
107107
// This should not overflow as long as `random_mod()` behaves according to the contract
108108
// (that is, returns a number within the given range).
109-
let random = Uint::<L>::random_mod(rng, &range_nonzero)
110-
.checked_add(&Uint::<L>::from(3u32))
111-
.expect("Integer overflow");
109+
let random = Option::from(
110+
Uint::<L>::random_mod(rng, &range_nonzero).checked_add(&Uint::<L>::from(3u32)),
111+
)
112+
.expect("Integer overflow");
112113
self.test(&random)
113114
}
114115
}

src/hazmat/sieve.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,8 @@ impl<const L: usize> Sieve<L> {
155155
// Should not overflow since `incr` is never greater than `incr_limit`,
156156
// and the latter is chosen such that it doesn't overflow when added to `base`
157157
// (see the rest of this method).
158-
self.base = self
159-
.base
160-
.checked_add(&self.incr.into())
161-
.expect("Integer overflow");
158+
self.base =
159+
Option::from(self.base.checked_add(&self.incr.into())).expect("Integer overflow");
162160

163161
self.incr = 0;
164162

@@ -219,10 +217,8 @@ impl<const L: usize> Sieve<L> {
219217
// The overflow should never happen here since `incr`
220218
// is never greater than `incr_limit`, and the latter is chosen such that
221219
// it does not overflow when added to `base` (see `update_residues()`).
222-
let mut num = self
223-
.base
224-
.checked_add(&self.incr.into())
225-
.expect("Integer overflow");
220+
let mut num =
221+
Option::from(self.base.checked_add(&self.incr.into())).expect("Integer overflow");
226222
if self.safe_primes {
227223
num = (num << 1) | Uint::<L>::ONE;
228224
}

0 commit comments

Comments
 (0)