commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
401e98ee3128516d03640f88e89663c78346dcce | Steven Dee | 2025-12-10T04:40:28 | Eliminate `WideWord` casts from `borrowing_sub` (#1029)
This works around rust-lang/rust#149522, which was leading to hangs on
linux-aarch64 in some code paths dependent upon `borrowing_sub`. | diff --git a/src/primitives.rs b/src/primitives.rs
index a8070f9..742b345 100644
--- a/src/primitives.rs
+++ b/src/primitives.rs
@@ -31,11 +31,11 @@ pub(crate) const fn overflowing_add(lhs: Word, rhs: Word) -> (Word, Word) {
/// Computes `lhs - (rhs + borrow)`, returning the result along with the new borrow.
#[inline... | 1 | 5 | 5 |
e9f0efd17d4b284e4e5eba6c365a076fb40c26aa | Bogdan Opanchuk | 2025-11-26T22:27:39 | Implement `Encoding` for all `Uint`s (#1016)
A part of #1008 that only deals with `Encoding`:
- `Encoding` implemented for all `Uint`s. `Encoding::Repr` for `Uint` is
now an `EncodedUint` struct instead of an array.
- Macros deriving `Encoding` are removed.
- Relaxed the bound on the error of `Encoding::Repr as Tr... | diff --git a/src/lib.rs b/src/lib.rs
index f81f682..234b5ed 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -167,6 +167,8 @@
#[macro_use]
extern crate alloc;
+pub use uint::encoding::{EncodedUint, TryFromSliceError};
+
#[cfg(feature = "rand_core")]
pub use rand_core;
#[cfg(feature = "rlp")]
diff --git a/src/traits.r... | 8 | 169 | 95 |
5784b132976ff893c42877558e25e6916511ab74 | Tony Arcieri | 2025-11-26T21:46:04 | Revert "BREAKING: Make random_mod platform-independent" (#1017)
This reverts commit 62b90b8b39263d4970853e2ecfada62646bc8428 (#1010)
We're noticing CI failures on cross which seem to be related to this
change, e.g.
https://github.com/RustCrypto/crypto-bigint/actions/runs/19647957432/job/56267760132
It looks like it... | diff --git a/src/uint/boxed/rand.rs b/src/uint/boxed/rand.rs
index a2fd4ff..51252b9 100644
--- a/src/uint/boxed/rand.rs
+++ b/src/uint/boxed/rand.rs
@@ -28,7 +28,7 @@ impl RandomBits for BoxedUint {
}
let mut ret = BoxedUint::zero_with_precision(bits_precision);
- random_bits_core(rng, &mut r... | 2 | 35 | 35 |
75001b26d8297e009b3c8b4190ce51f3b2909fce | Andrew Whitehead | 2025-11-25T22:54:27 | Int wrapping multiplication improvements (#998)
This optimizes `Int::wrapping_mul` and `Uint::checked_mul_int` to make
use of `Uint::wrapping_mul`, and adds `Int::saturating_mul`.
Signed-off-by: Andrew Whitehead <cywolf@gmail.com> | diff --git a/benches/int.rs b/benches/int.rs
index 922e051..b138af7 100644
--- a/benches/int.rs
+++ b/benches/int.rs
@@ -112,6 +112,59 @@ fn bench_concatenating_mul(c: &mut Criterion) {
});
}
+fn bench_wrapping_mul(c: &mut Criterion) {
+ let mut rng = ChaCha8Rng::from_seed([7u8; 32]);
+ let mut group = c.... | 6 | 247 | 34 |
62b90b8b39263d4970853e2ecfada62646bc8428 | Steven Dee | 2025-11-25T22:53:08 | BREAKING: Make random_mod platform-independent (#1010)
Replaces the fancy platform-word-based logic with a simple call to
`random_bits_core` with rejection sampling. Each retry has p > 0.5
(worst case) of selecting a number inside the range
Fixes #1009 | diff --git a/src/uint/boxed/rand.rs b/src/uint/boxed/rand.rs
index 51252b9..a2fd4ff 100644
--- a/src/uint/boxed/rand.rs
+++ b/src/uint/boxed/rand.rs
@@ -28,7 +28,7 @@ impl RandomBits for BoxedUint {
}
let mut ret = BoxedUint::zero_with_precision(bits_precision);
- random_bits_core(rng, &mut r... | 2 | 35 | 35 |
e322137644fc852c57ca49704bb356631f5839de | Ilia Vlasov | 2025-11-25T15:32:51 | Add `BoxedMontyForm::as_montgomery_mut` (#1014)
This PR adds a mutable access method for the underlying Montgomery form
`BoxedUint` in `BoxedMontyForm` type. | diff --git a/src/modular/boxed_monty_form.rs b/src/modular/boxed_monty_form.rs
index c2f86ec..abba204 100644
--- a/src/modular/boxed_monty_form.rs
+++ b/src/modular/boxed_monty_form.rs
@@ -242,6 +242,11 @@ impl BoxedMontyForm {
&self.montgomery_form
}
+ /// Mutably access the [`BoxedMontyForm`] value... | 1 | 19 | 0 |
9cbea3af591b1479f392109781b89f9ef09013f3 | Tony Arcieri | 2025-11-06T02:58:52 | v0.7.0-rc.10 (#1002)
This release notably includes a bump to `rand_core` v0.10.0-rc-2 | diff --git a/Cargo.lock b/Cargo.lock
index bf168bd..f376140 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -238,7 +238,7 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-rc.9"
+version = "0.7.0-rc.10"
dependencies = [
"bincode",
... | 2 | 2 | 2 |
1ed6ce9c72d71dd7a2e6bd7aa4ce9dea51870e79 | Tony Arcieri | 2025-11-06T02:47:52 | Bump `rand_core` to v0.10.0-rc-2 (#1001)
Also migrates from `rand_chacha` to `chacha20` for an RNG | diff --git a/Cargo.lock b/Cargo.lock
index 4661a29..bf168bd 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -100,6 +100,17 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
+[[package]]
+name = "chacha20"
+... | 28 | 125 | 88 |
e66b783ffb2654fa523ea50aacdce58209789e8c | goldlinker | 2025-11-05T17:17:10 | chore: make some documents clearer (#993) | diff --git a/src/int/add.rs b/src/int/add.rs
index a18e4b2..729acce 100644
--- a/src/int/add.rs
+++ b/src/int/add.rs
@@ -21,8 +21,8 @@ impl<const LIMBS: usize> Int<LIMBS> {
// Step 2. determine whether overflow happened.
// Note:
- // - overflow can only happen when the inputs have the same s... | 3 | 4 | 4 |
7ba139806eea9944bce6bc7f606d07ec0848ee01 | Tony Arcieri | 2025-10-16T19:45:29 | v0.7.0-rc.9 (#989) | diff --git a/Cargo.lock b/Cargo.lock
index 19909c6..a42e271 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -218,7 +218,7 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-rc.8"
+version = "0.7.0-rc.9"
dependencies = [
"bincode",
"... | 2 | 2 | 2 |
215e6e427ef1cd57a6bed6aa04d41f57aeff31bb | Tony Arcieri | 2025-10-16T19:36:53 | Make AMM-based modular `pow` function generic (#988)
The AMM modpow implementation was previously specialized to
`BoxedMontyForm`. This extracts the implementation into the toplevel
`pow` module and makes it generic.
Note it doesn't yet add support for using it with `MontyForm`, but that
should be a straightforward n... | diff --git a/src/int.rs b/src/int.rs
index 0f1798b..6295ee2 100644
--- a/src/int.rs
+++ b/src/int.rs
@@ -242,6 +242,14 @@ impl<const LIMBS: usize> FixedInteger for Int<LIMBS> {
}
impl<const LIMBS: usize> Integer for Int<LIMBS> {
+ fn as_limbs(&self) -> &[Limb] {
+ self.0.as_limbs()
+ }
+
+ fn as_mut... | 7 | 195 | 138 |
303845fbe099815638f958b285c0e670125f9b47 | Tony Arcieri | 2025-10-16T18:00:43 | `BoxedMontyForm::pow` cleanups (#987)
Some minor cleanups which make adapting the code to be generic easier:
- Passes the whole `BoxedMontyParams` rather than individual parameters,
using that to construct `BoxedMultiMultiplier` using `From`
- Builds an array of powers rather than a `Vec`, which avoids an `alloc`
dep... | diff --git a/src/modular/boxed_monty_form/pow.rs b/src/modular/boxed_monty_form/pow.rs
index 59c5c12..a0d32bf 100644
--- a/src/modular/boxed_monty_form/pow.rs
+++ b/src/modular/boxed_monty_form/pow.rs
@@ -1,8 +1,8 @@
//! Modular exponentiation support for [`BoxedMontyForm`].
-use super::{BoxedMontyForm, mul::BoxedMo... | 1 | 18 | 16 |
f2a47ecb90f1a2e8de0b149140a5e08415480fb0 | Andrew Whitehead | 2025-10-16T17:26:45 | Optimize checked multiplication and squaring (#983)
This optimizes checked (and saturated) multiplication and squaring to
perform a wrapping multiplication with a carry, and check for overflow
by a more efficient method. For boxed integers this means the allocation
is no larger than needed. Performance is 30+% improve... | diff --git a/benches/boxed_uint.rs b/benches/boxed_uint.rs
index 7ce38b9..ead840b 100644
--- a/benches/boxed_uint.rs
+++ b/benches/boxed_uint.rs
@@ -74,6 +74,19 @@ fn bench_mul(c: &mut Criterion) {
)
});
+ group.bench_function("boxed_checked_mul", |b| {
+ b.iter_batched(
+ || {
+ ... | 10 | 243 | 79 |
a88a92bcdb0a597eb04ab2d587556b068a118bec | Andrew Whitehead | 2025-10-15T22:39:03 | Faster Montgomery multiplication (#974)
This adds an interleaved Montgomery multiplication and further optimizes
Boxed Montgomery multiplications by removing allocations. For
BoxedMontyForm at 4096 bits this is around a 40% improvement overall.
Benchmarked on a 2021 MacBook Pro with custom benchmarks for different
lim... | diff --git a/benches/monty.rs b/benches/monty.rs
index 0538971..453bc53 100644
--- a/benches/monty.rs
+++ b/benches/monty.rs
@@ -133,19 +133,6 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
)
});
- group.bench_function("Bernstein-Yang invert, U256", |b| {
- b.i... | 7 | 386 | 225 |
190739a19a7392edf1e73b5d3f64c9183f65cffa | Tony Arcieri | 2025-09-29T20:34:26 | Switch from `doc_auto_cfg` to `doc_cfg` (#968)
The former was removed from nightly. See RustCrypto/traits#2028 | diff --git a/src/lib.rs b/src/lib.rs
index d563e46..d98d54b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,5 +1,5 @@
#![no_std]
-#![cfg_attr(docsrs, feature(doc_auto_cfg))]
+#![cfg_attr(docsrs, feature(doc_cfg))]
#![doc = include_str!("../README.md")]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/R... | 1 | 1 | 1 |
46298d81e47474175bcda65b9c035e409e375d06 | Tony Arcieri | 2025-09-29T18:10:41 | v0.7.0-rc.8 (#967) | diff --git a/Cargo.lock b/Cargo.lock
index 8875213..1fb9699 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -218,7 +218,7 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-rc.7"
+version = "0.7.0-rc.8"
dependencies = [
"bincode",
"... | 2 | 2 | 2 |
14b757158e61bf1d53c9c5bf2a13c4ee515df574 | Tony Arcieri | 2025-09-24T21:27:24 | Bump `hybrid-array` to v0.4.4; enable `subtle` feature (#964)
Notably this release also enables the `const-generics` feature, which
only incurs an MSRV bump to a much earlier version than our current MSRV
so enabling it is more functionality for effectively free | diff --git a/Cargo.lock b/Cargo.lock
index 0bc68a8..8875213 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -302,10 +302,11 @@ checksum = "bcaaec4551594c969335c98c903c1397853d4198408ea609190f420500f6be71"
[[package]]
name = "hybrid-array"
-version = "0.4.3"
+version = "0.4.4"
source = "registry+https://github.com/rust... | 2 | 4 | 3 |
139180548d90380881517ab69e11c5b7bd35824a | Tony Arcieri | 2025-09-24T18:42:06 | v0.7.0-rc.7 (#961) | diff --git a/Cargo.lock b/Cargo.lock
index 0d58abe..0bc68a8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -218,7 +218,7 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-rc.6"
+version = "0.7.0-rc.7"
dependencies = [
"bincode",
"... | 2 | 2 | 2 |
eaa5206e05f073bed5f5759e6a01d0964a5627a8 | Erik | 2025-09-24T15:26:50 | Optimized Binary Extended GCD (#945)
This PR introduces the optimized binxgcd algorithm.
Supersedes #761 and #856 | diff --git a/benches/uint.rs b/benches/uint.rs
index 0106af8..4d1fcab 100644
--- a/benches/uint.rs
+++ b/benches/uint.rs
@@ -516,6 +516,43 @@ fn bench_gcd(c: &mut Criterion) {
group.finish();
}
+fn xgcd_bench<const LIMBS: usize>(g: &mut BenchmarkGroup<WallTime>, _x: Uint<LIMBS>) {
+ let mut rng = make_rng();... | 5 | 472 | 48 |
0cf0d1dd9611848845e2d9539e4588f7f9b39df4 | Tony Arcieri | 2025-09-23T23:26:06 | benches: fix `nightly` build failure (#960)
Some unnecessary parens | diff --git a/benches/uint.rs b/benches/uint.rs
index df2011d..0106af8 100644
--- a/benches/uint.rs
+++ b/benches/uint.rs
@@ -224,7 +224,7 @@ fn bench_mul(c: &mut Criterion) {
group.bench_function("wrapping_square, U4096xU4096", |b| {
b.iter_batched(
- || (U4096::random(&mut rng)),
+ ... | 1 | 1 | 1 |
7fd787d58097253968979c0c1d2f12b6f2139b60 | Andrew Whitehead | 2025-09-23T23:05:43 | Re-apply "Faster wrapping multiplication" (#954)
This reapplies the changes in #930 with additional tests for
`wrapping_mul` and `wrapping_square`, and a small fix for an error
occurring in the `rsa` crate.
Signed-off-by: Andrew Whitehead <cywolf@gmail.com> | diff --git a/benches/boxed_uint.rs b/benches/boxed_uint.rs
index e124afa..4bbdb7a 100644
--- a/benches/boxed_uint.rs
+++ b/benches/boxed_uint.rs
@@ -61,6 +61,19 @@ fn bench_mul(c: &mut Criterion) {
)
});
+ group.bench_function("boxed_wrapping_mul", |b| {
+ b.iter_batched(
+ || {
+ ... | 8 | 429 | 171 |
adb017394bcbb034779f8d45566d5651b435feb9 | Tony Arcieri | 2025-09-13T01:49:56 | v0.7.0-rc.6 (#953) | diff --git a/Cargo.lock b/Cargo.lock
index e4e05a1..68dee19 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -218,7 +218,7 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-rc.5"
+version = "0.7.0-rc.6"
dependencies = [
"bincode",
"... | 2 | 2 | 2 |
8b9e61a834d9fc80e7f3be05c47d9590bc5045b4 | Tony Arcieri | 2025-09-13T01:41:31 | Revert "Faster wrapping multiplication" (#952)
This reverts commit 9fd27fa004f25e0ac914887424a42ef760b6e06d (#930)
This is causing panics and other failures in the RSA crate:
thread 'key::tests::key_generation_multi_16_1024' panicked at
crypto-bigint-0.7.0-rc.5/src/uint/mul/schoolbook.rs:94:51:
index out... | diff --git a/benches/boxed_uint.rs b/benches/boxed_uint.rs
index 4bbdb7a..e124afa 100644
--- a/benches/boxed_uint.rs
+++ b/benches/boxed_uint.rs
@@ -61,19 +61,6 @@ fn bench_mul(c: &mut Criterion) {
)
});
- group.bench_function("boxed_wrapping_mul", |b| {
- b.iter_batched(
- || {
- ... | 6 | 162 | 344 |
72933cd725869f52e3c3e2637f6e4fa2cbaf1f9a | Tony Arcieri | 2025-09-12T20:11:32 | v0.7.0-rc.5 (#951) | diff --git a/Cargo.lock b/Cargo.lock
index 374f211..e4e05a1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -218,7 +218,7 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-rc.4"
+version = "0.7.0-rc.5"
dependencies = [
"bincode",
"... | 2 | 2 | 2 |
0257377f6f15eac391ae54439d6fe068bf4e87fa | Tony Arcieri | 2025-09-12T19:52:36 | Impl `(Fixed)Integer` and `Signed` for `Int` (#943)
Followup to #942
This factors the parts of `Integer` that `Int` currently doesn't
implement onto `Unsigned`, along with things that definitely belong on
`Unsigned`.
With that it becomes possible to impl `Integer` and `Signed` for `Int`. | diff --git a/src/int.rs b/src/int.rs
index e332dee..0f1798b 100644
--- a/src/int.rs
+++ b/src/int.rs
@@ -1,17 +1,17 @@
//! Stack-allocated big signed integers.
+use crate::{
+ Bounded, ConstChoice, ConstCtOption, Constants, FixedInteger, Integer, Limb, NonZero, Odd, One,
+ Signed, Uint, Word, Zero,
+};
use co... | 8 | 147 | 67 |
90461b6c73b05c292a5d23c7012fdcf26eae3699 | Tony Arcieri | 2025-09-12T19:11:43 | Extract `jacobi` module; add `Neg` impl (#950)
Factors `JacobiSymbol` out of the `traits` module and into its own
`jacobi` module.
Also adds a `Neg` impl, adapted from the one in `crypto-primes`, which
seems to be the one thing missing for `crypto-primes` to switch to it
for its Jacobi symbol type. | diff --git a/src/jacobi.rs b/src/jacobi.rs
new file mode 100644
index 0000000..45fd8f0
--- /dev/null
+++ b/src/jacobi.rs
@@ -0,0 +1,87 @@
+use crate::ConstChoice;
+use core::ops::Neg;
+use subtle::{Choice, ConstantTimeEq};
+
+/// Possible return values for Jacobi symbol calculations.
+#[derive(Debug, Copy, Clone)]
+#[r... | 3 | 90 | 58 |
7bb8509234898b8bba62aea0343bbd99b5439944 | Tony Arcieri | 2025-09-12T14:16:40 | ConstMontyForm: add `Zero` and `(Const)One` impls (#949)
Followup to #947 | diff --git a/src/modular/const_monty_form.rs b/src/modular/const_monty_form.rs
index d1b8139..2e2e052 100644
--- a/src/modular/const_monty_form.rs
+++ b/src/modular/const_monty_form.rs
@@ -15,7 +15,7 @@ use super::{
div_by_2::div_by_2,
reduction::{montgomery_reduction, montgomery_retrieve},
};
-use crate::{C... | 1 | 31 | 1 |
d83d30e42272fa80c017ddaf016aad083dc1bd66 | Tony Arcieri | 2025-09-12T03:40:18 | Add `MontyParams::{one, r2}` accessor methods (#948)
Mostly I wanted to compute that `R^2` matched a particular test vector
when retrofitting `ConstMontyForm` into another codebase (`p256`).
These constants might also be helpful for plugging into other algorithms
that operate on values in Montgomery form. | diff --git a/src/modular/monty_form.rs b/src/modular/monty_form.rs
index 7f2f874..590f2ff 100644
--- a/src/modular/monty_form.rs
+++ b/src/modular/monty_form.rs
@@ -101,6 +101,16 @@ impl<const LIMBS: usize> MontyParams<LIMBS> {
&self.modulus
}
+ /// 1 in Montgomery form (a.k.a. `R`).
+ pub const f... | 1 | 10 | 0 |
b80ed708fdc15182381d572586bc255f0382a334 | Tony Arcieri | 2025-09-11T16:50:07 | Add `One` trait ala `Zero` (#947)
Adds a trait for the multiplicative identity element of `Self`, similar
to `num_traits::One` but with support for constant-time comparisons and
predicate methods like `is_one`.
It follows the same basic shape as the existing `Zero` trait.
The `Integer` trait is now bounded on it, a... | diff --git a/src/int.rs b/src/int.rs
index d5087c9..e332dee 100644
--- a/src/int.rs
+++ b/src/int.rs
@@ -1,15 +1,17 @@
//! Stack-allocated big signed integers.
use core::fmt;
+use num_traits::{ConstOne, ConstZero};
-use num_traits::ConstZero;
#[cfg(feature = "serde")]
use serdect::serde::{Deserialize, Deseriali... | 8 | 260 | 71 |
79d690bdb9870b58a4463374a54e6bc81b32554b | Erik | 2025-09-11T15:13:11 | Implement `Int::wrapping_mul` (#946)
As requested in RustCrypto/crypto-bigint#943 | diff --git a/src/int/mul.rs b/src/int/mul.rs
index 1eb6a3c..abcfd7d 100644
--- a/src/int/mul.rs
+++ b/src/int/mul.rs
@@ -1,7 +1,7 @@
//! [`Int`] multiplication operations.
use core::ops::{Mul, MulAssign};
-
+use num_traits::WrappingMul;
use subtle::CtOption;
use crate::{Checked, CheckedMul, ConcatMixed, ConstCh... | 1 | 60 | 16 |
00873c648ef9c3d846e2f7122d64d7e7a51d7bda | Tony Arcieri | 2025-09-10T17:55:02 | Add `Signed` and `Unsigned` marker traits (#942)
These are notably bounded on `Integer` and thus usable in place of
`Integer` anywhere a signed or unsigned integer specifically is expected
I note there's TODOs to impl `Integer` and `FixedInteger` for `Int`. I
went ahead and added another TODO to impl `Signed`. | diff --git a/src/int.rs b/src/int.rs
index bc1bb27..d5087c9 100644
--- a/src/int.rs
+++ b/src/int.rs
@@ -240,6 +240,8 @@ impl<const LIMBS: usize> Default for Int<LIMBS> {
// TODO: impl Integer
+// TODO: impl Signed
+
impl<const LIMBS: usize> ConstZero for Int<LIMBS> {
const ZERO: Self = Self::ZERO;
}
diff -... | 4 | 19 | 2 |
9fd27fa004f25e0ac914887424a42ef760b6e06d | Andrew Whitehead | 2025-09-09T14:57:29 | Faster wrapping multiplication (#930)
This implements basic wrapping multiplication for `Uint` and
`BoxedUint`, deferring to Karatsuba multiplication when it would be
faster (estimated by benchmarks). The number of limbs needs to get
fairly high before it needs to switch over though, and `Uint` currently
only implemen... | diff --git a/benches/boxed_uint.rs b/benches/boxed_uint.rs
index e124afa..4bbdb7a 100644
--- a/benches/boxed_uint.rs
+++ b/benches/boxed_uint.rs
@@ -61,6 +61,19 @@ fn bench_mul(c: &mut Criterion) {
)
});
+ group.bench_function("boxed_wrapping_mul", |b| {
+ b.iter_batched(
+ || {
+ ... | 6 | 344 | 162 |
732300c947ac92a03368afb74a4f699931f55cd5 | Tony Arcieri | 2025-09-02T22:55:26 | v0.7.0-rc.4 (#939) | diff --git a/Cargo.lock b/Cargo.lock
index 767015e..00e0821 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -218,7 +218,7 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-rc.3"
+version = "0.7.0-rc.4"
dependencies = [
"bincode",
"... | 2 | 2 | 2 |
c1b1303cb57e0bf5cf3feba4b23183a19fbb8f4b | Andrew Whitehead | 2025-09-02T22:08:53 | Faster retrieval from Montygomery form (#933)
This optimizes the `retrieve` methods of Montygomery forms by
implementing a specialized Montgomery multiplication. This corresponds
to the `almost_montgomery_mul_by_one` method (which is removed). In my
tests performance is about 7% better for `BoxedMontyForm` at 4096 bit... | diff --git a/src/modular/boxed_monty_form.rs b/src/modular/boxed_monty_form.rs
index 73ec662..5517387 100644
--- a/src/modular/boxed_monty_form.rs
+++ b/src/modular/boxed_monty_form.rs
@@ -13,7 +13,7 @@ use mul::BoxedMontyMultiplier;
use crate::{
BoxedUint, Limb, Monty, Odd, U64, Word,
- modular::{MontyParam... | 5 | 69 | 66 |
5be516c797e0aa286ba0f4c01062679e2b2c0901 | Tony Arcieri | 2025-09-02T19:13:37 | Cargo.lock: update dependencies (#937)
Updates the following dependencies:
$ cargo update
Updating crates.io index
Locking 61 packages to latest compatible versions
Updating anstyle v1.0.10 -> v1.0.11
Updating autocfg v1.4.0 -> v1.5.0
Updating base16ct v0.2.0 -> v0.3.0
Updating bitflags v... | diff --git a/Cargo.lock b/Cargo.lock
index ef9fbed..767015e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -19,21 +19,21 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
[[package]]
name = "anstyle"
-version = "1.0.10"
+version = "1.0.11"
source = "registry+https://github.com/rust-lang... | 1 | 136 | 155 |
ee9b20e0886212f9c46844542eda7e118d593124 | Tony Arcieri | 2025-09-02T19:04:44 | v0.7.0-rc.3 (#936)
Notably includes `hybrid-array` v0.4 support | diff --git a/Cargo.lock b/Cargo.lock
index fce7af9..ef9fbed 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -224,7 +224,7 @@ checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-rc.2"
+version = "0.7.0-rc.3"
dependencies = [
"bincode",
"... | 2 | 2 | 2 |
22ac4ade73a2e280972d67774ed5c5d8c95dbe33 | Tony Arcieri | 2025-09-01T21:57:28 | Bump `hybrid-array` to v0.4 (#934) | diff --git a/Cargo.lock b/Cargo.lock
index 9f72849..fce7af9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -308,9 +308,9 @@ checksum = "bcaaec4551594c969335c98c903c1397853d4198408ea609190f420500f6be71"
[[package]]
name = "hybrid-array"
-version = "0.3.1"
+version = "0.4.0"
source = "registry+https://github.com/rust-l... | 2 | 3 | 3 |
a13a59c449e770f16b669fa231cb0a941bb249aa | Andrew Whitehead | 2025-08-30T13:26:42 | Add Jacobi symbol calculation (#927)
This implementation is based on `bingcd`. It does not appear to affect
the GCD performance, being optimized away when it is not needed. This
would be useful in `primefield` for adding
`is_square`/`is_square_vartime` methods which should be faster than
`sqrt`.
Signed-off-by: Andrew... | diff --git a/benches/const_monty.rs b/benches/const_monty.rs
index 4723bc0..a6a8c3a 100644
--- a/benches/const_monty.rs
+++ b/benches/const_monty.rs
@@ -119,6 +119,22 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
)
});
+ group.bench_function("jacobi_symbol", |b| {
+ ... | 18 | 758 | 141 |
d58cfea32d12803ea6c2b81db421316812dad481 | Tony Arcieri | 2025-08-23T02:55:17 | v0.7.0-rc.2 (#931) | diff --git a/Cargo.lock b/Cargo.lock
index d2e1798..9f72849 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -224,7 +224,7 @@ checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-rc.1"
+version = "0.7.0-rc.2"
dependencies = [
"bincode",
"... | 2 | 2 | 2 |
3c3a24a85c439c8946e133eb717bfbf8e86148bc | Tony Arcieri | 2025-08-19T23:31:11 | Add `NonZero::<Uint>::{from_be_hex, from_le_hex}` (#928)
Adds panicking `const fn` constructors which are useful for defining
`NonZero` constants.
We need these for the `elliptic-curve` crate after #917, because we
previously didn't store the curve's order as `NonZero` (since the
associated constant long, long predat... | diff --git a/src/non_zero.rs b/src/non_zero.rs
index 6834824..7228c56 100644
--- a/src/non_zero.rs
+++ b/src/non_zero.rs
@@ -139,10 +139,12 @@ impl NonZero<Limb> {
impl<const LIMBS: usize> NonZeroUint<LIMBS> {
/// Creates a new non-zero integer in a const context.
- /// Panics if the value is zero.
///
... | 2 | 23 | 3 |
198734b6172d9e115610584812e9fe13163e6b63 | Andrew Whitehead | 2025-08-15T17:34:23 | Remove extra bounds on `ConstMontyParams` impl (#926)
No longer needed.
Signed-off-by: Andrew Whitehead <cywolf@gmail.com> | diff --git a/src/modular/const_monty_form/macros.rs b/src/modular/const_monty_form/macros.rs
index e267d32..864c05c 100644
--- a/src/modular/const_monty_form/macros.rs
+++ b/src/modular/const_monty_form/macros.rs
@@ -35,11 +35,7 @@ macro_rules! const_monty_params {
#[doc = $doc]
#[derive(Clone, Copy, ... | 1 | 1 | 5 |
ae429ded556a3e7fcecb6d9b5e8ba1c5106d1177 | Tony Arcieri | 2025-08-15T14:44:02 | v0.7.0-rc.1 (#925) | diff --git a/Cargo.lock b/Cargo.lock
index a461163..3bfd8f2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -224,7 +224,7 @@ checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-rc.0"
+version = "0.7.0-rc.1"
dependencies = [
"bincode",
"... | 2 | 2 | 2 |
97fd5ae58787609f2b0f0f62db4f89bb03240bd9 | Andrew Whitehead | 2025-08-15T14:33:46 | Clean up GCD API (#923)
This mostly avoids exposing the separate `safegcd`/`bingcd`
implementations. Both use the same pre-processing for inputs so the
active variant only needs to be selected in `Odd<Uint>`. The
`safegcd(_vartime)` and `bingcd(_vartime)` methods are only exposed for
benchmarking at the moment.
Becau... | diff --git a/benches/uint.rs b/benches/uint.rs
index f738005..d5590b9 100644
--- a/benches/uint.rs
+++ b/benches/uint.rs
@@ -427,6 +427,32 @@ fn gcd_bench<const LIMBS: usize>(g: &mut BenchmarkGroup<WallTime>, _x: Uint<LIMB
BatchSize::SmallInput,
)
});
+
+ g.bench_function(BenchmarkId::new(... | 7 | 272 | 373 |
41f3ea53a8806297786cdf7cb049ba8e4a007deb | Andrew Whitehead | 2025-08-15T14:13:16 | Performance improvements for `bingcd` (#924)
This adds the faster `bingcd` step function from #905 as well as
improvements to the `compact` method, reducing the number of full-width
shifts required.
greatest common divisor/bingcd/1
time: [227.95 ns 229.09 ns 230.74 ns]
... | diff --git a/src/modular/bingcd/compact.rs b/src/modular/bingcd/compact.rs
index edff0b0..0385114 100644
--- a/src/modular/bingcd/compact.rs
+++ b/src/modular/bingcd/compact.rs
@@ -1,5 +1,5 @@
/// Constructing a compact representation of a [`Uint`]
-use crate::Uint;
+use crate::{Limb, Uint};
impl<const LIMBS: usize... | 7 | 98 | 57 |
ea5c388472a9b784bb908fcb63a1ac8d6daa98e2 | Andrew Whitehead | 2025-08-12T03:06:40 | Faster constant time bit shifts (#919)
This update adds internal `bounded_wrapping_sh(r/l)` and
`wrapping_sh(r/l)_by_limbs` methods and optimizes `shr` and `shl` for
`Uint` by applying sub-limb and super-limb shifts in different ways.
Performance is generally improved (a lot), with division methods,
`sqrt`, `bingcd`, ... | diff --git a/src/limb.rs b/src/limb.rs
index afc0e72..ce9fd36 100644
--- a/src/limb.rs
+++ b/src/limb.rs
@@ -95,6 +95,9 @@ impl Limb {
#[cfg(target_pointer_width = "64")]
pub const BYTES: usize = 8;
+ /// `floor(log2(Self::BITS))`.
+ pub const LOG2_BITS: u32 = u32::BITS - (Self::BITS - 1).leading_zero... | 4 | 173 | 78 |
c3befa5259e4e7d006d23e4450852e0a02799f24 | Andrew Whitehead | 2025-08-06T17:05:22 | Simplify `Uint::add_mod`, `Uint::double_mod` (#917)
This also adjusts the signature of `Uint::double_mod` to require a
`NonZero` modulus, consistent with the other operations.
`Uint::sub_mod_with_carry` is changed to match the version previously in
`add_mod` and avoid a performance regression.
Signed-off-by: Andrew ... | diff --git a/src/modular/add.rs b/src/modular/add.rs
index 16e7f30..6b489db 100644
--- a/src/modular/add.rs
+++ b/src/modular/add.rs
@@ -12,5 +12,5 @@ pub(crate) const fn double_montgomery_form<const LIMBS: usize>(
a: &Uint<LIMBS>,
modulus: &Odd<Uint<LIMBS>>,
) -> Uint<LIMBS> {
- a.double_mod(&modulus.0)
... | 3 | 5 | 23 |
4cc51659f26f6e95da123c01ff5c60351c1c355e | Andrew Whitehead | 2025-08-06T17:01:00 | Fix iteration count for safegcd (#918)
As noted in #905 this is the correct iteration count when `g ≤ f` is not
ensured. There is no real impact on performance.
Signed-off-by: Andrew Whitehead <cywolf@gmail.com> | diff --git a/src/modular/safegcd.rs b/src/modular/safegcd.rs
index d89c197..964f243 100644
--- a/src/modular/safegcd.rs
+++ b/src/modular/safegcd.rs
@@ -382,7 +382,7 @@ const fn shr_in_place_wide<const L: usize, const H: usize>(
/// safegcd-bounds: https://github.com/sipa/safegcd-bounds
#[inline]
const fn iterations... | 1 | 1 | 1 |
61bc4dcce5023fd77489af4e380ac7ebee7faa7b | Tony Arcieri | 2025-08-06T15:41:17 | Bump `der` dependency to v0.8.0-rc.8 (#916) | diff --git a/Cargo.lock b/Cargo.lock
index 8a739a8..a461163 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -246,9 +246,9 @@ dependencies = [
[[package]]
name = "der"
-version = "0.8.0-rc.7"
+version = "0.8.0-rc.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e2fe0a4fafae25053c19a03fef... | 3 | 5 | 5 |
f2f5922beb1f0451511afb66b0434433ee4a29bd | Andrew Whitehead | 2025-08-06T15:23:53 | Add SquareMod trait and implement for Uint, BoxedUint (#915)
Mostly convenience methods for now, although it might be possible to
further optimize them later.
Signed-off-by: Andrew Whitehead <cywolf@gmail.com> | diff --git a/src/modular/boxed_monty_form.rs b/src/modular/boxed_monty_form.rs
index e866645..73ec662 100644
--- a/src/modular/boxed_monty_form.rs
+++ b/src/modular/boxed_monty_form.rs
@@ -55,7 +55,7 @@ impl BoxedMontyParams {
.wrapping_add(&BoxedUint::one());
// `R^2 mod modulus`, used to conve... | 5 | 54 | 6 |
f53686f9ed0ebdd387e09a1a07733f45073a240c | Andrew Whitehead | 2025-08-06T13:10:07 | Update modular operations to use NonZero modulus (#914)
The modulus type is added as a trait parameter so it can be overridden,
allowing implementations for `Odd<Self>` or `NonZero<Limb>` for
instance. `BoxedUint::mul_mod` is simplified along the way.
Fixes #903
Signed-off-by: Andrew Whitehead <cywolf@gmail.com> | diff --git a/benches/boxed_uint.rs b/benches/boxed_uint.rs
index 8656ad4..e124afa 100644
--- a/benches/boxed_uint.rs
+++ b/benches/boxed_uint.rs
@@ -281,10 +281,14 @@ fn bench_invert(c: &mut Criterion) {
group.bench_function("invert_mod", |b| {
b.iter_batched(
|| {
- (
+ ... | 28 | 164 | 138 |
f12c1a5fc085ddec7a255960ab7075309880e7e3 | Tony Arcieri | 2025-08-05T00:14:57 | v0.7.0-rc.0 (#910) | diff --git a/Cargo.lock b/Cargo.lock
index f804f5e..8a739a8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -224,7 +224,7 @@ checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-pre.7"
+version = "0.7.0-rc.0"
dependencies = [
"bincode",
... | 2 | 2 | 2 |
81bd7454743b3eabfea9b0d6499027d5cc93fe9e | Tony Arcieri | 2025-08-04T23:36:34 | Change `const_monty_form!` to define a type alias (#909)
Instead of constructing a value, it now defines a type alias, then you
can use `MyType::new(&uint)` as the constructor.
Closes #878 | diff --git a/src/lib.rs b/src/lib.rs
index 38c8499..ba7f0e1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -90,9 +90,11 @@
//!
//! ### Modular arithmetic
//!
-//! This library has initial support for modular arithmetic in the form of the
-//! [`AddMod`], [`SubMod`], [`NegMod`], and [`MulMod`] traits, as well as the
-//... | 8 | 43 | 40 |
b7c0144f2720aea78900451033fc1a2de0fdd742 | Tony Arcieri | 2025-08-04T21:18:59 | Remove `ConstMontyFormInverter` (#908)
Like #907, this is a vestige of the old safegcd implementation.
`ConstMontyForm::invert` now works for all sizes of limbs, so anyone
needing to do `ConstMontyForm` inversion in a `const fn` context should
just use that. | diff --git a/src/modular.rs b/src/modular.rs
index 78306b9..71985ea 100644
--- a/src/modular.rs
+++ b/src/modular.rs
@@ -33,7 +33,7 @@ mod sub;
pub(crate) mod boxed_monty_form;
pub use self::{
- const_monty_form::{ConstMontyForm, ConstMontyParams, invert::ConstMontyFormInverter},
+ const_monty_form::{ConstMon... | 2 | 2 | 91 |
cb71acaa8bc6d39439a71612f5560cb7b8a19db5 | Tony Arcieri | 2025-08-04T18:26:52 | Remove `ConstMontyParams::inverter` (#907)
Precomputed inverters are vestiges of the old safegcd implementation,
most of which were already removed in #894 and #898 | diff --git a/benches/const_monty.rs b/benches/const_monty.rs
index 2e5518c..4723bc0 100644
--- a/benches/const_monty.rs
+++ b/benches/const_monty.rs
@@ -87,18 +87,6 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
)
});
- group.bench_function("Bernstein-Yang invert, U25... | 4 | 0 | 54 |
9a09377161f3b2c48b071055b0e162e9ea96db22 | Tony Arcieri | 2025-08-04T17:29:26 | Have `Reduce` borrow its input (#906)
Impls of `Reduce` only subsequently call functions which borrow, and
have no need to actually take ownership of their inputs.
Per the Rust API guidelines, in such a case a function should borrow its
input:
https://rust-lang.github.io/api-guidelines/flexibility.html?highlight=cl... | diff --git a/src/modular/const_monty_form/reduce.rs b/src/modular/const_monty_form/reduce.rs
index d5c3c3d..1336ff9 100644
--- a/src/modular/const_monty_form/reduce.rs
+++ b/src/modular/const_monty_form/reduce.rs
@@ -1,17 +1,7 @@
-use crate::{Reduce, Uint, modular::ConstMontyForm};
-
use super::ConstMontyParams;
+use ... | 2 | 2 | 12 |
380d4d48793c250529667c83e01e7c349534b0e6 | Andrew Whitehead | 2025-08-04T16:54:50 | Update `BoxedUint::div_rem` to accept mixed sized inputs (#902)
Allowing mixed size inputs means that `rem` can be performed on 'wide'
inputs without resizing the modulus, improving performance. The updated
method can also be used to remove restrictions on `BoxedUint::mul_mod`
but that's another update.
Signed-off-by... | diff --git a/src/modular/boxed_monty_form.rs b/src/modular/boxed_monty_form.rs
index 18ea60d..e866645 100644
--- a/src/modular/boxed_monty_form.rs
+++ b/src/modular/boxed_monty_form.rs
@@ -12,7 +12,7 @@ use super::{Retrieve, div_by_2};
use mul::BoxedMontyMultiplier;
use crate::{
- BoxedUint, Limb, Monty, Odd, Re... | 6 | 184 | 84 |
86f63975ec7b5cedbae11a1d22a81a3613a168c2 | Andrew Whitehead | 2025-08-04T16:50:43 | Add Uint::rem_wide (#896)
This adds a constant time `rem_wide` method (based on `rem_wide_vartime`
and `div_rem`). It is used to speed up `MontyParams::new` about 25% and
`Uint::mul_mod` about 65% while removing some annoying trait bounds.
Signed-off-by: Andrew Whitehead <cywolf@gmail.com> | diff --git a/benches/uint.rs b/benches/uint.rs
index 53eedf2..821dc62 100644
--- a/benches/uint.rs
+++ b/benches/uint.rs
@@ -312,6 +312,18 @@ fn bench_division(c: &mut Criterion) {
)
});
+ group.bench_function("rem_wide, U256", |b| {
+ b.iter_batched(
+ || {
+ let (x_... | 5 | 143 | 43 |
31a896b2901bada254c1aeb3a5478751ef122911 | daxpedda | 2025-08-04T15:32:19 | `ConstMontyForm::lincomb_vartime()` is constant-time (#904)
From: https://docs.rs/crypto-bigint/0.7.0-pre.7/crypto_bigint/modular/struct.ConstMontyForm.html#method.lincomb_vartime
> This method is variable time only with the value of the modulus.
With `ConstMontyForm`, the modulus is a constant and source code liter... | diff --git a/benches/const_monty.rs b/benches/const_monty.rs
index e9a7162..2e5518c 100644
--- a/benches/const_monty.rs
+++ b/benches/const_monty.rs
@@ -131,11 +131,11 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
)
});
- group.bench_function("lincomb_vartime, U256*U... | 2 | 4 | 7 |
e03bcef981fba14a17058ee0191c3297e02e6c2c | Andrew Whitehead | 2025-08-02T16:34:10 | Fix `Uint` division for small numerators (#901)
`Uint::div_rem` could panic for some mixed-size inputs, this adjustment
fixes those cases (and improves performance).
This does not apply to `BoxedUint` because it currently requires both
inputs to have the same bit precision.
Signed-off-by: Andrew Whitehead <cywolf@gm... | diff --git a/src/uint/div.rs b/src/uint/div.rs
index 624b6d9..cea79b6 100644
--- a/src/uint/div.rs
+++ b/src/uint/div.rs
@@ -6,6 +6,7 @@ use super::div_limb::{
};
use crate::{
CheckedDiv, ConstChoice, DivRemLimb, DivVartime, Limb, NonZero, RemLimb, Uint, Wrapping,
+ const_choice::u32_min,
};
use core::ops::... | 1 | 87 | 46 |
9d748da82949ac79005bd9560a8f2dbb9e5443e3 | Tony Arcieri | 2025-07-30T17:00:54 | Remove `modular::montgomery_reduction` from public API (#900)
It's an implementation detail. It was originally `pub` because it was
used by the `const_monty_params!` nee `impl_modulus!` macro, however
that has been changed to use `const fn` constructors instead. | diff --git a/src/modular.rs b/src/modular.rs
index 1f35565..78306b9 100644
--- a/src/modular.rs
+++ b/src/modular.rs
@@ -35,7 +35,6 @@ pub(crate) mod boxed_monty_form;
pub use self::{
const_monty_form::{ConstMontyForm, ConstMontyParams, invert::ConstMontyFormInverter},
monty_form::{MontyForm, MontyParams},
-... | 2 | 1 | 2 |
1c3393c6dbb095fd7555598154bf75ab2fad89da | Tony Arcieri | 2025-07-29T17:39:01 | Remove `*SafeGcdInverter` types from public API (#898)
Previously they needed to be public to make trait bounds work, but now
that those bounds are no longer required (#894) these types no longer
need to be public, as they're otherwise an implementation detail. | diff --git a/src/modular.rs b/src/modular.rs
index 30049d6..1f35565 100644
--- a/src/modular.rs
+++ b/src/modular.rs
@@ -36,14 +36,12 @@ pub use self::{
const_monty_form::{ConstMontyForm, ConstMontyParams, invert::ConstMontyFormInverter},
monty_form::{MontyForm, MontyParams},
reduction::montgomery_reduct... | 5 | 14 | 54 |
7e90ef2c439fcb917b7a491352e9fe07524a7cb0 | Tony Arcieri | 2025-07-29T14:18:22 | Remove `BoxedMontyFormInverter` (#897)
Legacy of the `PrecomputeInverter` trait, which was removed in #894 | diff --git a/src/modular/boxed_monty_form/invert.rs b/src/modular/boxed_monty_form/invert.rs
index 04bef51..7264d2c 100644
--- a/src/modular/boxed_monty_form/invert.rs
+++ b/src/modular/boxed_monty_form/invert.rs
@@ -2,23 +2,38 @@
use super::{BoxedMontyForm, BoxedMontyParams};
use crate::{Invert, modular::BoxedSafe... | 1 | 25 | 60 |
bfd010775118fe29c02f5141a80a8e153472ead7 | Andrew Whitehead | 2025-07-28T21:48:09 | Remove unused R3 from Montgomery parameters (#895)
This could be used in reducing a 'wide' value through Montgomery
reduction, but it isn't currently.
Removing this parameter has a strangely positive effect on the `monty`
benchmarks (on my machine) which I don't really understand. Maybe just
better register usage, or... | diff --git a/src/modular/boxed_monty_form.rs b/src/modular/boxed_monty_form.rs
index c216d6d..18ea60d 100644
--- a/src/modular/boxed_monty_form.rs
+++ b/src/modular/boxed_monty_form.rs
@@ -34,8 +34,6 @@ struct BoxedMontyParamsInner {
one: BoxedUint,
/// R^2, used to move into Montgomery form
r2: BoxedUin... | 2 | 0 | 32 |
ebc60f30bff12f2079772d04b20613fad69cc7f8 | Tony Arcieri | 2025-07-28T21:47:10 | Remove `PrecomputedInverter` and `Inverter` traits (#894)
`PrecomputedInverter` was largely a hack around the previous
implementation of safegcd, namely that it used a 62-bit unsaturated
implementation, which needed to be bounded by a different const generic
parameter `UNSAT_LIMBS`. Namely the `Invert` impl was bounde... | diff --git a/benches/const_monty.rs b/benches/const_monty.rs
index 6ace2f3..e9a7162 100644
--- a/benches/const_monty.rs
+++ b/benches/const_monty.rs
@@ -91,7 +91,7 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
b.iter_batched(
|| {
let x = ConstMon... | 17 | 51 | 295 |
634a12361d96ff22cb2cc61684f6df6a8d4a492e | Andrew Whitehead | 2025-07-28T19:41:56 | Update modular inverse calculation in MontyParams, BoxedMontyParams (#893)
This reuses `invert_mod_u64` to calculate the modular inverse, which
improves performance when creating new MontyParams and BoxedMontyParams
by around 20%. `Uint::mul_mod` is similarly improved.
Signed-off-by: Andrew Whitehead <cywolf@gmail.co... | diff --git a/src/modular.rs b/src/modular.rs
index cd9b357..a2851fc 100644
--- a/src/modular.rs
+++ b/src/modular.rs
@@ -82,7 +82,7 @@ mod tests {
U256::from_be_hex("0748d9d99f59ff1105d314967254398f2b6cedcb87925c23c999e990f3f29c6d")
);
assert_eq!(
- Modulus1::PARAMS.mod_neg_inv... | 17 | 128 | 160 |
f64bf092dd6668377949cd57faedcbc76819ce0d | Andrew Whitehead | 2025-07-26T00:50:34 | Fix edge case for Uint::invert_odd_mod with modulus 1 (#890)
One last edge case I noticed in testing the Boxed implementation against
num-bigint.
Signed-off-by: Andrew Whitehead <cywolf@gmail.com> | diff --git a/src/modular/safegcd.rs b/src/modular/safegcd.rs
index 77c9cc3..77cfa37 100644
--- a/src/modular/safegcd.rs
+++ b/src/modular/safegcd.rs
@@ -129,8 +129,7 @@ pub const fn invert_odd_mod<const LIMBS: usize, const VARTIME: bool>(
invert_odd_mod_precomp::<LIMBS, VARTIME>(a, m, mi, &Uint::ONE)
}
-/// Cal... | 2 | 9 | 4 |
6ae6551139185e3292960bb76738914aca231949 | Andrew Whitehead | 2025-07-26T00:50:03 | Track caller when unwrapping ConstCtOption (#888)
This improves error messages by reporting where `unwrap()`,
`expect(msg)` was called rather than the assertion line in
const_choice.rs.
Signed-off-by: Andrew Whitehead <cywolf@gmail.com> | diff --git a/src/const_choice.rs b/src/const_choice.rs
index dba03f8..70c160f 100644
--- a/src/const_choice.rs
+++ b/src/const_choice.rs
@@ -337,8 +337,12 @@ impl<T> ConstCtOption<T> {
/// This returns the underlying value but panics if it is not `Some`.
#[inline]
+ #[track_caller]
pub fn unwrap(sel... | 1 | 15 | 1 |
6372c4f6821af5569205ca888dd608df3a3ab94f | Tony Arcieri | 2025-07-21T17:37:44 | Revert "Rename `div_by_2` to `shr1`" (#884)
This reverts commit 5f48318a49b72500af825d1ef0d70c32a3319fc9 (#882).
My original rationale for this was to share code with a larger `shr`
implementation. That could be done with repeat applications of `shr1`,
though using a Montgomery multiplication would probably be faster... | diff --git a/benches/monty.rs b/benches/monty.rs
index 87fe781..b982a34 100644
--- a/benches/monty.rs
+++ b/benches/monty.rs
@@ -180,13 +180,13 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
)
});
- group.bench_function("shr1, MontyForm(U256)", |b| {
+ group.bench_... | 9 | 36 | 70 |
08377c5a61d6d891f37b465d5222b645b80e672d | Tony Arcieri | 2025-07-21T13:45:16 | `ConstMontyForm`: add `ConstCtOption` support (#883)
This is needed to retrieve the results of inversions from a `const fn`.
Computing inversions at compile time is used by the field
implementations in https://github.com/RustCrypto/elliptic-curves | diff --git a/src/const_choice.rs b/src/const_choice.rs
index 461abf1..f5ee505 100644
--- a/src/const_choice.rs
+++ b/src/const_choice.rs
@@ -1,7 +1,8 @@
use subtle::{Choice, CtOption};
use crate::{
- Int, Limb, NonZero, NonZeroInt, Odd, OddInt, Uint, WideWord, Word, modular::SafeGcdInverter,
+ Int, Limb, NonZ... | 2 | 31 | 2 |
5f48318a49b72500af825d1ef0d70c32a3319fc9 | Tony Arcieri | 2025-07-20T02:31:01 | Rename `div_by_2` to `shr1` (#882)
For a few reasons:
- It's more consistent with the existing uses of `shr1` in the codebase
- It's implemented in terms of `shr1` already
- With a little work it can be adapted into a full-fledged `shr`
This preserves the `div_by_2*` names with deprecations | diff --git a/benches/monty.rs b/benches/monty.rs
index b982a34..87fe781 100644
--- a/benches/monty.rs
+++ b/benches/monty.rs
@@ -180,13 +180,13 @@ fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) {
)
});
- group.bench_function("div_by_2, U256", |b| {
+ group.bench_functio... | 9 | 70 | 36 |
84b7edc78defc7a3a245dabde07df7f53db96ca7 | David | 2025-07-19T21:54:47 | Simpler carrying_mul_add (#870)
The previous version was doing all the right things but in a slightly
roundabout way. I think this is more readable. | diff --git a/src/primitives.rs b/src/primitives.rs
index 34014ea..a8070f9 100644
--- a/src/primitives.rs
+++ b/src/primitives.rs
@@ -58,13 +58,30 @@ pub(crate) const fn carrying_mul_add(
let lhs = lhs as WideWord;
let rhs = rhs as WideWord;
let addend = addend as WideWord;
- let ret = (lhs * rhs) + ad... | 1 | 23 | 6 |
0d39525d31b095ac48c66ad3ac739f32a611d6a3 | Tony Arcieri | 2025-07-19T21:54:11 | ConstMontyForm: remove superfluous intermediate function (#879)
The internal `from_integer` function is unnecessary because the only
caller is `new`, so this gets rid of it and moves the function body to
`new`. | diff --git a/src/modular/const_monty_form.rs b/src/modular/const_monty_form.rs
index 0996710..4477c33 100644
--- a/src/modular/const_monty_form.rs
+++ b/src/modular/const_monty_form.rs
@@ -84,9 +84,8 @@ impl<MOD: ConstMontyParams<LIMBS>, const LIMBS: usize> ConstMontyForm<MOD, LIMBS
phantom: PhantomData,
... | 1 | 2 | 8 |
b9eab44a44290e5b5e2ffdae652544f9c13c0c6d | Tony Arcieri | 2025-07-19T14:33:41 | v0.7.0-pre.7 (#877) | diff --git a/Cargo.lock b/Cargo.lock
index 2e81e27..0805d0b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -224,7 +224,7 @@ checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-pre.6"
+version = "0.7.0-pre.7"
dependencies = [
"bincode",
... | 2 | 2 | 2 |
3b47a8a0b70a52e4877c34d531cc0023ce6fbb46 | Tony Arcieri | 2025-07-18T20:19:19 | Unify `ConstMontyParams` and `MontyParams` (#873)
Changes `ConstMontyParams` from having associated constants that
duplicate `MontyParams` to having an associated `MontyParams` constant.
`MontyParams` has `const fn` constructors, which the
`const_monty_params!` (and legacy `impl_modulus!`) macros have been
changed to... | diff --git a/benches/const_monty.rs b/benches/const_monty.rs
index bbe6938..6ace2f3 100644
--- a/benches/const_monty.rs
+++ b/benches/const_monty.rs
@@ -21,7 +21,7 @@ fn bench_montgomery_conversion<M: Measurement>(group: &mut BenchmarkGroup<'_, M>
let mut rng = ChaChaRng::from_os_rng();
group.bench_function("... | 15 | 110 | 146 |
73c1067737dc9d051b2106c82faa606ae0113c9e | Tony Arcieri | 2025-07-10T22:52:15 | Mention `crypto-primes` in rustdoc (#868)
Helps make it more discoverable.
cc @fjarri | diff --git a/src/lib.rs b/src/lib.rs
index 7d51781..38c8499 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -159,6 +159,12 @@
//! [`Mul`]: core::ops::Mul
//! [`Rem`]: core::ops::Rem
//! [`Sub`]: core::ops::Sub
+//!
+//! ## `crypto-primes` crate
+//!
+//! This crate contains no prime number related functionality (e.g. ra... | 1 | 6 | 0 |
36afc5cc0a9e811e676b5a699601bd3e29a5ed1b | Tony Arcieri | 2025-07-04T16:47:30 | Fix deprecated `impl_modulus!` macro (#866)
Also adds a test it still works. It was broken in #861 (missing colon)
when it was changed to invoke the new `const_monty_params!` macro.
Closes #865 | diff --git a/src/modular/const_monty_form/macros.rs b/src/modular/const_monty_form/macros.rs
index 098d18a..20ab75a 100644
--- a/src/modular/const_monty_form/macros.rs
+++ b/src/modular/const_monty_form/macros.rs
@@ -112,7 +112,7 @@ macro_rules! const_monty_form {
#[macro_export]
macro_rules! impl_modulus {
($na... | 1 | 9 | 1 |
eb358ff097a10b519871d7ba01b6cebcef95fa55 | Tony Arcieri | 2025-07-03T19:51:33 | v0.7.0-pre.6 (#864) | diff --git a/Cargo.lock b/Cargo.lock
index 123d917..6e6bf9d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -224,7 +224,7 @@ checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-pre.5"
+version = "0.7.0-pre.6"
dependencies = [
"bincode",
... | 2 | 2 | 2 |
5ad88d00def486fc91bd8dfb502695ccf20f7adf | Tony Arcieri | 2025-07-03T16:32:54 | Bump `bincode` to v2 (#863) | diff --git a/Cargo.lock b/Cargo.lock
index 96eced1..123d917 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -37,11 +37,22 @@ checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
[[package]]
name = "bincode"
-version = "1.3.3"
+version = "2.0.1"
source = "registry+https://github.com/rust-lang/c... | 9 | 106 | 126 |
7631eed263fa9beb2f528afd19f1e0b819535ab7 | Tony Arcieri | 2025-07-03T15:54:29 | der v0.8.0-rc.6 (#862) | diff --git a/Cargo.lock b/Cargo.lock
index d05d59d..96eced1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -235,9 +235,9 @@ dependencies = [
[[package]]
name = "der"
-version = "0.8.0-rc.5"
+version = "0.8.0-rc.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9843074b9f917c0ae9144eeab6... | 2 | 3 | 3 |
589e915eb70d40ba80978b55506e182570583dee | dishmaker | 2025-07-03T15:22:22 | uint: encoding: der: add `BoxedUint` + optimize `EncodeValue::value_len` (#851) | diff --git a/src/uint/encoding.rs b/src/uint/encoding.rs
index bbc0770..858ce0b 100644
--- a/src/uint/encoding.rs
+++ b/src/uint/encoding.rs
@@ -1040,4 +1040,28 @@ mod tests {
}
}
}
+
+ #[test]
+ #[cfg(target_pointer_width = "32")]
+ fn encode_be_hex() {
+ let n = UintEx::from... | 2 | 185 | 4 |
73111915db06477c08ac0f6c74e8dae3dd3716f1 | Tony Arcieri | 2025-07-03T14:53:06 | Rename `impl_modulus!` => `const_monty_params!` (#861)
The old name is preserved with a deprecation.
The new name matches the `ConstMontyParams` trait name, and also matches
the `const_monty_form!` macro. | diff --git a/benches/const_monty.rs b/benches/const_monty.rs
index b638389..bbe6938 100644
--- a/benches/const_monty.rs
+++ b/benches/const_monty.rs
@@ -1,7 +1,7 @@
use criterion::{
BatchSize, BenchmarkGroup, Criterion, criterion_group, criterion_main, measurement::Measurement,
};
-use crypto_bigint::{Random, Ra... | 12 | 81 | 43 |
17c5083066071fb1a18fa0cc8eacab3b9c8f9f09 | Erik | 2025-07-03T12:02:45 | Fix clippy for Rust v1.88 (#859) | diff --git a/src/int.rs b/src/int.rs
index 9d7d114..6cb876d 100644
--- a/src/int.rs
+++ b/src/int.rs
@@ -347,10 +347,7 @@ mod tests {
fn debug() {
let n = I128::from_be_hex("AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDD");
- assert_eq!(
- format!("{:?}", n),
- "Int(0xAAAAAAAABBBBBBBBCCCC... | 4 | 7 | 14 |
c0689f9bf404c4469306b4603761d2eca48043fc | Erik | 2025-06-24T16:41:44 | `NonZeroInt::new_unwrap` (#857)
plus some minor clean-up | diff --git a/src/const_choice.rs b/src/const_choice.rs
index eb10a6e..eb5b786 100644
--- a/src/const_choice.rs
+++ b/src/const_choice.rs
@@ -1,6 +1,8 @@
use subtle::{Choice, CtOption};
-use crate::{Int, Limb, NonZero, Odd, Uint, WideWord, Word, modular::SafeGcdInverter};
+use crate::{
+ Int, Limb, NonZero, NonZer... | 2 | 52 | 12 |
99c74cb8239a0513af21e8de83a92436662aff5c | Tony Arcieri | 2025-06-19T20:54:22 | Bump `criterion` to v0.6 (#849) | diff --git a/Cargo.lock b/Cargo.lock
index e6c57e2..80437f5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -149,25 +149,22 @@ checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
[[package]]
name = "criterion"
-version = "0.5.1"
+version = "0.6.0"
source = "registry+https://github.com/rust-la... | 9 | 26 | 35 |
71b87a9f03b2cc44508225ca140f57895148642c | Arthur Gautier | 2025-06-19T18:25:11 | implement `PartialOrd<Uint>` for `BoxedUint` (#803) | diff --git a/src/uint/boxed/cmp.rs b/src/uint/boxed/cmp.rs
index 31cad6a..b924b3b 100644
--- a/src/uint/boxed/cmp.rs
+++ b/src/uint/boxed/cmp.rs
@@ -5,7 +5,7 @@
pub(super) use core::cmp::{Ordering, max};
use super::BoxedUint;
-use crate::{ConstChoice, Limb};
+use crate::{ConstChoice, Limb, Uint};
use subtle::{
... | 1 | 13 | 1 |
57652646124b1d51c1a329ea9127d667006dd77e | Erik | 2025-06-19T18:08:30 | `Int`-`Uint` conversion (#837)
This PR introduces `Int::to_uint` and `Uint::to_int`, allowing better
conversion between these types. | diff --git a/src/const_choice.rs b/src/const_choice.rs
index d35d728..eb10a6e 100644
--- a/src/const_choice.rs
+++ b/src/const_choice.rs
@@ -395,7 +395,7 @@ impl<const LIMBS: usize> ConstCtOption<Uint<LIMBS>> {
/// Returns the contained value, interpreting the underlying [`Uint`] value as an [`Int`].
#[inline... | 7 | 64 | 14 |
c1978721bac5ea65ddac85f62980a87526058993 | Erik | 2025-06-18T23:53:50 | Add `NonZeroInt` and `OddInt` type aliases (#845) | diff --git a/src/non_zero.rs b/src/non_zero.rs
index 4b631f9..ab28ad7 100644
--- a/src/non_zero.rs
+++ b/src/non_zero.rs
@@ -26,6 +26,9 @@ use serdect::serde::{
/// Non-zero unsigned integer.
pub type NonZeroUint<const LIMBS: usize> = NonZero<Uint<LIMBS>>;
+/// Non-zero signed integer
+pub type NonZeroInt<const LIM... | 2 | 6 | 0 |
b27f50f14e804d953f4ad829b265c3ad7a5687e7 | Tony Arcieri | 2025-06-16T12:06:40 | Add `NonZero` and `Odd` type aliases (#844)
Adds the following type aliases:
- `NonZeroUint`
- `NonZeroBoxedUint`
- `OddUint`
- `OddBoxedUint`
This avoids consumers of the crate from having to assemble these
themselves. | diff --git a/src/lib.rs b/src/lib.rs
index ae44a16..7d51781 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -187,11 +187,10 @@ pub use crate::{
int::types::*,
int::*,
limb::{Limb, WideWord, Word},
- non_zero::NonZero,
- odd::Odd,
+ non_zero::*,
+ odd::*,
traits::*,
- uint::div_limb::Recip... | 3 | 20 | 4 |
51d376f12df4628e044c0d6be7671d623fd8ad98 | Tony Arcieri | 2025-06-16T00:02:41 | v0.7.0-pre.5 (#843) | diff --git a/Cargo.lock b/Cargo.lock
index fc6f011..e6c57e2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -216,7 +216,7 @@ checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-pre.4"
+version = "0.7.0-pre.5"
dependencies = [
"bincode",
... | 2 | 2 | 2 |
36f8b20bd38850ebd4f822497ceb3ba48e519df4 | Tony Arcieri | 2025-06-15T19:42:53 | Fix deprecations (#842)
These were introduced in #755 which was just merged | diff --git a/Cargo.toml b/Cargo.toml
index 3308280..41efdee 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -80,3 +80,6 @@ harness = false
[[bench]]
name = "int"
harness = false
+
+[profile.dev]
+opt-level = 2
diff --git a/src/uint/bingcd/extension.rs b/src/uint/bingcd/extension.rs
index 4c7b755..d10a1de 100644
--- a/sr... | 2 | 6 | 3 |
0fa3be5eaf5ea1bdce7c19b1650b4d4423516cb1 | Erik | 2025-06-15T17:55:32 | Binary GCD (#755)
This PR introduces an implementation of Optimized Binary GCD. Ref:
[Pornin, Algorithm 2](https://eprint.iacr.org/2020/972.pdf).
### _Upsides to this technique:_
- it is up to 27x faster than the `gcd` algorithm currently implemented
in `crypto_bigint` (see below) (really, it just has a different
com... | diff --git a/benches/int.rs b/benches/int.rs
index e509058..1301a1f 100644
--- a/benches/int.rs
+++ b/benches/int.rs
@@ -1,7 +1,6 @@
use std::ops::Div;
use criterion::{BatchSize, Criterion, black_box, criterion_group, criterion_main};
-use num_traits::WrappingSub;
use rand_chacha::ChaChaRng;
use rand_core::Seedab... | 13 | 869 | 25 |
0416d656df1de1d95fafe0cba825da835474f833 | Erik | 2025-06-15T17:48:53 | Improve `Int::abs` (#840)
Make
- `Odd::<Int>::abs() -> Odd<Uint>`, and
- `NonZero::<Int>::abs() -> NonZero<Uint>`
instead of `-> Uint`. | diff --git a/src/non_zero.rs b/src/non_zero.rs
index 46f54f0..8db9952 100644
--- a/src/non_zero.rs
+++ b/src/non_zero.rs
@@ -171,11 +171,16 @@ impl<const LIMBS: usize> NonZero<Uint<LIMBS>> {
}
impl<const LIMBS: usize> NonZero<Int<LIMBS>> {
- /// Convert a [`NonZero<Int>`] to its sign and [`NonZero<Uint>`] magnit... | 2 | 23 | 4 |
5d38cbd94680254c1d667045a475597db068a00c | Erik | 2025-06-15T17:48:19 | Prep `Int`-`Uint` multiplication operations for 0.7.0 (#838) | diff --git a/src/int/mul_uint.rs b/src/int/mul_uint.rs
index 29e7213..ac106ed 100644
--- a/src/int/mul_uint.rs
+++ b/src/int/mul_uint.rs
@@ -1,8 +1,7 @@
use core::ops::Mul;
-
use subtle::CtOption;
-use crate::{CheckedMul, ConcatMixed, ConstChoice, Int, Uint, Zero};
+use crate::{CheckedMul, ConcatMixed, ConstChoice,... | 3 | 121 | 29 |
b6a5c8c419400d0ebac0a8cb4f0b18b32aca4676 | Tony Arcieri | 2025-06-15T17:08:20 | Bump `proptest` dependency to 1.7 (#841) | diff --git a/Cargo.lock b/Cargo.lock
index f2923f3..fc6f011 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -61,9 +61,9 @@ checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
[[package]]
name = "bitflags"
-version = "2.8.0"
+version = "2.9.1"
source = "registry+https://github.com/rust-lang/cr... | 3 | 20 | 57 |
a94c575c9110c66c52f4b8187c9a37e41777fa3d | wawwior | 2025-06-14T18:54:28 | Implement serde for BoxedUint (#789)
Adapted from #587 | diff --git a/Cargo.lock b/Cargo.lock
index 143f56a..f2923f3 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -714,9 +714,9 @@ dependencies = [
[[package]]
name = "serde_json"
-version = "1.0.138"
+version = "1.0.140"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d434192e7da787e94a6ea7e96... | 4 | 76 | 3 |
28ee1f5a06b55bd45ff3fd253c9aa2f3bc9c3e61 | Erik | 2025-06-03T12:33:50 | `div` with differently sized denominators (#799)
With this PR in place, denominators are no longer required to be a
`Uint`/`Int` of the same number of limbs as the numerator, enabling more
efficient division. | diff --git a/benches/uint.rs b/benches/uint.rs
index d6af21a..6445132 100644
--- a/benches/uint.rs
+++ b/benches/uint.rs
@@ -219,7 +219,15 @@ fn bench_division(c: &mut Criterion) {
let mut rng = make_rng();
let mut group = c.benchmark_group("wrapping ops");
- group.bench_function("div/rem, U256/U128, ful... | 5 | 350 | 199 |
c451e15c3c8878f8dbf4b1ac0c173fb94dc85935 | Tony Arcieri | 2025-06-02T20:06:45 | Add `BoxedUint::{from_be_slice_vartime, from_le_slice_vartime}` (#833)
Adds methods for decoding `BoxedUint` which infer the precision from the
input size.
This is useful for decoding public parameters, especially when the size
of other parameters is inferred from some public parameter that needs to
be decoded first,... | diff --git a/src/uint/boxed/encoding.rs b/src/uint/boxed/encoding.rs
index 0d7255a..546f586 100644
--- a/src/uint/boxed/encoding.rs
+++ b/src/uint/boxed/encoding.rs
@@ -39,6 +39,20 @@ impl BoxedUint {
Ok(ret)
}
+ /// Create a new [`BoxedUint`] from the provided big endian bytes, automatically selecti... | 2 | 60 | 2 |
9ea4fb5f6cf7bb25ebe385d03f2c28f727036937 | Tony Arcieri | 2025-05-30T21:23:32 | v0.7.0-pre.4 (#831)
Release that includes the trimmed serialization API for the `rsa` crate | diff --git a/Cargo.lock b/Cargo.lock
index f5f41cf..9fc68d8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -216,7 +216,7 @@ checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
[[package]]
name = "crypto-bigint"
-version = "0.7.0-pre.3"
+version = "0.7.0-pre.4"
dependencies = [
"bincode",
... | 2 | 2 | 2 |
0ae192833c0add56070df49c0d963f7fb1fe659d | Arthur Gautier | 2025-05-29T21:02:06 | adjust deprecation notice on mac (#820)
This adjust the deprecation notice on `Limb::mac` to avoid confusion
when upgrading crypto-bigint dependency. | diff --git a/src/limb/mul.rs b/src/limb/mul.rs
index 92c29a0..88d2f07 100644
--- a/src/limb/mul.rs
+++ b/src/limb/mul.rs
@@ -10,7 +10,10 @@ use subtle::CtOption;
impl Limb {
/// Computes `self + (b * c) + carry`, returning the result along with the new carry.
- #[deprecated(since = "0.7.0", note = "please us... | 1 | 4 | 1 |
e08a2d04081bb0ba6f3b72ef45f0c7f619a5a826 | Tony Arcieri | 2025-05-25T19:40:08 | Fix spelling: `almost_montgomery_mul` | diff --git a/src/modular/boxed_monty_form/pow.rs b/src/modular/boxed_monty_form/pow.rs
index 6014329..59c5c12 100644
--- a/src/modular/boxed_monty_form/pow.rs
+++ b/src/modular/boxed_monty_form/pow.rs
@@ -113,7 +113,7 @@ fn pow_montgomery_form(
// Ensure the output is properly reduced.
//
- // Using the ... | 1 | 1 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.