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
32a578fa508df56aa379ac6488a7629528504867
Tony Arcieri
2023-11-30T01:42:53
BoxedUint: add `map_limbs`; rename `fold_limbs` (#357) Splits apart the internal functions for iterating over limbs and handling widening, and applying a given function to the inputs. `BoxedUint::map_limbs` is useful when there is no carry. The somewhat ambiguously named `BoxedUint::chain` has also been renamed...
diff --git a/src/uint/boxed.rs b/src/uint/boxed.rs index 4b73779..47d8ffc 100644 --- a/src/uint/boxed.rs +++ b/src/uint/boxed.rs @@ -262,7 +262,7 @@ impl BoxedUint { /// /// If one of the two values has fewer limbs than the other, pads with /// [`Limb::ZERO`] as the value for that limb. - fn chain<F>(...
5
24
6
9752d1b52bb40daba7458dd9f8c4e290525b17b3
Tony Arcieri
2023-11-30T01:27:11
Impl `Rem` for `BoxedUint` (#356)
diff --git a/src/uint/boxed/div.rs b/src/uint/boxed/div.rs index f3275fd..76bfe7b 100644 --- a/src/uint/boxed/div.rs +++ b/src/uint/boxed/div.rs @@ -1,6 +1,7 @@ //! [`BoxedUint`] division operations. use crate::{BoxedUint, Limb, NonZero}; +use core::ops::{Rem, RemAssign}; use subtle::ConstantTimeEq; impl BoxedU...
1
49
0
c79ea4f8b3b4f356f3e24ad9eec9809eab3d290c
Tony Arcieri
2023-11-30T01:09:11
Refactor `Integer` trait; add `Constants`/`LimbsConstant` (#355) This commit factors all of the associated constants off of the `Integer` trait into separate traits: - The existing `Bounded` trait subsumes `BITS`/`BYTES` - `Constants` provides `ONE` and `MAX` - `LimbsConstant` provides `LIMBS` Methods have be...
diff --git a/src/limb.rs b/src/limb.rs index 6d06890..3d7f603 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -19,7 +19,7 @@ mod sub; #[cfg(feature = "rand_core")] mod rand; -use crate::{Bounded, ZeroConstant}; +use crate::{Bounded, Constants, ZeroConstant}; use core::fmt; use subtle::{Choice, ConditionallySelectab...
5
84
38
24929591ecd98115224d5686629b5d54f494b929
Tony Arcieri
2023-11-29T21:02:05
BoxedUint: tweaks to `BoxedUint::{cond_map, cond_and_then}` (#354)
diff --git a/src/uint/boxed/ct.rs b/src/uint/boxed/ct.rs index 7e2baea..4bf0e73 100644 --- a/src/uint/boxed/ct.rs +++ b/src/uint/boxed/ct.rs @@ -9,7 +9,9 @@ impl BoxedUint { /// Conditional `map`: workaround which provides a [`CtOption::map`]-like API. /// /// Ensures both functions are called regardless...
1
10
4
7b0253a719ce14b0d3f6590cabb8105035efc1e0
Tony Arcieri
2023-11-29T20:37:53
NonZero: derive `Hash` (#353)
diff --git a/src/non_zero.rs b/src/non_zero.rs index 4a952c7..0dcc1d3 100644 --- a/src/non_zero.rs +++ b/src/non_zero.rs @@ -21,7 +21,7 @@ use serdect::serde::{ }; /// Wrapper type for non-zero integers. -#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, Default, E...
1
1
1
4e061ef7c6850831b3a100cba6590e2730db6c1e
Tony Arcieri
2023-11-29T20:36:10
BoxedUint: add `cond_map` and `cond_and_then` (#352) Unfortunately `BoxedUint` can't impl `subtle::ConditionallySelectable` due to a supertrait bound on `Copy`. See dalek-cryptography/subtle#94 This bound is required by `CtOption::map` and `CtOption::and_then` which are important for writing constant-time code. ...
diff --git a/src/uint/boxed.rs b/src/uint/boxed.rs index 23b268b..4b73779 100644 --- a/src/uint/boxed.rs +++ b/src/uint/boxed.rs @@ -6,6 +6,7 @@ mod bit_and; mod bit_or; mod bits; mod cmp; +mod ct; mod div; pub(crate) mod encoding; mod inv_mod; diff --git a/src/uint/boxed/ct.rs b/src/uint/boxed/ct.rs new file mod...
2
121
0
68777f5a4d062b5bb8070a0ad684303b27f30d39
Tony Arcieri
2023-11-29T17:03:22
Impl `Hash` for `BoxedUint` (#350) Uses a derived impl. Ideally this wouldn't be used with secret values, or at least hopefully with a good hashing algorithm (like the default SipHasher, which is a secure PRF)
diff --git a/src/uint/boxed.rs b/src/uint/boxed.rs index fe779c4..23b268b 100644 --- a/src/uint/boxed.rs +++ b/src/uint/boxed.rs @@ -36,7 +36,8 @@ use zeroize::Zeroize; /// Unlike many other heap-allocated big integer libraries, this type is not /// arbitrary precision and will wrap at its fixed-precision rather than...
1
2
1
f09c9ab948a695f2053370b4adccc3cbe65ae976
Tony Arcieri
2023-11-29T16:07:03
`BoxedUint` random number generation (#349) Impls the `RandomMod` trait for `BoxedUint`, sharing an implementation with `Uint`. The `Random` trait can't be impl'd since we need to specify a precision as an argument. Perhaps we need a trait like `RandomWithPrecision`.
diff --git a/src/uint/boxed.rs b/src/uint/boxed.rs index 1768b48..fe779c4 100644 --- a/src/uint/boxed.rs +++ b/src/uint/boxed.rs @@ -17,6 +17,9 @@ mod shr; mod sub; mod sub_mod; +#[cfg(feature = "rand_core")] +mod rand; + use crate::{Limb, NonZero, Uint, Word, Zero, U128, U64}; use alloc::{boxed::Box, vec, vec::V...
3
103
25
ee468e3a3689e3c2e7dc21879ec481e2d6ec6e59
Tony Arcieri
2023-11-28T18:28:40
v0.6.0-pre.0 (#347)
diff --git a/Cargo.lock b/Cargo.lock index aecf9c3..dfe1e7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,7 +224,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.6.0-pre" +version = "0.6.0-pre.0" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index 378f7a...
2
2
2
4c09b811fafea006ff9f064ad393321041de45ed
Tony Arcieri
2023-11-28T16:58:43
Assert `Boxed*` size equivalance using `bits_precision` (#344) Several functions on the `Boxed*` types don't yet support implicit widening (#312) and will panic if two or more operands are not the same size (NOTE: we should eventually fix this) Some of these functions previously had debug asserts that the number ...
diff --git a/src/modular/boxed_residue/mul.rs b/src/modular/boxed_residue/mul.rs index 7636e10..0b5e1c0 100644 --- a/src/modular/boxed_residue/mul.rs +++ b/src/modular/boxed_residue/mul.rs @@ -95,8 +95,8 @@ pub(super) fn mul_montgomery_form( modulus: &BoxedUint, mod_neg_inv: Limb, ) -> BoxedUint { - debug...
5
10
10
2038768f06d2b2005dd81e1a03b2cc1833390cfa
Tony Arcieri
2023-11-28T16:32:01
Impl `MulMod` for `BoxedUint` (#343) Like the `MulMod` impl on `Uint`, a more efficient implementation is possible (as noted in the comments), but for now this gets the job done.
diff --git a/src/modular/boxed_residue.rs b/src/modular/boxed_residue.rs index 9073dab..b3f8d67 100644 --- a/src/modular/boxed_residue.rs +++ b/src/modular/boxed_residue.rs @@ -8,7 +8,7 @@ mod neg; mod pow; mod sub; -use super::reduction::montgomery_reduction_boxed; +use super::{reduction::montgomery_reduction_boxe...
6
216
2
c1ca43a44dd0a2a6ea320e012c2f6678a2fc1d35
Tony Arcieri
2023-11-28T04:56:16
Impl `Invert` for `BoxedResidue` (#342)
diff --git a/src/modular/boxed_residue.rs b/src/modular/boxed_residue.rs index 254ef50..9073dab 100644 --- a/src/modular/boxed_residue.rs +++ b/src/modular/boxed_residue.rs @@ -2,6 +2,7 @@ //! is chosen at runtime. mod add; +mod inv; mod mul; mod neg; mod pow; diff --git a/src/modular/boxed_residue/inv.rs b/src/...
4
54
2
266f62eb8ddd29960109699a8ab9ada1a7fef30a
Tony Arcieri
2023-11-28T04:26:12
Add `BoxedUint::inv_mod` (#341) Support for computing modular inverses, proptested against the implementation in `num-bigint-dig`, which this commit also switches to (`num-bigint` doesn't provide an implementation we can test against). Uses the same method as `Uint::inv_mod`, namely an algorithm equivalent to GM...
diff --git a/Cargo.lock b/Cargo.lock index e39846f..aecf9c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -77,6 +77,12 @@ version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +[[package]] +name = "byteorder" +...
14
450
14
453533622ab075781bad18d50e9c913d11110e47
Tony Arcieri
2023-11-28T02:18:04
Impl `Sub` for `BoxedResidue` (#340)
diff --git a/src/modular/boxed_residue.rs b/src/modular/boxed_residue.rs index 716f8ec..254ef50 100644 --- a/src/modular/boxed_residue.rs +++ b/src/modular/boxed_residue.rs @@ -3,6 +3,7 @@ mod add; mod mul; +mod neg; mod pow; mod sub; diff --git a/src/modular/boxed_residue/neg.rs b/src/modular/boxed_residue/neg...
2
26
0
6005886fd9cff4d3fca1c5f344b9933ab7a04a0e
Tony Arcieri
2023-11-28T01:55:56
Impl `Sub` for `BoxedResidue` (#339)
diff --git a/src/modular/boxed_residue.rs b/src/modular/boxed_residue.rs index 7d80866..716f8ec 100644 --- a/src/modular/boxed_residue.rs +++ b/src/modular/boxed_residue.rs @@ -4,6 +4,7 @@ mod add; mod mul; mod pow; +mod sub; use super::reduction::montgomery_reduction_boxed; use crate::{BoxedUint, Limb, NonZero,...
2
110
0
79991e81bf890701b5d25f28c66ea9bd754e2a33
Tony Arcieri
2023-11-28T01:40:16
Impl `Add` for `BoxedResidue` (#338)
diff --git a/src/modular/boxed_residue.rs b/src/modular/boxed_residue.rs index c8a8d67..7d80866 100644 --- a/src/modular/boxed_residue.rs +++ b/src/modular/boxed_residue.rs @@ -1,6 +1,7 @@ //! Implements `BoxedResidue`s, supporting modular arithmetic with a modulus whose size and value //! is chosen at runtime. +mo...
4
111
2
cb53a4fa185746482429cad299ab148a6c20b060
Tony Arcieri
2023-11-28T00:05:04
Add `BoxedUint::pow` (#337) Initial support for modular exponentiation, adapted from the original implementation of `pow_montgomery_form` this crate used prior to #248: https://github.com/RustCrypto/crypto-bigint/blob/4838fd96e1bde8b0c5e0ce691c366c7ec930e466/src/uint/modular/pow.rs Proptested against `num_bigin...
diff --git a/src/modular/boxed_residue.rs b/src/modular/boxed_residue.rs index f306d4f..c8a8d67 100644 --- a/src/modular/boxed_residue.rs +++ b/src/modular/boxed_residue.rs @@ -2,6 +2,7 @@ //! is chosen at runtime. mod mul; +mod pow; use super::reduction::montgomery_reduction_boxed; use crate::{BoxedUint, Limb,...
4
171
27
c966aead39f3f31481fd557752d05d20f7307e8f
Tony Arcieri
2023-11-27T23:19:00
Make `BoxedUint::rem_vartime` infallible using `NonZero` (#336) Now that #335 has been merged allowing `NonZero<BoxedUint>` to be expressed, we can use it as the operand for remainder, eliminating the need to handle division by zero at the type system level. This dramatically simplifies the implementation of `Bo...
diff --git a/src/boxed.rs b/src/boxed.rs deleted file mode 100644 index 4bcb860..0000000 --- a/src/boxed.rs +++ /dev/null @@ -1,3 +0,0 @@ -//! Heap-allocated "boxed" types. - -pub(crate) mod uint; diff --git a/src/modular/boxed_residue.rs b/src/modular/boxed_residue.rs index a71c379..f306d4f 100644 --- a/src/modular/bo...
11
92
152
baaba0c3d14b470edfd816e9ea2e24270f55eaee
Tony Arcieri
2023-11-27T22:39:04
Split `Zero` trait into `Zero`+`ZeroConstant` (#335) The `BoxedUint` type couldn't impl the old `Zero` trait because it requires the value be bound to a constant instead of computed at runtime. This commit splits the original trait into two traits, adding a `fn zero()` to `Zero` which can be used for `BoxedUint`...
diff --git a/src/limb.rs b/src/limb.rs index a5ca957..6d06890 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -19,7 +19,7 @@ mod sub; #[cfg(feature = "rand_core")] mod rand; -use crate::{Bounded, Zero}; +use crate::{Bounded, ZeroConstant}; use core::fmt; use subtle::{Choice, ConditionallySelectable}; @@ -105,7 +1...
6
35
10
5ac0272ae916ee8691b2fbaaa98e25fa19692db5
Tony Arcieri
2023-11-27T22:16:07
BoxedResidue: initial impl w\ `mul` (#333) Adds a heap-allocated analogue of `Residue`/`DynResidue` providing a representation of a modular value in Montgomery form. This initial commit includes support for Montgomery multiplication.
diff --git a/src/modular.rs b/src/modular.rs index f69079d..add5bb8 100644 --- a/src/modular.rs +++ b/src/modular.rs @@ -17,7 +17,7 @@ //! the modulus can vary at runtime. mod dyn_residue; -pub(crate) mod reduction; +mod reduction; mod residue; mod add; @@ -27,12 +27,18 @@ mod mul; mod pow; mod sub; +#[cfg(...
11
540
51
4aee8ce1e185f9c1156a162ecce6164bf80ab915
Tony Arcieri
2023-11-27T18:19:05
Add `BoxedUint::{inv_mod2k, bitor}` (#334) Support for computing inverses modulo powers of 2. The `bitor` impl was needed to test `inv_mod2k`, which internally uses a `set_bit` function that needed tested.
diff --git a/src/limb/bit_or.rs b/src/limb/bit_or.rs index cafac18..f863ac0 100644 --- a/src/limb/bit_or.rs +++ b/src/limb/bit_or.rs @@ -1,7 +1,7 @@ //! Limb bit or operations. use super::Limb; -use core::ops::BitOr; +use core::ops::{BitOr, BitOrAssign}; impl Limb { /// Calculates `a | b`. @@ -17,3 +17,15 @...
5
253
3
2b4f5e3b5c99030345e03d0c344ab054c55a8c4d
Tony Arcieri
2023-11-27T04:10:26
Add `BoxedUint::rem_vartime` (#332)
diff --git a/src/uint/boxed.rs b/src/uint/boxed.rs index 0587674..1ae76d7 100644 --- a/src/uint/boxed.rs +++ b/src/uint/boxed.rs @@ -5,6 +5,7 @@ mod add_mod; mod bit_and; mod bits; mod cmp; +mod div; pub(crate) mod encoding; mod modular; mod mul; @@ -170,6 +171,19 @@ impl BoxedUint { Self { limbs } ...
3
84
0
5098094a51e57842388b540d7774118eb60f3a06
Tony Arcieri
2023-11-27T03:45:33
Add `BoxedUint::shr_vartime` (#331)
diff --git a/src/uint/boxed.rs b/src/uint/boxed.rs index c9dcd6a..0587674 100644 --- a/src/uint/boxed.rs +++ b/src/uint/boxed.rs @@ -9,6 +9,7 @@ pub(crate) mod encoding; mod modular; mod mul; mod shl; +mod shr; mod sub; mod sub_mod; diff --git a/src/uint/boxed/shl.rs b/src/uint/boxed/shl.rs index 430dd6a..17da1a...
3
66
7
aed4b3604b9a06afb9e0b4c2aed0d94a3569f7c3
Tony Arcieri
2023-11-27T03:32:24
Add `BoxedUint::shl_vartime` (#330)
diff --git a/src/uint/boxed.rs b/src/uint/boxed.rs index 1081119..c9dcd6a 100644 --- a/src/uint/boxed.rs +++ b/src/uint/boxed.rs @@ -8,6 +8,7 @@ mod cmp; pub(crate) mod encoding; mod modular; mod mul; +mod shl; mod sub; mod sub_mod; diff --git a/src/uint/boxed/shl.rs b/src/uint/boxed/shl.rs new file mode 100644 ...
2
80
0
071bb8598a572785638e99656db39205ff3088ab
Tony Arcieri
2023-11-27T03:32:13
Add `BoxedUint::conditional_select` (#329) This is an inherent function with the same type signature as `subtle::ConditionallySelectable::conditional_select`, however we can't impl the upstream trait because it has a `Copy` bound. See dalek-cryptography/subtle#94.
diff --git a/src/uint/boxed.rs b/src/uint/boxed.rs index 2f1bf6b..1081119 100644 --- a/src/uint/boxed.rs +++ b/src/uint/boxed.rs @@ -14,7 +14,7 @@ mod sub_mod; use crate::{Limb, Uint, Word, Zero, U128, U64}; use alloc::{boxed::Box, vec, vec::Vec}; use core::fmt; -use subtle::Choice; +use subtle::{Choice, Conditional...
1
33
1
f07de9194d364f072d8b91b60b536eab194c713f
Tony Arcieri
2023-11-27T02:38:08
Add `BoxedUint::bits` (#328) Adds a function for counting the number of bits in a value, i.e. the index of the highest set bit. Since `BoxedUint` isn't `const fn`, this can be implemented in constant-time using `subtle`.
diff --git a/src/uint/boxed.rs b/src/uint/boxed.rs index cfc8514..2f1bf6b 100644 --- a/src/uint/boxed.rs +++ b/src/uint/boxed.rs @@ -3,6 +3,7 @@ mod add; mod add_mod; mod bit_and; +mod bits; mod cmp; pub(crate) mod encoding; mod modular; @@ -150,11 +151,6 @@ impl BoxedUint { self.limbs.len() } - ...
3
51
6
e3340640a8cea5900dbf54d5ea9b3e589ed4097c
Tony Arcieri
2023-11-27T01:14:59
Replace `BoxedUint::new` with `::zero_with_precision` (#327) The two APIs are nearly identical. The only difference is the latter is infallible and panics if an invalid precision is given. This also changes `BoxedUint::max` to have the same behavior. Whether they should panic is a debatable point. Indeed having...
diff --git a/src/uint/boxed.rs b/src/uint/boxed.rs index 767289e..cfc8514 100644 --- a/src/uint/boxed.rs +++ b/src/uint/boxed.rs @@ -78,34 +78,17 @@ impl BoxedUint { .fold(Choice::from(1), |acc, limb| acc & limb.is_zero()) } - /// Create a new [`BoxedUint`] with the given number of bits of precis...
6
16
37
464673bf575f793d2064a7e84f7e4ec97e42ccbb
Tony Arcieri
2023-11-26T23:33:12
Rename `constant_mod`/`runtime_mod` to `*residue` (#326) Renames the following: - `modular::constant_mod` => `modular::residue` - `modular::runtime_mod` => `modular::dyn_residue` Notably these names map to the types they contain, which should make it a bit more intuitively obvious what's inside of them. It wa...
diff --git a/src/modular.rs b/src/modular.rs index cb460ab..f69079d 100644 --- a/src/modular.rs +++ b/src/modular.rs @@ -16,9 +16,9 @@ //! The [`DynResidue`] and [`DynResidueParams`] types implement support for modular arithmetic where //! the modulus can vary at runtime. -mod constant_mod; +mod dyn_residue; pub(c...
16
26
29
3206b24a86c5e9820059fbb792b3c96167584d70
Tony Arcieri
2023-11-26T23:09:53
Move `BoxedUint` under `uint::boxed` (#325) This layout maps better to adding `boxed` support to other submodules, like `modular::boxed` (which could contain a `BoxedResidue`)
diff --git a/src/lib.rs b/src/lib.rs index db12049..e9dc3c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -163,8 +163,6 @@ pub mod modular; #[cfg(feature = "generic-array")] mod array; -#[cfg(feature = "alloc")] -mod boxed; mod checked; mod ct_choice; mod limb; @@ -186,7 +184,7 @@ pub use crate::{ pub use subtle;...
12
3
4
f7d44bcd965c0620cd1f8b2ad17688a49832ae93
Tony Arcieri
2023-11-26T22:59:21
Move `modular` module to toplevel (#324) It was previously located under `uint`. Now that we've begun work to share the implementation between `Uint` and `BoxedUint`, moving this module to the toplevel makes sense. It also better maps to the public API, where it's re-exported from the toplevel, i.e. this is no...
diff --git a/src/boxed/uint/modular.rs b/src/boxed/uint/modular.rs index 8b7d8cb..ca1cf30 100644 --- a/src/boxed/uint/modular.rs +++ b/src/boxed/uint/modular.rs @@ -1,7 +1,7 @@ //! Modular arithmetic support for [`BoxedUint`]. use super::BoxedUint; -use crate::{uint::modular::reduction::montgomery_reduction_core, L...
27
8
6
d6c01b74b128af74ebb1b85732e63f4ae9768a90
Tony Arcieri
2023-11-26T22:49:53
Montgomery multiplication support for `BoxedUint` (#323) Adds an internal `impl_montgomery_reduction!` macro which can be used to abstract over `const fn` use cases as well as `BoxedUint` use cases which would require `const_mut_refs` to be usable from a `const fn`. This is used to define an inner `mul_montgomery...
diff --git a/src/boxed/uint.rs b/src/boxed/uint.rs index 7d5c943..767289e 100644 --- a/src/boxed/uint.rs +++ b/src/boxed/uint.rs @@ -5,6 +5,7 @@ mod add_mod; mod bit_and; mod cmp; pub(crate) mod encoding; +mod modular; mod mul; mod sub; mod sub_mod; @@ -262,6 +263,14 @@ impl From<u128> for BoxedUint { } } ...
5
109
31
3bf706638465fd9c81450dbd816bd88aa11d6958
Tony Arcieri
2023-11-26T21:14:27
Add `Uint::bitand_limb` (#322) Similar to #321, this adds a function which applies a bitwise AND of the given limb to every limb in a `Uint`. This can be used to replace intermediate array allocations and reduce stack size inside of `Uint::{add_mod, sub_mod}`.
diff --git a/src/boxed/uint/bit_and.rs b/src/boxed/uint/bit_and.rs index 101fe15..fb8b955 100644 --- a/src/boxed/uint/bit_and.rs +++ b/src/boxed/uint/bit_and.rs @@ -12,7 +12,8 @@ impl BoxedUint { Self::chain(self, rhs, Limb::ZERO, |a, b, z| (a.bitand(b), z)).0 } - /// Bitwise `AND` against the given ...
4
22
13
7b437b924573147fd0360e1e8428e29fb71eb567
Tony Arcieri
2023-11-26T21:03:04
Avoid allocations in `BoxedUint::{add_mod, sub_mod}` (#321)
diff --git a/src/boxed/uint/add_mod.rs b/src/boxed/uint/add_mod.rs index 4a76a96..953d992 100644 --- a/src/boxed/uint/add_mod.rs +++ b/src/boxed/uint/add_mod.rs @@ -16,14 +16,12 @@ impl BoxedUint { // Attempt to subtract the modulus, to ensure the result is in the field. let (w, borrow) = w.sbb(p, L...
3
11
8
7e9ea3039bea8b28e98af02b9940fdb33b208c9f
Tony Arcieri
2023-11-26T20:44:22
BoxedUint: impl `SubMod` (#320)
diff --git a/src/boxed/uint.rs b/src/boxed/uint.rs index bec672d..7d5c943 100644 --- a/src/boxed/uint.rs +++ b/src/boxed/uint.rs @@ -7,6 +7,7 @@ mod cmp; pub(crate) mod encoding; mod mul; mod sub; +mod sub_mod; use crate::{Limb, Uint, Word, Zero, U128, U64}; use alloc::{boxed::Box, vec, vec::Vec}; diff --git a/s...
5
94
12
887ffc73da60ef48497247c88468309c5c07ac1e
Tony Arcieri
2023-11-26T20:28:12
Simplify implementation of `BoxedUint::chain` (#319)
diff --git a/src/boxed/uint.rs b/src/boxed/uint.rs index d978f6a..bec672d 100644 --- a/src/boxed/uint.rs +++ b/src/boxed/uint.rs @@ -170,47 +170,28 @@ impl BoxedUint { self.limbs.len() * Limb::BITS } - /// Sort two [`BoxedUint`]s by precision, returning a tuple of the shorter - /// followed by the...
2
15
33
46238eebfa1a8ba781d37328c8555c5c455a3cbd
Tony Arcieri
2023-11-26T20:24:52
Integer: add `*Mod` ops to bounds (#318) Bounds `Integer` types on: - `AddMod` - `SubMod` - `NegMod` - `MulMod`
diff --git a/src/traits.rs b/src/traits.rs index 3a9cf36..7f04013 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -14,6 +14,7 @@ use rand_core::CryptoRngCore; /// Integer type. pub trait Integer: 'static + + AddMod + AsRef<[Limb]> + BitAnd<Output = Self> + BitOr<Output = Self> @@ -31,6 +32,8 ...
1
4
0
f077b6c9d9431f18aeea0031625295c995ab33e6
Tony Arcieri
2023-11-26T20:17:29
BoxedUint: impl `AddMod` (#317)
diff --git a/src/boxed/uint.rs b/src/boxed/uint.rs index 1ae097d..d978f6a 100644 --- a/src/boxed/uint.rs +++ b/src/boxed/uint.rs @@ -1,6 +1,7 @@ //! Heap-allocated big unsigned integers. mod add; +mod add_mod; mod bit_and; mod cmp; pub(crate) mod encoding; diff --git a/src/boxed/uint/add_mod.rs b/src/boxed/uint/...
3
73
2
ec311d6afc9d3d3ac51b19341674de9a5ebdb964
Tony Arcieri
2023-11-26T20:07:28
BoxedUint: impl `ConstantTimeGreater/Less` and `PartialOrd/Ord` (#316)
diff --git a/src/boxed/uint/cmp.rs b/src/boxed/uint/cmp.rs index 1a32052..9a7a212 100644 --- a/src/boxed/uint/cmp.rs +++ b/src/boxed/uint/cmp.rs @@ -3,9 +3,11 @@ //! By default these are all constant-time and use the `subtle` crate. use super::BoxedUint; -use crate::Limb; -use core::cmp; -use subtle::{Choice, Const...
1
101
4
3f6422e386371d91b74a6802824190179a7858c3
Tony Arcieri
2023-11-26T19:49:46
BoxedUint: fix argument ordering to `::chain` (#315) Previously it swapped the arguments if one was shorter. This needs to be reflected in the argument ordering to the callback. Unfortunately the existing tests didn't catch this, so they've been updated with a case that does.
diff --git a/src/boxed/uint.rs b/src/boxed/uint.rs index 0eb88a1..1ae097d 100644 --- a/src/boxed/uint.rs +++ b/src/boxed/uint.rs @@ -172,11 +172,11 @@ impl BoxedUint { /// Sort two [`BoxedUint`]s by precision, returning a tuple of the shorter /// followed by the longer, or the original order if their precisio...
3
21
12
f7589bfe2aed250bbda4830bf681b0f7447b6dd7
Tony Arcieri
2023-11-26T19:00:24
BoxedUint: impl `BitAnd*` (#314)
diff --git a/src/boxed/uint.rs b/src/boxed/uint.rs index 65990a3..0eb88a1 100644 --- a/src/boxed/uint.rs +++ b/src/boxed/uint.rs @@ -1,6 +1,7 @@ //! Heap-allocated big unsigned integers. mod add; +mod bit_and; mod cmp; pub(crate) mod encoding; mod mul; diff --git a/src/boxed/uint/bit_and.rs b/src/boxed/uint/bit_...
6
143
4
2fda5f0c15cd8c87a722cda23ddf52b4db5178bb
Tony Arcieri
2023-11-26T18:06:32
Impl `MulMod` for `Uint` (#313) Uses Montgomery multiplication although it may not be the most efficient approach (e.g. a Barrett reduction might be faster). This also changes the `MulMod` trait to remove the Montgomery-specific implementation details, allowing a simple `mul_mod(self, rhs, p)`. Optimized Montgom...
diff --git a/src/traits.rs b/src/traits.rs index 55d0689..3a9cf36 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -145,16 +145,12 @@ pub trait NegMod { } /// Compute `self * rhs mod p`. -/// -/// Requires `p_inv = -(p^{-1} mod 2^{BITS}) mod 2^{BITS}` to be provided for efficiency. pub trait MulMod<Rhs = Self> { ...
3
52
7
48bd4ac4be736db14d1136fa6ed98086bac9c841
Tony Arcieri
2023-11-25T23:56:43
Add proptests for `BoxedUint::mul_wide` (#311)
diff --git a/src/boxed/uint/mul.rs b/src/boxed/uint/mul.rs index 3ae4d87..307192e 100644 --- a/src/boxed/uint/mul.rs +++ b/src/boxed/uint/mul.rs @@ -4,7 +4,7 @@ use crate::{BoxedUint, Limb}; impl BoxedUint { /// Multiply `self` by `rhs`. - pub fn mul(&self, rhs: &Self) -> Self { + pub fn mul_wide(&self, r...
2
20
7
1399b18f9dea3c550063c69cf621ded26d7156b0
Tony Arcieri
2023-11-25T23:36:49
Add proptests for `BoxedUint::checked_add` (#310)
diff --git a/tests/boxed_uint_proptests.rs b/tests/boxed_uint_proptests.rs index 30d9d16..11cec21 100644 --- a/tests/boxed_uint_proptests.rs +++ b/tests/boxed_uint_proptests.rs @@ -2,7 +2,7 @@ #![cfg(feature = "alloc")] -use crypto_bigint::{BoxedUint, Limb}; +use crypto_bigint::{BoxedUint, CheckedAdd, Limb}; use ...
1
18
2
c898a04f2da9a635abdf4f4c5c4de831a2e6edbe
Tony Arcieri
2023-11-25T23:17:21
Initial proptests for `BoxedUint` (#309)
diff --git a/tests/boxed_uint_proptests.rs b/tests/boxed_uint_proptests.rs new file mode 100644 index 0000000..30d9d16 --- /dev/null +++ b/tests/boxed_uint_proptests.rs @@ -0,0 +1,35 @@ +//! Equivalence tests between `crypto_bigint::BoxedUint` and `num_bigint::BigUint`. + +#![cfg(feature = "alloc")] + +use crypto_bigin...
2
36
1
73f2440d8d80501033a2878a8796cf8201d6893a
Tony Arcieri
2023-11-25T22:58:37
Add `BoxedUint::{to_be_bytes, to_le_bytes}` (#308) These functions allocate and return a boxed slice containing bytes serialized with the chosen endianness.
diff --git a/src/boxed/uint/encoding.rs b/src/boxed/uint/encoding.rs index f3c2c32..a2c7e86 100644 --- a/src/boxed/uint/encoding.rs +++ b/src/boxed/uint/encoding.rs @@ -2,6 +2,7 @@ use super::BoxedUint; use crate::Limb; +use alloc::boxed::Box; /// Decoding errors for [`BoxedUint`]. #[derive(Clone, Copy, Debug, ...
1
50
0
65f45a4852eea6643e8dfea30b7e9279d874eda8
Tony Arcieri
2023-11-25T20:31:54
Add `BoxedUint::{from_be_slice, from_le_slice}` (#307) Initial support for decoding `BoxedUint` from a byte slice. Decoding is fallible and paramaterized around an expected precision. Requiring a known precision at decode time allows the caller to ensure that all values are the same dynamically-determined size so...
diff --git a/Cargo.toml b/Cargo.toml index 307ed93..3b7ec79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,9 +41,9 @@ rand_chacha = "0.3" [features] default = ["rand"] alloc = ["serdect?/alloc"] +extra-sizes = [] rand = ["rand_core/std"] serde = ["dep:serdect"] -extra-sizes = [] [package.metadata.docs.rs] all...
6
270
12
8350d22e2e0302e6fc323904da65eb843383ed9f
Tony Arcieri
2023-11-23T19:35:48
Add `BoxedUint::mul` (#306) Implements basic multiplication support for `BoxedUint`.
diff --git a/src/boxed/uint.rs b/src/boxed/uint.rs index 34aac40..85dabae 100644 --- a/src/boxed/uint.rs +++ b/src/boxed/uint.rs @@ -2,11 +2,13 @@ mod add; mod cmp; +mod mul; mod sub; -use crate::{Limb, Word}; +use crate::{Limb, Uint, Word, Zero, U128, U64}; use alloc::{boxed::Box, vec, vec::Vec}; use core::fm...
3
125
2
647dec53453b100d3e6ef44c22c127efe5541d85
Tony Arcieri
2023-11-23T18:58:12
BoxedUint: change internal representation to `Box<[Limb]>` (#305) It was previously a `Vec<Limb>`, however this encourages changing the precision of an existing `BoxedUint` when they're supposed to be fixed-precision. Using `Box<[Limb]>` decreases the on-stack size by eliminating the capacity and discourages cha...
diff --git a/src/boxed/uint.rs b/src/boxed/uint.rs index a561b66..34aac40 100644 --- a/src/boxed/uint.rs +++ b/src/boxed/uint.rs @@ -5,7 +5,7 @@ mod cmp; mod sub; use crate::{Limb, Word}; -use alloc::{vec, vec::Vec}; +use alloc::{boxed::Box, vec, vec::Vec}; use core::fmt; #[cfg(feature = "zeroize")] @@ -21,8 +2...
1
27
15
32ab360efa0cf4c92224c58ab2d756209377a063
Tony Arcieri
2023-11-23T18:38:13
Remove obsolete ordering note on `Uint::mul_wide` (#304)
diff --git a/src/uint/mul.rs b/src/uint/mul.rs index cb29332..fccdfbf 100644 --- a/src/uint/mul.rs +++ b/src/uint/mul.rs @@ -20,14 +20,6 @@ impl<const LIMBS: usize> Uint<LIMBS> { /// Compute "wide" multiplication, with a product twice the size of the input. /// /// Returns a tuple containing the `(lo, hi...
1
0
8
c2646df153fd01d9afad25f820540b12effe12b1
Tony Arcieri
2023-11-23T18:25:44
Add `BoxedUint::{sbb, wrapping_sub, checked_sub}` (#303) Implements basic subtraction support for `BoxedUint`.
diff --git a/src/boxed/uint.rs b/src/boxed/uint.rs index 4771a69..a561b66 100644 --- a/src/boxed/uint.rs +++ b/src/boxed/uint.rs @@ -2,6 +2,7 @@ mod add; mod cmp; +mod sub; use crate::{Limb, Word}; use alloc::{vec, vec::Vec}; diff --git a/src/boxed/uint/sub.rs b/src/boxed/uint/sub.rs new file mode 100644 index ...
2
59
0
bfb0ac138032ff6a8398fa9fa93a266d9c792d8f
Tony Arcieri
2023-11-23T14:29:42
Flatten `uint::modular` (#300) Removes the `constant_mod` and `runtime_mod` modules from the public API, re-exporting their types under `modular`. In place of a module-level separation, this adds documentation with separate sections for constant versus runtime-dynamic moduli.
diff --git a/benches/bench.rs b/benches/bench.rs index 827357a..d39cf70 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -2,7 +2,7 @@ use criterion::{ criterion_group, criterion_main, measurement::Measurement, BatchSize, BenchmarkGroup, Criterion, }; use crypto_bigint::{ - modular::runtime_mod::{DynRes...
7
62
26
6389c77b8b563a15e39667aea16f317de96e8838
Tony Arcieri
2023-11-22T23:09:18
Simplify `uint::modular` submodule names (#299) Removes redundant `const_` and `runtime_` prefixes which already exist on their parent modules.
diff --git a/src/uint/modular/constant_mod.rs b/src/uint/modular/constant_mod.rs index f0dea15..559030d 100644 --- a/src/uint/modular/constant_mod.rs +++ b/src/uint/modular/constant_mod.rs @@ -1,11 +1,11 @@ //! Implements `Residue`s, supporting modular arithmetic with a constant modulus. -mod const_add; -mod const_i...
14
12
12
650d92782f4297a7d834873cc9e86faa37899dfe
Tony Arcieri
2023-11-22T22:59:54
crypto-bigint: formatting cleanups (#298) - Moves module-level comments to modules - Gets rid of newlines between imports that get auto-sorted by rustfmt
diff --git a/src/uint/modular.rs b/src/uint/modular.rs index cd560aa..4a57337 100644 --- a/src/uint/modular.rs +++ b/src/uint/modular.rs @@ -1,10 +1,8 @@ -mod reduction; - -/// Implements `Residue`s, supporting modular arithmetic with a constant modulus. pub mod constant_mod; -/// Implements `DynResidue`s, supporting ...
15
71
78
02ec8211053ca3e5d70d6d5074003d86a446dff3
Tony Arcieri
2023-11-21T02:54:38
`const_assert_eq`/`const_assert_ne` fixups (#297) These macros are designed to allow assertions around const generics, however the previous implementation had a number of deficiencies, most notably it only worked if the constant name was `N`. This changes the macro "type signature" to ensure the first parameter i...
diff --git a/src/macros.rs b/src/macros.rs index 7142c21..49aef10 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -4,12 +4,12 @@ #[doc(hidden)] #[macro_export] macro_rules! const_assert_n { - ($n:expr, $($arg:tt)*) => {{ + ($n:ident, $($arg:tt)*) => {{ // TODO(tarcieri): gensym a name so it's unique...
1
15
9
eba9b64c7feda327f5f0ac054e6d1c5068a20f29
Tony Arcieri
2023-11-21T02:43:58
Make `DynResidueParams::new` fallible (#296) Renames the former `DynResidueParams::new_checked` to `::new`, eliminating the potential panic condition and returning `CtOption` instead.
diff --git a/benches/bench.rs b/benches/bench.rs index 56b4eaf..827357a 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -74,7 +74,7 @@ fn bench_division<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) { } fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) { - let params = DynRe...
5
16
41
b0a566c316beb92390effb7785e90b97fcc5f38b
Bogdan Opanchuk
2023-11-21T02:16:54
Add TryFrom<&[u8]> bound to Encoding::Repr (#261)
diff --git a/src/traits.rs b/src/traits.rs index 0c26941..55d0689 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -244,7 +244,12 @@ pub trait Bounded { /// Encoding support. pub trait Encoding: Sized { /// Byte array representation. - type Repr: AsRef<[u8]> + AsMut<[u8]> + Copy + Clone + Sized; + type Re...
1
6
1
e4aa7a17ddbc57fd843d89665841a2d45b98d9b0
Tony Arcieri
2023-11-21T02:16:23
Bump version to v0.6.0-pre (#295) This version bump does not signify a release, but that we are starting a new round of breaking changes, as proposed in #268. The first actual prerelease with an associated crate released to crates.io will be versioned v0.6.0-pre.0.
diff --git a/Cargo.lock b/Cargo.lock index 1831ff3..877407c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -226,7 +226,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.5" +version = "0.6.0-pre" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index 0bace43..668...
2
2
2
5a990d579eaae6dfa95315ce6c339db0f89fed5b
Yehonatan Cohen Scaly
2023-11-18T00:06:43
Multi-exponentiation (#248) Resolves #250
diff --git a/benches/bench.rs b/benches/bench.rs index 1887417..56b4eaf 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -3,7 +3,7 @@ use criterion::{ }; use crypto_bigint::{ modular::runtime_mod::{DynResidue, DynResidueParams}, - Limb, NonZero, Random, Reciprocal, U128, U2048, U256, + Limb, MultiEx...
6
396
25
4838fd96e1bde8b0c5e0ce691c366c7ec930e466
Tony Arcieri
2023-11-17T17:34:58
Add `const_assert_eq!` and `const_assert_ne!` macros (#293) Leverages some idiosyncrasies of the Rust type system to define macros which can be used to make compile-time assertions about const generic parameters, working around the "can't use generic parameters from outer item" error which would occur if one simply...
diff --git a/src/lib.rs b/src/lib.rs index ed7af4c..dc18526 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,7 +155,7 @@ extern crate alloc; #[macro_use] -mod nlimbs; +mod macros; #[cfg(feature = "generic-array")] mod array; diff --git a/src/macros.rs b/src/macros.rs new file mode 100644 index 0000000..7142c21 ...
4
80
31
834a6645418333d9358dc887186719bf3403e036
rickwebiii
2023-11-13T21:30:13
vartime remark (#275)
diff --git a/src/uint/bits.rs b/src/uint/bits.rs index 9e6c1d7..da51405 100644 --- a/src/uint/bits.rs +++ b/src/uint/bits.rs @@ -2,6 +2,9 @@ use crate::{CtChoice, Limb, Uint, Word}; impl<const LIMBS: usize> Uint<LIMBS> { /// Returns `true` if the bit at position `index` is set, `false` otherwise. + /// + ...
1
3
0
624761889833b155fa7699cb4c62e692161a20de
Dustin Ray
2023-11-13T21:29:41
Update docs for consistency (#286) Co-authored-by: Dr. Capybara <dustinray313@gmail.com>
diff --git a/src/checked.rs b/src/checked.rs index caf0dfd..d1f6160 100644 --- a/src/checked.rs +++ b/src/checked.rs @@ -8,7 +8,7 @@ use serdect::serde::{Deserialize, Deserializer, Serialize, Serializer}; /// Provides intentionally-checked arithmetic on `T`. /// /// Internally this leverages the [`CtOption`] type fr...
8
11
11
2e30cee13ca8c40ca1e70ff43006e61b3697ffb1
daxpedda
2023-11-10T19:09:39
Implement `ArrayEncoding` for `U832` (#288)
diff --git a/src/uint/array.rs b/src/uint/array.rs index a23e84e..1f83dfc 100644 --- a/src/uint/array.rs +++ b/src/uint/array.rs @@ -61,6 +61,7 @@ impl_uint_array_encoding! { (U512, typenum::U64), (U576, typenum::U72), (U768, typenum::U96), + (U832, typenum::U104), (U896, typenum::U112), (U1...
1
1
0
ef32e28146dc904fc33e7b773402aa129310df49
Bogdan Opanchuk
2023-11-09T00:02:46
Make `Uint::random_mod()` work identically on 32- and 64-bit targets (#285)
diff --git a/src/uint/rand.rs b/src/uint/rand.rs index c5f730b..80af3bb 100644 --- a/src/uint/rand.rs +++ b/src/uint/rand.rs @@ -1,7 +1,7 @@ //! Random number generator support use super::Uint; -use crate::{Limb, NonZero, Random, RandomMod}; +use crate::{Encoding, Limb, NonZero, Random, RandomMod}; use rand_core::...
1
17
6
63703b6e31308d35950fc23858f1b5156b65b43a
Bogdan Opanchuk
2023-10-14T19:26:48
Add `trailing_ones[_vartime]()`, `trailing_zeros_vartime()`, `leading_zeros_vartime()` (#282)
diff --git a/src/limb/bits.rs b/src/limb/bits.rs index 02a74de..c769e33 100644 --- a/src/limb/bits.rs +++ b/src/limb/bits.rs @@ -15,4 +15,9 @@ impl Limb { pub const fn trailing_zeros(self) -> usize { self.0.trailing_zeros() as usize } + + /// Calculate the number of trailing ones the binary repres...
2
168
13
e624e3a2f5044094ca7cc7815c126ca91b57a0aa
Tony Arcieri
2023-09-03T20:55:47
Make `Uint::inv_mod` a `const fn` (#271)
diff --git a/src/uint/inv_mod.rs b/src/uint/inv_mod.rs index cf7cf07..e41dc66 100644 --- a/src/uint/inv_mod.rs +++ b/src/uint/inv_mod.rs @@ -146,7 +146,7 @@ impl<const LIMBS: usize> Uint<LIMBS> { /// Computes the multiplicative inverse of `self` mod `modulus`. /// Returns `(inverse, CtChoice::TRUE)` if an inv...
1
3
3
e0320a1cef4e7934d851a199e193b9284b02da45
Bogdan Opanchuk
2023-09-02T20:58:20
Modular inversion improvements (#263)
diff --git a/benches/bench.rs b/benches/bench.rs index 26ee63a..1887417 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -153,6 +153,59 @@ fn bench_shifts<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) { }); } +fn bench_inv_mod<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) { + group.bench_fun...
7
285
27
ed9a92f9325478d262587704dae8f489c5a19961
Bogdan Opanchuk
2023-08-30T18:53:23
Add subtle trait impls for DynResidue and DynResidueParams (#269)
diff --git a/src/uint/modular/runtime_mod.rs b/src/uint/modular/runtime_mod.rs index 4468d71..b1c1e9f 100644 --- a/src/uint/modular/runtime_mod.rs +++ b/src/uint/modular/runtime_mod.rs @@ -7,7 +7,7 @@ use super::{ Retrieve, }; -use subtle::CtOption; +use subtle::{Choice, ConditionallySelectable, ConstantTimeEq,...
1
47
1
e0d71af4dad357efc06383d83c7b1816a55badbe
Bogdan Opanchuk
2023-08-28T16:58:36
Add constant-time `Uint::shr()` and `Uint::shl()` (#267)
diff --git a/benches/bench.rs b/benches/bench.rs index 8be5f59..26ee63a 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -3,7 +3,7 @@ use criterion::{ }; use crypto_bigint::{ modular::runtime_mod::{DynResidue, DynResidueParams}, - Limb, NonZero, Random, Reciprocal, U128, U256, + Limb, NonZero, Rando...
8
115
11
3126405cc4c4dcc9e6c1a34efe5be5c8876924e4
Bogdan Opanchuk
2023-08-28T13:54:39
Add `const fn` constructors for `NonZero<Uint>` and `NonZero<Limb>` (#266)
diff --git a/src/non_zero.rs b/src/non_zero.rs index ccee78b..997dfc2 100644 --- a/src/non_zero.rs +++ b/src/non_zero.rs @@ -1,6 +1,6 @@ //! Wrapper type for non-zero integers. -use crate::{Encoding, Integer, Limb, Uint, Zero}; +use crate::{CtChoice, Encoding, Integer, Limb, Uint, Zero}; use core::{ fmt, ...
1
17
1
177035e00f33e52b66c5b113d7e60c067c5b0c48
Bogdan Opanchuk
2023-08-28T13:45:36
Use references in bit-twiddling methods of Uint (#265)
diff --git a/src/uint/bits.rs b/src/uint/bits.rs index 8340143..500a931 100644 --- a/src/uint/bits.rs +++ b/src/uint/bits.rs @@ -3,7 +3,7 @@ use crate::{CtChoice, Limb, Uint, Word}; impl<const LIMBS: usize> Uint<LIMBS> { /// Returns `true` if the bit at position `index` is set, `false` otherwise. #[inline(al...
1
6
6
bd1af3dd11605b3857596994407e198d033d6088
Tony Arcieri
2023-07-16T22:41:38
`const_evaluatable_checked` => `generic_const_exprs` The upstream rustc feature was renamed. This updates comments which refer to it.
diff --git a/src/uint.rs b/src/uint.rs index c6c4cc6..341685d 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -295,7 +295,7 @@ where #[cfg(feature = "zeroize")] impl<const LIMBS: usize> DefaultIsZeroes for Uint<LIMBS> {} -// TODO(tarcieri): use `const_evaluatable_checked` when stable to make generic around bits. +// ...
3
3
3
189449f319c912965348c24fee83a3c32d1706eb
Bogdan Opanchuk
2023-07-01T22:52:32
NCC audit fixes (#256) - Remove conditionals in `Uint::saturating_add()` and `saturating_mul()` - More logical checks in the `Uint::random_mod()` test - Mark `sqrt` for renaming, to explicitly describe it as vartime
diff --git a/src/uint/add.rs b/src/uint/add.rs index 21aa5d5..e4f7bfa 100644 --- a/src/uint/add.rs +++ b/src/uint/add.rs @@ -24,12 +24,7 @@ impl<const LIMBS: usize> Uint<LIMBS> { /// Perform saturating addition, returning `MAX` on overflow. pub const fn saturating_add(&self, rhs: &Self) -> Self { let...
5
90
39
be8cd7bdeb113e02be79c360471e29596cd2babb
Yehonatan Cohen Scaly
2023-06-27T12:34:23
Add U16384 and U32768 (#255)
diff --git a/src/uint.rs b/src/uint.rs index db4bb93..c6c4cc6 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -323,7 +323,9 @@ impl_uint_aliases! { (U4224, 4224, "4224-bit"), (U4352, 4352, "4352-bit"), (U6144, 6144, "6144-bit"), - (U8192, 8192, "8192-bit") + (U8192, 8192, "8192-bit"), + (U16384, 1...
1
4
1
a49189925e4e8721e1ff76e3f0f8e8d959761f66
Yehonatan Cohen Scaly
2023-06-25T14:42:40
Make pow work with different sized exponents (#251)
diff --git a/src/uint/modular/constant_mod/const_pow.rs b/src/uint/modular/constant_mod/const_pow.rs index 60455b0..ea3dd1c 100644 --- a/src/uint/modular/constant_mod/const_pow.rs +++ b/src/uint/modular/constant_mod/const_pow.rs @@ -4,8 +4,11 @@ use super::{Residue, ResidueParams}; impl<MOD: ResidueParams<LIMBS>, co...
3
19
9
3c89a6eb302574de9e233056cfbd95efdbea291c
Andrew Whitehead
2023-06-25T02:10:31
Concat/split and multiply mixed size Uints (#253) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/traits.rs b/src/traits.rs index da9b9b6..b500001 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -187,26 +187,49 @@ pub trait CheckedSub<Rhs = Self>: Sized { fn checked_sub(&self, rhs: Rhs) -> CtOption<Self>; } -/// Concatenate two numbers into a "wide" twice-width value, using the `rhs` +///...
9
494
405
0fdd45bb62cc604bc4c8147fbcfe01da17779b58
Andrew Whitehead
2023-06-25T02:08:22
Expose and optimize wrapping_neg (#252) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/limb.rs b/src/limb.rs index 73f3fee..334e5ea 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -13,6 +13,7 @@ mod cmp; mod encoding; mod from; mod mul; +mod neg; mod shl; mod shr; mod sub; diff --git a/src/limb/neg.rs b/src/limb/neg.rs new file mode 100644 index 0000000..b658bb9 --- /dev/null +++ b/s...
4
57
35
2122b4a2a47d96bc80a15ef577e0fb5023af8c39
Bogdan Opanchuk
2023-06-20T01:07:09
Make Uint::from_be_hex() and from_le_hex() constant-time (#254)
diff --git a/src/uint/encoding.rs b/src/uint/encoding.rs index 5431b81..42f9de1 100644 --- a/src/uint/encoding.rs +++ b/src/uint/encoding.rs @@ -46,18 +46,23 @@ impl<const LIMBS: usize> Uint<LIMBS> { let mut res = [Limb::ZERO; LIMBS]; let mut buf = [0u8; Limb::BYTES]; let mut i = 0; + ...
1
41
25
b158cedaba1e2f13c9fb96bb3f9b5265b255a1a3
Aaron Feickert
2023-05-26T16:23:41
Enforce valid modulus for `Residue` and associated macros (#243)
diff --git a/src/uint/modular/constant_mod.rs b/src/uint/modular/constant_mod.rs index 92b6ce7..b775af4 100644 --- a/src/uint/modular/constant_mod.rs +++ b/src/uint/modular/constant_mod.rs @@ -1,6 +1,6 @@ use core::{fmt::Debug, marker::PhantomData}; -use subtle::{Choice, ConditionallySelectable, ConstantTimeEq}; +us...
2
38
5
c7b4694f4bf73d795e34557857f6f1dac950ac45
Aaron Feickert
2023-05-26T12:48:43
Enforce valid modulus for `DynResidueParams` (#240)
diff --git a/src/uint/modular/runtime_mod.rs b/src/uint/modular/runtime_mod.rs index 32b0785..4468d71 100644 --- a/src/uint/modular/runtime_mod.rs +++ b/src/uint/modular/runtime_mod.rs @@ -7,6 +7,8 @@ use super::{ Retrieve, }; +use subtle::CtOption; + /// Additions between residues with a modulus set at runtim...
1
61
3
3dd841a4f32feac14f883a22f4b04594c4618d1c
Yehonatan Cohen Scaly
2023-05-22T01:59:19
Add U4224 and U4352 (#233)
diff --git a/src/uint.rs b/src/uint.rs index b673aa6..c54e553 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -357,6 +357,8 @@ impl_uint_aliases! { (U3072, 3072, "3072-bit"), (U3584, 3584, "3584-bit"), (U4096, 4096, "4096-bit"), + (U4224, 4224, "4224-bit"), + (U4352, 4352, "4352-bit"), (U6144, 6...
2
7
7
3318efa75f106253e26c74729514498090596a7d
Aaron Feickert
2023-05-22T01:58:43
Add zeroizing to `DynResidue` (#235)
diff --git a/src/uint/modular/runtime_mod.rs b/src/uint/modular/runtime_mod.rs index f0e993d..32b0785 100644 --- a/src/uint/modular/runtime_mod.rs +++ b/src/uint/modular/runtime_mod.rs @@ -186,3 +186,11 @@ impl<const LIMBS: usize, P: ResidueParams<LIMBS>> From<&Residue<P, LIMBS>> for D } } } + +/// NOTE:...
1
8
0
7bc52eeb5d5e2faa59a68f1a6c299c618e40d79c
Andrew Whitehead
2023-05-21T23:17:39
add cmp_vartime, ct_cmp (#238) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/ct_choice.rs b/src/ct_choice.rs index 56bb79d..d0d31dc 100644 --- a/src/ct_choice.rs +++ b/src/ct_choice.rs @@ -50,11 +50,15 @@ impl CtChoice { pub(crate) const fn is_true_vartime(&self) -> bool { self.0 == CtChoice::TRUE.0 } + + pub(crate) const fn to_u8(self) -> u8 { + (s...
2
90
11
1fe5dad3d806f96a7a3260c8969f0676759f2a98
Andrew Whitehead
2023-05-19T00:09:54
Expose montgomery form in Residue/DynResidue (#239) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/uint/modular/constant_mod.rs b/src/uint/modular/constant_mod.rs index 3e9b522..92b6ce7 100644 --- a/src/uint/modular/constant_mod.rs +++ b/src/uint/modular/constant_mod.rs @@ -59,6 +59,7 @@ pub trait ResidueParams<const LIMBS: usize>: #[derive(Debug, Clone, Copy, PartialEq, Eq)] /// A residue mod `...
2
79
1
85f0f6e7aaad608020538f41dbb57efab0f41615
Tony Arcieri
2023-05-08T17:18:14
Factor `extra-sizes` definitions under a submodule (#231) Extracts an `extra_sizes` submodule gated on the `extra-sizes` feature. Moving the definitions to a submodule means the type aliases are appropriately tagged in the rustdoc. It also reduces the amount of feature-specific gating required, and keeps uint....
diff --git a/src/uint.rs b/src/uint.rs index c5bd718..b673aa6 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -335,116 +335,6 @@ macro_rules! impl_uint_aliases { }; } -#[cfg(feature = "extra-sizes")] -impl_uint_aliases! { - (U704, 704, "704-bit"), - (U832, 832, "832-bit"), - (U960, 960, "960-bit"), - ...
2
286
276
a459375deb89c07e9c5ef83fc2d9045dfb953805
Yehonatan Cohen Scaly
2023-05-08T16:45:40
Add `extra-sizes` feature (#229)
diff --git a/Cargo.toml b/Cargo.toml index 832b484..8e955d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,7 @@ default = ["rand"] alloc = ["serdect?/alloc"] rand = ["rand_core/std"] serde = ["dep:serdect"] +extra-sizes = [] [package.metadata.docs.rs] all-features = true diff --git a/src/uint.rs b/src/uin...
2
277
0
a5fe39b084638f9520bcc1a10182a8ac1f4bba59
Sam Tay
2023-05-03T01:22:02
Fix serdect usage (#222)
diff --git a/Cargo.toml b/Cargo.toml index 5250890..832b484 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ rand_chacha = "0.3" [features] default = ["rand"] -alloc = [] +alloc = ["serdect?/alloc"] rand = ["rand_core/std"] serde = ["dep:serdect"]
1
1
1
2a29f9ab8b9f40b3b223db596ce094d2272eaf53
Bogdan Opanchuk
2023-04-20T21:43:15
Div-by-2 adjustment (#212) - Use shr_1() to calculate the shifted value and parity at the same time - Update the docstring of shr_1()
diff --git a/src/uint/modular/div_by_2.rs b/src/uint/modular/div_by_2.rs index e11dc0a..20c0a5d 100644 --- a/src/uint/modular/div_by_2.rs +++ b/src/uint/modular/div_by_2.rs @@ -18,7 +18,7 @@ pub(crate) fn div_by_2<const LIMBS: usize>(a: &Uint<LIMBS>, modulus: &Uint<LIMBS // ("+1" because both `a` and `modulus` are...
2
3
4
f97767083a9022f9d5e211b598650de0dc98cdad
Bogdan Opanchuk
2023-04-20T18:34:42
Add `div_by_2()` method for integers in Montgomery form (#211)
diff --git a/src/uint/modular.rs b/src/uint/modular.rs index ff20f44..cd560aa 100644 --- a/src/uint/modular.rs +++ b/src/uint/modular.rs @@ -6,6 +6,7 @@ pub mod constant_mod; pub mod runtime_mod; mod add; +mod div_by_2; mod inv; mod mul; mod pow; diff --git a/src/uint/modular/constant_mod.rs b/src/uint/modular/c...
5
80
2
91d425270029e81c200b2626b37d62ff734cd430
Luke Parker
2023-04-19T12:58:17
Add DefaultIsZeroes annotation to Residue (#210)
diff --git a/src/uint/modular/constant_mod.rs b/src/uint/modular/constant_mod.rs index f94e4c4..bc14d59 100644 --- a/src/uint/modular/constant_mod.rs +++ b/src/uint/modular/constant_mod.rs @@ -67,6 +67,12 @@ where phantom: PhantomData<MOD>, } +#[cfg(feature = "zeroize")] +impl<MOD: ResidueParams<LIMBS>, const L...
1
6
0
a02c5054774695345319b7f00f6608d272bdff2b
Bogdan Opanchuk
2023-04-02T22:27:44
Housekeeping fixes (#204) * Add Montgomery conversion benches, use iter_batched() * Make the debug assert consistent with the docstring * Move sub_mod_with_hi() closer to sub_mod() and rename the variables for uniformity
diff --git a/benches/bench.rs b/benches/bench.rs index 9d2e130..8be5f59 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -1,159 +1,148 @@ use criterion::{ - criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, + criterion_group, criterion_main, measurement::Measurement, Ba...
4
134
152
74b481ba1d6f79ee6856cea0d6683072d3873489
Bogdan Opanchuk
2023-03-29T16:06:34
Montgomery multiplication improvements (#203)
diff --git a/benches/bench.rs b/benches/bench.rs index e047780..9d2e130 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -104,10 +104,54 @@ fn bench_modpow<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { }); } +fn bench_montgomery<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { + con...
6
110
61
095640d791cc58020a80702da73b441ca774d9c2
Bogdan Opanchuk
2023-03-24T15:38:21
Expose residue params and modulus in DynResidue (#197)
diff --git a/src/uint/modular/runtime_mod.rs b/src/uint/modular/runtime_mod.rs index 72f1094..1b45ac9 100644 --- a/src/uint/modular/runtime_mod.rs +++ b/src/uint/modular/runtime_mod.rs @@ -48,6 +48,11 @@ impl<const LIMBS: usize> DynResidueParams<LIMBS> { mod_neg_inv, } } + + /// Returns th...
1
10
0
0a38fee3079fdcf2e57f1fc5e0227b73db053b91
Dirk Stolle
2023-03-23T21:14:06
Fix a few typos (#199)
diff --git a/src/ct_choice.rs b/src/ct_choice.rs index 1308dd3..5ccbb0e 100644 --- a/src/ct_choice.rs +++ b/src/ct_choice.rs @@ -9,10 +9,10 @@ use crate::Word; pub struct CtChoice(Word); impl CtChoice { - /// The falsy vaue. + /// The falsy value. pub const FALSE: Self = Self(0); - /// The truthy va...
3
4
4
1e334c49a364afcce84784d3e0e003529952eef1
Tony Arcieri
2023-03-13T17:58:45
Improve `Debug` impls on `Limb` and `Uint` (#195) Instead of deriving `Debug`, uses the `UpperHex` impls to print a hex inspection of the inner value.
diff --git a/src/limb.rs b/src/limb.rs index 3155ffd..73f3fee 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -59,7 +59,7 @@ pub(crate) const HI_BIT: usize = Limb::BITS - 1; /// Big integers are represented as an array of smaller CPU word-size integers /// called "limbs". -#[derive(Copy, Clone, Debug, Default, Hash)]...
2
47
4
6e5213b887766c91a6a381c61db359e31a0b0893
Ola Bini
2023-03-06T21:53:44
Fix #191 by using a module path available from the outside of the create (#193) Fix #191 by using a module path that is available from outside of the crate, and add a test to make sure the macro const_residue is possible to use outside of the crate Co-authored-by: Ola Bini <ola@olabini.se>
diff --git a/src/uint/modular/constant_mod/macros.rs b/src/uint/modular/constant_mod/macros.rs index 42c8d6e..1583ca5 100644 --- a/src/uint/modular/constant_mod/macros.rs +++ b/src/uint/modular/constant_mod/macros.rs @@ -45,8 +45,6 @@ macro_rules! impl_modulus { /// For example, `residue!(U256::from(105u64), MyModulus...
2
11
3
2bda2d4e35e66baac0ae4e9aab0828a558b2f0c5
Tony Arcieri
2023-02-28T22:35:28
Cargo.lock: bump dependencies (#190)
diff --git a/Cargo.lock b/Cargo.lock index 426e528..21a182f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,16 +14,16 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", +...
1
252
108
5bec2f28c14976ac9bbf983f3652d8e9413235cc
Heorhii Azarov
2023-02-17T16:44:55
Fix convert from tuple (#183) Looks like you're right. Thanks!
diff --git a/src/uint/concat.rs b/src/uint/concat.rs index 906bb2e..8b53401 100644 --- a/src/uint/concat.rs +++ b/src/uint/concat.rs @@ -37,7 +37,7 @@ macro_rules! impl_concat { impl From<($name, $name)> for Uint<{nlimbs!($bits) * 2}> { fn from(nums: ($name, $name)) -> Uint<{nlimbs!($bit...
1
10
1
a8570cdc7044e1d1ffccc131a77ab9ca5e6a8358
skaunov
2023-02-06T15:13:44
Correct minor typo in `lib.rs` (#175)
diff --git a/src/lib.rs b/src/lib.rs index 0893e79..0a790c8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,7 +22,7 @@ //! //! This crate defines a [`Uint`] type which is const generic around an inner //! [`Limb`] array, where a [`Limb`] is a newtype for a word-sized integer. -//! Thus large integers are represented...
1
1
1
14056cb89b692e8e00d11c698c43a0c12d8ba8ba
Tony Arcieri
2023-02-06T02:29:14
Impl `ArrayEncoding` for U224/U544 (#180) Need for `elliptic-curves` implementations
diff --git a/src/uint/array.rs b/src/uint/array.rs index 4d3790c..36f165e 100644 --- a/src/uint/array.rs +++ b/src/uint/array.rs @@ -73,6 +73,12 @@ impl_uint_array_encoding! { (U8192, typenum::U1024) } +#[cfg(target_pointer_width = "32")] +impl_uint_array_encoding! { + (U224, typenum::U28), // For NIST P-224...
1
6
0
3814e8659916c859e778e3e7c286a47e62886aec
Tony Arcieri
2023-02-05T02:36:34
Define `U224` and `U544` on 32-bit platforms (#179) These are useful for P-224 and P-521 respectively. They're gated on the target using 32-bit limbs (since neither is a multiple of 64). fiat-crypto provides P-224 field arithmetic for 32-bit platforms that uses 7 limbs, for example.
diff --git a/src/uint.rs b/src/uint.rs index 147946c..5478027 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -355,6 +355,12 @@ impl_uint_aliases! { (U8192, 8192, "8192-bit") } +#[cfg(target_pointer_width = "32")] +impl_uint_aliases! { + (U224, 224, "224-bit"), // For NIST P-224 + (U544, 544, "544-bit") //...
1
6
0