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
a68fe3b09fc9438cbc201f7b7d6c765ecdc9b0b7
Tony Arcieri
2023-02-01T17:26:37
crypto-bigint: fix test vectors (#178) One of the "primes" in a list used in tests was accidentally 256 instead of 257. This had no actual impact on the test and they continue to pass.
diff --git a/src/limb/mul.rs b/src/limb/mul.rs index 5df7375..7f8b084 100644 --- a/src/limb/mul.rs +++ b/src/limb/mul.rs @@ -159,7 +159,7 @@ mod tests { #[test] fn mul_wide() { - let primes: &[u32] = &[3, 5, 17, 256, 65537]; + let primes: &[u32] = &[3, 5, 17, 257, 65537]; for &a_int...
2
2
2
073752761974e11115ab31aa1dfbd3b0e7210e98
Tony Arcieri
2023-01-31T17:25:36
v0.5.0-pre.3 (#177)
diff --git a/Cargo.lock b/Cargo.lock index c9574b0..de8c6bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.0-pre.2" +version = "0.5.0-pre.3" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index 46ee...
2
2
2
56291063f9bb8167fd85f256f8297df993d17a1f
Tony Arcieri
2023-01-31T17:13:39
crypto-bigint: fix recursion bug in `Rem` impl for `Uint` (#176) Previously this accidentally recursed instead of calling the inherent method: thread 'uint::div::tests::rem_trait' has overflowed its stack fatal runtime error: stack overflow error: test failed, to rerun pass `--lib` This uses UFCS ...
diff --git a/src/uint/div.rs b/src/uint/div.rs index d47c505..90741c4 100644 --- a/src/uint/div.rs +++ b/src/uint/div.rs @@ -520,7 +520,7 @@ impl<const LIMBS: usize> Rem<NonZero<Uint<LIMBS>>> for Uint<LIMBS> { type Output = Uint<LIMBS>; fn rem(self, rhs: NonZero<Uint<LIMBS>>) -> Self::Output { - self...
1
13
1
c10127d60b4323e0a63b8234723b5671b5401abc
Tony Arcieri
2023-01-27T19:12:04
v0.5.0-pre.2 (#174)
diff --git a/Cargo.lock b/Cargo.lock index c2a909b..c9574b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.0-pre.1" +version = "0.5.0-pre.2" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index d570...
2
2
2
b754b2a637e99c2411b359b329929e292cb9c327
haslersn
2023-01-23T19:49:57
Make `impl_modulus!` usable from external crates (#172) Previously it was impossible to use `impl_modulus!` in crates that use crypto-bigint, because certain functions were only available within the crypto-bigint crate.
diff --git a/src/uint/div.rs b/src/uint/div.rs index 0f3df25..d47c505 100644 --- a/src/uint/div.rs +++ b/src/uint/div.rs @@ -44,7 +44,7 @@ impl<const LIMBS: usize> Uint<LIMBS> { /// Computes `self` / `rhs`, returns the quotient (q), remainder (r) /// and the truthy value for is_some or the falsy value for is_...
6
44
32
3d3c1caf611304e69b88cf4594dc96ba43b96765
haslersn
2023-01-23T16:55:03
Impl `Serialize` and `Deserialize` for `Residue` (#170)
diff --git a/src/uint/modular/constant_mod.rs b/src/uint/modular/constant_mod.rs index a6e0130..b76ad94 100644 --- a/src/uint/modular/constant_mod.rs +++ b/src/uint/modular/constant_mod.rs @@ -9,6 +9,13 @@ use super::{reduction::montgomery_reduction, Retrieve}; #[cfg(feature = "rand_core")] use crate::{rand_core::Cry...
1
44
0
85617bc38e3e0a7f346e0aaa4999aeb0e58ca061
haslersn
2023-01-23T15:40:30
Support to concat `U320` and `U640` (#173) - Add concat support for the `U320` and `U640` types - Add split support for the resulting `U640` and `U1280` types - While we're at it, remove (anyway broken) split support for types with odd number of limbs
diff --git a/src/uint.rs b/src/uint.rs index 79816f5..147946c 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -335,13 +335,16 @@ impl_uint_aliases! { (U128, 128, "128-bit"), (U192, 192, "192-bit"), (U256, 256, "256-bit"), + (U320, 320, "320-bit"), (U384, 384, "384-bit"), (U448, 448, "448-bit")...
1
7
2
50dccd3222a3af95877d262cfa0bf48f053bd223
haslersn
2023-01-19T23:35:46
Require some additional traits for `ResidueParams` (#171) This makes it easier to handle `ResidueParams` and `Residue` in generic code.
diff --git a/src/uint/modular/constant_mod.rs b/src/uint/modular/constant_mod.rs index ca278b0..a6e0130 100644 --- a/src/uint/modular/constant_mod.rs +++ b/src/uint/modular/constant_mod.rs @@ -1,4 +1,4 @@ -use core::marker::PhantomData; +use core::{fmt::Debug, marker::PhantomData}; use subtle::{Choice, Conditionally...
2
5
3
84a1268a3aac122be5a4e4f20b84ec0968ce8bcb
haslersn
2023-01-17T15:07:30
Impl `Random` for `Wrapping` (#168)
diff --git a/src/wrapping.rs b/src/wrapping.rs index c2f6c2b..83311c5 100644 --- a/src/wrapping.rs +++ b/src/wrapping.rs @@ -4,6 +4,9 @@ use crate::Zero; use core::fmt; use subtle::{Choice, ConditionallySelectable, ConstantTimeEq}; +#[cfg(feature = "rand_core")] +use {crate::Random, rand_core::CryptoRngCore}; + #[...
1
10
0
13fe5277f21a8da1846db31fd1a942a2c67efbd5
haslersn
2023-01-17T15:03:57
Impl `Random` for `Residue` (#169) For `DynResidue` we cannot implement `Random`, because parameters would need to be passed to know the modulus.
diff --git a/src/uint/modular/constant_mod.rs b/src/uint/modular/constant_mod.rs index 2cba810..ca278b0 100644 --- a/src/uint/modular/constant_mod.rs +++ b/src/uint/modular/constant_mod.rs @@ -6,6 +6,9 @@ use crate::{Limb, Uint, Zero}; use super::{reduction::montgomery_reduction, Retrieve}; +#[cfg(feature = "rand_...
1
14
0
e8c8a778fc903ff76e65d97eea4fb6eb0a5f5db5
haslersn
2023-01-17T14:59:46
Add const versions of `Residue::square` and `DynResidue::square` (#166)
diff --git a/src/uint/modular/constant_mod/const_mul.rs b/src/uint/modular/constant_mod/const_mul.rs index c3ea455..3bce184 100644 --- a/src/uint/modular/constant_mod/const_mul.rs +++ b/src/uint/modular/constant_mod/const_mul.rs @@ -23,6 +23,18 @@ impl<MOD: ResidueParams<LIMBS>, const LIMBS: usize> Residue<MOD, LIMBS> ...
2
26
16
e598ad648254da32928cbc3212b0ed1e51c12829
Tony Arcieri
2023-01-17T04:26:08
Use `CryptoRngCore` (#164) More succinct marker trait introduced in `rand_core` v0.6.4
diff --git a/Cargo.toml b/Cargo.toml index 5a9d380..d570094 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ subtle = { version = "2.4", default-features = false } # optional dependencies der = { version = "0.6", optional = true, default-features = false } generic-array = { version = "0.14", optional = tru...
5
13
16
c765e0282a77f262de92793137fe2329fdd079a1
Tony Arcieri
2023-01-13T23:40:03
v0.5.0-pre.1 (#162)
diff --git a/Cargo.lock b/Cargo.lock index 5e68594..c2a909b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.0-pre.0" +version = "0.5.0-pre.1" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index 0f48...
2
2
2
78fc4ed3ac528f10fb1073e9e7992dc3a244557e
Tony Arcieri
2023-01-13T23:02:56
Add `BITS`, `BYTES`, and `LIMBS` to `Integer` trait (#161) Makes all of `Uint`'s inherent constants available through the `Integer` trait as well. This is needed for the `elliptic-curve` crate, which uses the `Integer` trait and accesses some of these constants.
diff --git a/src/traits.rs b/src/traits.rs index d876da7..e73970d 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -47,6 +47,15 @@ pub trait Integer: /// Maximum value this integer can express. const MAX: Self; + /// Total size of the represented integer in bits. + const BITS: usize; + + /// Total...
2
15
3
b284dd69deab343a2a0a9b435a2f1825ef494328
Tony Arcieri
2023-01-13T22:42:01
v0.5.0-pre.0 (#160)
diff --git a/Cargo.lock b/Cargo.lock index 3a91520..5e68594 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -220,7 +220,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.0-pre" +version = "0.5.0-pre.0" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index 0f225d...
2
2
2
64d24045256290d03649c5a32a8647a3b62a011c
Bogdan Opanchuk
2022-12-31T21:22:39
Use built-in traits for `(Dyn)Resiude` (#155) - Remove `AddResidue`, `SubResidue`, `MulResidue`, `InvResidue`, `PowResidue` - Impl `Add`, `Mul`, `Sub`, and `Neg` for `Residue` and `DynResidue` (also the combinations of by-ref and by-value, and the corresponding `const fn`s) - Add `Pow`, `Invert` and `Square` trai...
diff --git a/benches/bench.rs b/benches/bench.rs index c279892..8be7834 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -2,10 +2,7 @@ use criterion::{ criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, }; use crypto_bigint::{ - modular::{ - runtime_mod::{DynRe...
21
496
294
2328b8852f4af1bc534ec675d73b1c9d1cf6b03b
Jelle Vos
2022-12-28T17:20:47
Implement more efficient squaring operation (#133) Translates the implementation originally from: https://github.com/ucbrise/jedi-pairing/blob/c4bf151/include/core/bigint.hpp#L410 Permission from the original author has been given to relicense the resulting translation as Apache 2.0 + MIT
diff --git a/src/uint/mul.rs b/src/uint/mul.rs index 507e270..7c4dc7a 100644 --- a/src/uint/mul.rs +++ b/src/uint/mul.rs @@ -1,6 +1,6 @@ //! [`Uint`] addition operations. -use crate::{Checked, CheckedMul, Concat, Limb, Uint, Wrapping, Zero}; +use crate::{Checked, CheckedMul, Concat, Limb, Uint, WideWord, Word, Wrapp...
1
80
3
6cb2ac9041019b47c194a729feb32eaead6697dd
Bogdan Opanchuk
2022-12-24T14:50:45
Rename `BIT_SIZE` -> `BITS`, `BYTE_SIZE` -> `BYTES` (#157) Also adds Uint::BITS and Uint::BYTES inherent constants to mimic Limb
diff --git a/benches/bench.rs b/benches/bench.rs index cc7425b..c279892 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -6,7 +6,7 @@ use crypto_bigint::{ runtime_mod::{DynResidue, DynResidueParams}, PowResidue, }, - Encoding, NonZero, Random, Reciprocal, Uint, U256, + NonZero, Rando...
27
104
107
af95d7a04a03e92d10cce3d6e10d10fd375e29bc
Bogdan Opanchuk
2022-12-23T17:17:45
Add constant-time `leading_zeros()`, `trailing_zeros()`, `bits()`, and `bit()` for `Uint` (#153)
diff --git a/src/limb/bits.rs b/src/limb/bits.rs index c470ae9..17f96a4 100644 --- a/src/limb/bits.rs +++ b/src/limb/bits.rs @@ -5,4 +5,14 @@ impl Limb { pub const fn bits(self) -> usize { Limb::BIT_SIZE - (self.0.leading_zeros() as usize) } + + /// Calculate the number of leading zeros in the bin...
3
135
5
f7d83634c7ca6453aa712a4b930a0b76997b71ae
Bogdan Opanchuk
2022-12-23T15:14:21
Fix integer overflow in div2by1() (#156) If it overflows we do not follow this branch, but we still have to calculate it because of constant-timeness.
diff --git a/src/uint/div_limb.rs b/src/uint/div_limb.rs index 3e6163d..5bdbc0d 100644 --- a/src/uint/div_limb.rs +++ b/src/uint/div_limb.rs @@ -146,8 +146,12 @@ const fn div2by1(u1: Word, u0: Word, reciprocal: &Reciprocal) -> (Word, Word) { let q1 = Limb::ct_select(Limb(q1), Limb(q1.wrapping_sub(1)), r_gt_q0).0; ...
1
22
1
9316a1d6a4e536a55c7820c9feb90a97f1d37fc6
Bogdan Opanchuk
2022-12-21T14:58:31
Add SubResidue trait and impls for Residue and DynResidue (#149)
diff --git a/src/uint/modular.rs b/src/uint/modular.rs index a93d772..59a9943 100644 --- a/src/uint/modular.rs +++ b/src/uint/modular.rs @@ -13,6 +13,7 @@ mod add; mod inv; mod mul; mod pow; +mod sub; /// Provides a consistent interface to add two residues of the same type together. pub trait AddResidue { @@ -20...
6
172
0
023b62169be8868ce5ad8bc45713f2536eb3d9e3
Bogdan Opanchuk
2022-12-19T15:11:49
Fix a warning during documentation build (#152)
diff --git a/src/uint/div_limb.rs b/src/uint/div_limb.rs index 8b159da..3e6163d 100644 --- a/src/uint/div_limb.rs +++ b/src/uint/div_limb.rs @@ -1,6 +1,6 @@ //! Implementation of constant-time division via reciprocal precomputation, as described in //! "Improved Division by Invariant Integers" by Niels Möller and Tor...
1
1
1
8ab4265d9b7d4e40d1778db6f82049c87eca0191
Tony Arcieri
2022-12-17T15:43:11
Re-export `constant_mod` macros from the parent module (#151) These are defined in `modular::constant_mod::macros` module. It was previously `pub`, but to shorten things up this commit makes that module private and re-exports the macros from `modular::const_mod`.
diff --git a/src/uint/modular/constant_mod.rs b/src/uint/modular/constant_mod.rs index d815f8c..981466c 100644 --- a/src/uint/modular/constant_mod.rs +++ b/src/uint/modular/constant_mod.rs @@ -15,9 +15,11 @@ mod const_mul; /// Exponentiation of residues with a constant modulus mod const_pow; -#[macro_use] /// Macr...
1
4
2
4d0e1d34d6160c61e4901755f5637c8a7a9571bb
Bogdan Opanchuk
2022-12-11T19:20:47
Add windowed exponentiation for (Dyn)Residue (#147)
diff --git a/benches/bench.rs b/benches/bench.rs index 67767c7..cc7425b 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -1,7 +1,13 @@ use criterion::{ criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, }; -use crypto_bigint::{NonZero, Random, Reciprocal, Uint}; +use cry...
7
177
25
8f684a1aa5d5c125a9e7e6a366bd686ca4492cda
Bogdan Opanchuk
2022-12-11T14:55:24
Faster random_mod (#146) Co-authored-by: Steve Thomas <Sc00bz@users.noreply.github.com>
diff --git a/src/limb/rand.rs b/src/limb/rand.rs index 0bc8af3..7205063 100644 --- a/src/limb/rand.rs +++ b/src/limb/rand.rs @@ -23,20 +23,15 @@ impl RandomMod for Limb { fn random_mod(mut rng: impl CryptoRng + RngCore, modulus: &NonZero<Self>) -> Self { let mut bytes = <Self as Encoding>::Repr::default()...
2
10
28
b647915e2b883a315d30141115520398678b1979
Tony Arcieri
2022-12-09T02:48:51
Rename `Uint` methods and other TODOs (#144) Addresses a number of todos in `uint.rs` including renaming the following methods for consistency: - `limbs` -> `as_limbs` - `limbs_mut` -> `as_limbs_mut` - `into_limbs` -> `to_limbs`
diff --git a/src/non_zero.rs b/src/non_zero.rs index 1034665..0b93c43 100644 --- a/src/non_zero.rs +++ b/src/non_zero.rs @@ -243,7 +243,7 @@ impl<const LIMBS: usize> NonZero<Uint<LIMBS>> { let mut i = 0; let mut found_non_zero = false; while i < LIMBS { - if n.limbs()[i].0 != 0 { +...
5
25
31
3c03a76bcc906619f597a9a48f56e429f0ccb048
Tony Arcieri
2022-12-09T01:41:57
Bump version to `v0.5.0-pre`; remove deprecations (#142) Breaking changes were introduced in #130, so this bumps the crate's version to a prerelease to denote that. It will be bumped to `pre.0` for an actual crate release. Also removes all deprecated APIs.
diff --git a/Cargo.lock b/Cargo.lock index 0b35c98..50d5998 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,7 +64,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "crypto-bigint" -version = "0.4.9" +version = "0.5.0-pre" dependencies = [ "bincode", "der", di...
6
2
45
2c0ae83192e8100f34b612b10efb2576bf0f40c7
Bogdan Opanchuk
2022-12-06T18:45:18
Zeroes for residues (#139) - Add DynResidue::zero() - Add Residue::ZERO, and implement ConstantTimeEq, Default, and Zero for Residue
diff --git a/src/uint/modular/constant_mod.rs b/src/uint/modular/constant_mod.rs index 877ccc3..fa6bf2d 100644 --- a/src/uint/modular/constant_mod.rs +++ b/src/uint/modular/constant_mod.rs @@ -1,8 +1,8 @@ use core::marker::PhantomData; -use subtle::{Choice, ConditionallySelectable}; +use subtle::{Choice, Conditional...
2
32
2
6f30b6133f48014ebaf6910aa28f20ea35754ea0
Tony Arcieri
2022-11-22T15:42:26
Add `clippy::mod_module_files` lint (#136) Lints against using the 2015 module style. Fixes one lingering instance of this style.
diff --git a/src/lib.rs b/src/lib.rs index 8f8ecd3..86ac4fa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,7 @@ )] #![deny(unsafe_code)] #![warn( + clippy::mod_module_files, clippy::unwrap_used, missing_docs, missing_debug_implementations, diff --git a/src/uint/modular/runtime_mod/mod.rs b/src...
2
1
0
895f20da17f4d34d2580bb218eb8876fd6b34dbc
Tony Arcieri
2022-11-22T15:24:37
Use 2018 module style (#135) It's the standard style used by the @RustCrypto project.
diff --git a/src/uint/modular/mod.rs b/src/uint/modular.rs similarity index 100% rename from src/uint/modular/mod.rs rename to src/uint/modular.rs diff --git a/src/uint/modular/constant_mod/mod.rs b/src/uint/modular/constant_mod.rs similarity index 100% rename from src/uint/modular/constant_mod/mod.rs rename to src/uin...
2
0
0
70528617a37e4c6a5e54b0a4fd470f00d94073fa
Jelle Vos
2022-11-21T22:20:24
Runtime moduli (#134) Extends #130 by adding residues for moduli decided at run-time.
diff --git a/src/lib.rs b/src/lib.rs index 855ea9b..8f8ecd3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -109,7 +109,8 @@ //! assert_eq!(b, U256::ZERO); //! ``` //! -//! It also supports modular arithmetic over constant moduli using `Residue`. +//! It also supports modular arithmetic over constant moduli using `Resid...
15
328
50
f1a2829c134e41ce77d631c9d37307f4e6b462de
Andrew Whitehead
2022-10-10T17:55:06
Add bit accessor methods (#122) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/uint/bits.rs b/src/uint/bits.rs index e1b4873..b76d89f 100644 --- a/src/uint/bits.rs +++ b/src/uint/bits.rs @@ -1,9 +1,27 @@ use crate::{Limb, UInt, Word}; impl<const LIMBS: usize> UInt<LIMBS> { + /// Get the value of the bit at position `index`, as a 0- or 1-valued Word. + /// Returns 0 for ...
4
39
6
641312a9e51eef9b76cd2029ee282c7c3bff9840
Andrew Whitehead
2022-10-10T17:40:42
add resize method for UInt (#129) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/uint.rs b/src/uint.rs index 566e2a4..5aac67c 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -26,6 +26,7 @@ mod inv_mod; mod mul; mod mul_mod; mod neg_mod; +mod resize; mod shl; mod shr; mod sqrt; diff --git a/src/uint/resize.rs b/src/uint/resize.rs new file mode 100644 index 0000000..5a5ec7e --- /...
2
38
0
704e3816aeb2af4f8886371b62856943943fa5f5
Andrew Whitehead
2022-10-07T14:54:18
faster comparisons (#128) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/uint/cmp.rs b/src/uint/cmp.rs index 393b46d..19046df 100644 --- a/src/uint/cmp.rs +++ b/src/uint/cmp.rs @@ -3,7 +3,7 @@ //! By default these are all constant-time and use the `subtle` crate. use super::UInt; -use crate::{Limb, SignedWord, WideSignedWord, Word, Zero}; +use crate::{limb::HI_BIT, Limb...
1
22
11
9a62517df17960d4f77965411098f8d3623d58b4
Andrew Whitehead
2022-10-05T23:49:12
optimize neg_mod (#127) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/uint/neg_mod.rs b/src/uint/neg_mod.rs index d5d948d..0a1dc03 100644 --- a/src/uint/neg_mod.rs +++ b/src/uint/neg_mod.rs @@ -4,8 +4,18 @@ use crate::{Limb, NegMod, UInt}; impl<const LIMBS: usize> UInt<LIMBS> { /// Computes `-a mod p` in constant time. + /// Assumes `self` is in `[0, p)`. ...
1
11
1
2d0f41584890b8d097299da88887bbbdfb4ff2ad
Andrew Whitehead
2022-08-25T23:07:08
fix ct_select documentation (#118) Signed-off-by: Andrew Whitehead <cywolf@gmail.com> Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/limb.rs b/src/limb.rs index e31f91b..df3ae7a 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -121,7 +121,7 @@ impl Limb { #[cfg(target_pointer_width = "64")] pub const BYTE_SIZE: usize = 8; - /// Return `a` if `c`!=0 or `b` if `c`==0. + /// Return `a` if `c`==0 or `b` if `c`==`Word::MAX...
2
2
2
4b783057952b984c4a6bce6a67f6edd84cec87f8
Andrew Whitehead
2022-08-25T20:50:06
add a public LIMBS constant to UInt (#114) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/uint.rs b/src/uint.rs index db611cd..566e2a4 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -78,6 +78,9 @@ impl<const LIMBS: usize> UInt<LIMBS> { /// The value `1`. pub const ONE: Self = Self::from_u8(1); + /// The number of limbs used on this platform. + pub const LIMBS: usize = LIMBS...
1
3
0
da733d59f8096360246cf4ada10918c07cc43dd6
Andrew Whitehead
2022-08-25T20:49:08
faster const decoding of UInt (#113) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/uint.rs b/src/uint.rs index c70c8d5..db611cd 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -307,12 +307,14 @@ macro_rules! impl_uint_aliases { type Repr = [u8; $bits / 8]; + #[inline] fn from_be_bytes(bytes: Self::Repr) -> Self { - ...
3
49
159
377c8b3a88742201787bc78ac138f1f6e79f9ef9
Andrew Whitehead
2022-08-25T20:47:35
Fix constant-time behaviour for ct_reduce/ct_div_rem (#117) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/uint/div.rs b/src/uint/div.rs index 80683db..6b766ae 100644 --- a/src/uint/div.rs +++ b/src/uint/div.rs @@ -1,7 +1,7 @@ //! [`UInt`] division operations. use super::UInt; -use crate::limb::{SignedWord, Word, HI_BIT}; +use crate::limb::Word; use crate::{Integer, Limb, NonZero, Wrapping}; use core:...
1
25
35
ed8d96be88ea4e1a970f5fcc3ce5cae85113addb
Andrew Whitehead
2022-08-23T22:53:14
Add left, right bitshift for Limb (#112) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/limb.rs b/src/limb.rs index 5976fda..e31f91b 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -13,6 +13,8 @@ mod cmp; mod encoding; mod from; mod mul; +mod shl; +mod shr; mod sub; #[cfg(feature = "rand_core")] diff --git a/src/limb/shl.rs b/src/limb/shl.rs new file mode 100644 index 0000000..c0003d...
4
152
4
723791d8b7c43b0905aba2cb235b37356e0270f4
Tony Arcieri
2022-08-16T23:45:22
crypto-bigint: `const fn` impls of `concat` and `split` (#111)
diff --git a/src/traits.rs b/src/traits.rs index dc09e4d..b89c70a 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -186,8 +186,8 @@ pub trait Concat<Rhs = Self> { /// Concatenated output: twice the width of `Self`. type Output; - /// Concate the two values, with `self` as most significant and `rhs` as -...
7
170
117
6f6245992ce9e2f1cdcedb75bf9c0c8e35fda3ad
Andrew Whitehead
2022-08-15T00:21:01
add non-const UInt decoding from an array (#110) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/uint/encoding.rs b/src/uint/encoding.rs index 710d056..66d04be 100644 --- a/src/uint/encoding.rs +++ b/src/uint/encoding.rs @@ -154,8 +154,45 @@ const fn decode_hex_byte(bytes: [u8; 2]) -> u8 { result } +/// Create a new [`UInt`] from the provided big endian byte array. +pub(crate) fn uint_from...
2
81
6
f28cef1ef53a1e711998891faf273b033ac528b7
haslersn
2022-08-15T00:19:13
uint: Implement modulo operations for special moduli (#108) Implement modulo operations (`neg`, `add`, `sub`, `mul`) for special moduli that are so close to `MAX` that the difference to overflow fits in a single `Limb`. For such moduli, these new implementations are much faster than the existing generic modulus im...
diff --git a/src/uint.rs b/src/uint.rs index 4620bc2..69c3398 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -22,6 +22,7 @@ mod encoding; mod from; mod inv_mod; mod mul; +mod mul_mod; mod neg_mod; mod shl; mod shr; diff --git a/src/uint/add_mod.rs b/src/uint/add_mod.rs index 7a81ab9..3486a0a 100644 --- a/src/uint/...
5
286
4
3d1461231a1aac8736027751c80948d4264ad5f9
haslersn
2022-08-08T14:19:13
limb: always inline bitand (#109) Previously, rustc didn't inline `Limb::bitand` inside functions such as `UInt::add_mod` and `UInt::sub_mod`, when calling them from a different crate. This is probably because non-generic functions without `inline` attribute don't get inlined across crates (unless using link-time ...
diff --git a/src/limb/bit_and.rs b/src/limb/bit_and.rs index ff153b2..3f0bfba 100644 --- a/src/limb/bit_and.rs +++ b/src/limb/bit_and.rs @@ -5,6 +5,7 @@ use core::ops::BitAnd; impl Limb { /// Calculates `a & b`. + #[inline(always)] pub const fn bitand(self, rhs: Self) -> Self { Limb(self.0 & rh...
1
2
0
d10ef192b9d80b1c2ad467d99a3aa907b6021b6a
haslersn
2022-07-30T21:17:28
uint: Relax bounds for UInt::add_mod and UInt::sub_mod (#104) In some applications involving modulo arithmetic, there are occasions where one knows that a certain number `x` that needs to be reduced is not much larger than the modulus `p`. In particular, if one knows `x < 2p`, one can simply reduce it by calling `...
diff --git a/src/uint/add_mod.rs b/src/uint/add_mod.rs index 8ede1bd..7a81ab9 100644 --- a/src/uint/add_mod.rs +++ b/src/uint/add_mod.rs @@ -5,7 +5,7 @@ use crate::{AddMod, Limb, UInt}; impl<const LIMBS: usize> UInt<LIMBS> { /// Computes `self + rhs mod p` in constant time. /// - /// Assumes `self` and `r...
2
2
2
26a7c66058795c3ce936c44fdfea5e400cee5dd8
haslersn
2022-07-30T21:16:16
uint: Optimize neg_mod by simply calling sub_mod (#106) The new implementation uses 2 instead of 3 iterations over the limbs.
diff --git a/src/uint/neg_mod.rs b/src/uint/neg_mod.rs index 3925b31..64c8c18 100644 --- a/src/uint/neg_mod.rs +++ b/src/uint/neg_mod.rs @@ -1,53 +1,11 @@ //! [`UInt`] subtraction modulus operations. -use crate::{Limb, NegMod, UInt}; +use crate::{NegMod, UInt}; impl<const LIMBS: usize> UInt<LIMBS> { /// Comp...
1
35
44
d6da7af97d49c34782be98f4d4ac6c27bb95ef72
haslersn
2022-07-30T21:05:29
uint: Implement from_word and from_wide_word (#105) This is useful for clients who write generic code targeting both 32-bit and 64-bit.
diff --git a/src/uint/from.rs b/src/uint/from.rs index 6f2f1f5..8311b30 100644 --- a/src/uint/from.rs +++ b/src/uint/from.rs @@ -1,6 +1,6 @@ //! `From`-like conversions for [`UInt`]. -use crate::{Limb, Split, UInt, Word, U128, U64}; +use crate::{Limb, Split, UInt, WideWord, Word, U128, U64}; impl<const LIMBS: usi...
1
20
1
fea5f50c3f73c8b7f95f0ce12a8f78f70316646a
Tony Arcieri
2022-06-30T17:12:01
Rename `LimbUInt` => `Word`, `WideLimbUInt` => `WideWord` (#88) Also internally renames (Wide)`LimbUInt` => (Wide)`SignedWord`. These names are slightly less unwieldy. The previous names are still retained but with a `#[deprecated]` attribute, to be removed in the next breaking release (i.e. v0.5).
diff --git a/src/lib.rs b/src/lib.rs index bfe82c4..25673a1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -154,7 +154,7 @@ mod wrapping; pub use crate::{ checked::Checked, - limb::{Limb, LimbUInt, WideLimbUInt}, + limb::{Limb, WideWord, Word}, non_zero::NonZero, traits::*, uint::*, @@ -162,7 ...
16
195
162
9ee18aaf66d83bd0c4b607db2b8f31766de9561a
daxpedda
2022-06-13T02:13:23
Add `Encoding` tests (#93)
diff --git a/src/limb/encoding.rs b/src/limb/encoding.rs index 9d0f6cc..62bfed1 100644 --- a/src/limb/encoding.rs +++ b/src/limb/encoding.rs @@ -32,3 +32,36 @@ impl Encoding for Limb { self.0.to_le_bytes() } } + +#[cfg(test)] +mod test { + use super::*; + use proptest::prelude::*; + + prop_compo...
2
50
0
578cff215759fce1f8dfe3447ad7bff4538c2161
Tony Arcieri
2022-06-13T02:12:00
Use const generic impls of `*Mod` traits (#98) The core implementations of these traits are already const generic, so there's no reason the trait impls shouldn't also be.
diff --git a/src/uint/add_mod.rs b/src/uint/add_mod.rs index 2babff7..8ede1bd 100644 --- a/src/uint/add_mod.rs +++ b/src/uint/add_mod.rs @@ -32,24 +32,16 @@ impl<const LIMBS: usize> UInt<LIMBS> { } } -macro_rules! impl_add_mod { - ($($size:expr),+) => { - $( - impl AddMod for UInt<$size> { ...
3
21
45
f4fa23de2b0064a5365c23f3dd872c2de072f823
Tony Arcieri
2022-06-12T22:41:21
Impl `ArrayEncoding` for `U576` (#96)
diff --git a/src/uint/array.rs b/src/uint/array.rs index 3cb45a4..cba2b37 100644 --- a/src/uint/array.rs +++ b/src/uint/array.rs @@ -61,6 +61,7 @@ impl_uint_array_encoding! { (U384, typenum::U48), (U448, typenum::U56), (U512, typenum::U64), + (U576, typenum::U72), (U768, typenum::U96), (U896...
1
1
0
0307d22a381d2b5f28cdee18de44e0f7671d6b8d
Tony Arcieri
2022-06-12T21:32:24
Add `U576` type alias (#94) Useful for RustCrypto/elliptic-curves#600 as well as `p521`.
diff --git a/src/uint.rs b/src/uint.rs index fb10752..7d1f9a0 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -243,6 +243,7 @@ impl_uint_aliases! { (U384, 384, "384-bit"), (U448, 448, "448-bit"), (U512, 512, "512-bit"), + (U576, 576, "576-bit"), (U768, 768, "768-bit"), (U896, 896, "896-bit"), ...
2
2
1
64b8f842ed46310a66da0e4eea3798e1b43ad702
Tony Arcieri
2022-06-02T22:59:11
crypto-bigint: add `UInt::as_uint_array` (#91) Adds a `const fn` for borrowing the limbs of a `UInt` as a reference to an array of word-sized integers (i.e. `LimbUInt`). The intended use case is passing this array as an argument to `const fn` fiat-crypto functions.
diff --git a/src/uint.rs b/src/uint.rs index 04e7020..3b6b0c8 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -36,7 +36,7 @@ mod array; mod rand; use crate::{Concat, Encoding, Integer, Limb, LimbUInt, Split, Zero}; -use core::fmt; +use core::{fmt, mem}; use subtle::{Choice, ConditionallySelectable}; #[cfg(feature...
1
12
6
3977d4d216cd98b4b644dea5b8d1fcbed4fefe54
Tony Arcieri
2022-05-31T14:28:57
Impl `AsRef`/`AsMut<[LimbUInt]>` for `UInt` (#89) Provides direct reference-based access to the inner limb array within `UInt` as a reference to an array of `u32`/`u64` integers (depending on the target word size). Uses an `unsafe` pointer cast between `Limb` and its integer type, however since `Limb` is a `repr...
diff --git a/src/lib.rs b/src/lib.rs index ddd608b..bfe82c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,7 @@ html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg" )] -#![forbid(unsafe...
3
34
11
69fa45dcc7179c3fbe5ef5dcf8d66fda73750240
Michael Lodder
2022-05-18T13:54:26
add inv_mod2k (#86) Signed-off-by: Michael Lodder <redmike7@gmail.com>
diff --git a/src/uint.rs b/src/uint.rs index cd312ec..afb3481 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -20,6 +20,7 @@ mod cmp; mod div; mod encoding; mod from; +mod inv_mod; mod mul; mod neg_mod; mod shl; diff --git a/src/uint/div.rs b/src/uint/div.rs index 6044fe3..40f123c 100644 --- a/src/uint/div.rs +++ b...
3
109
6
9af20ba34e1842e82cbd7e743ee958bcd232b88d
Michael Lodder
2022-05-17T19:34:18
address issue #84 (#85) Signed-off-by: Michael Lodder <redmike7@gmail.com>
diff --git a/src/uint/div.rs b/src/uint/div.rs index 6223651..6044fe3 100644 --- a/src/uint/div.rs +++ b/src/uint/div.rs @@ -42,11 +42,11 @@ impl<const LIMBS: usize> UInt<LIMBS> { e = e.shr_vartime(1); } // If `self`<rhs - // set quo and rem to Self::ZERO + // set quo to zer...
1
18
13
59bdab1079d29419521a7cd6fa2e79790ccf5cf1
PopcornPaws
2022-05-10T15:14:39
Fix endianness typo. (#82)
diff --git a/src/uint.rs b/src/uint.rs index 41ce3f1..cd312ec 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -234,7 +234,7 @@ impl_split! { #[cfg(test)] mod tests { - use crate::{Concat, Split, U128, U64}; + use crate::{Concat, Encoding, Split, U128, U64}; use subtle::ConditionallySelectable; #[tes...
2
18
2
506f2b8b36faddf53da136bd3e962e295d0ff207
Tony Arcieri
2022-05-08T17:43:00
Bump `der` crate dependency to v0.6 (#80)
diff --git a/Cargo.lock b/Cargo.lock index dfe8125..7aab6e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,7 +49,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "crypto-bigint" -version = "0.4.0-pre.0" +version = "0.4.0-pre.1" dependencies = [ "der", "gene...
2
4
4
ca272bd8bcc4afa80adaa42186186d15b5e7fed8
Tony Arcieri
2022-05-07T15:57:46
v0.4.0-pre.1 (#79)
diff --git a/Cargo.toml b/Cargo.toml index 1f867cd..e2c2aca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crypto-bigint" -version = "0.4.0-pre.0" # Also update html_root_url in lib.rs when bumping this +version = "0.4.0-pre.1" # Also update html_root_url in lib.rs when bumping this descr...
1
1
1
ef7d22da949628079fd1c0c8c8e7636b83720d60
Tony Arcieri
2022-05-07T15:03:22
Bump `der` dependency to v0.6.0-pre.4 (#78) Also adds a `DecodeValue` impl for `UInt`
diff --git a/Cargo.lock b/Cargo.lock index a8d385a..dfe8125 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,9 +66,9 @@ dependencies = [ [[package]] name = "der" -version = "0.6.0-pre.3" +version = "0.6.0-pre.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3ed717eef39a802bcfbfefed2...
3
23
17
a683f95e99a1546e95547934ee65fb0cf301eb35
PopcornPaws
2022-04-28T19:10:09
Pad limbs with zeros when displaying hexadecimal representation. (#74) * Pad hexadecimal limb display with zeros. * Uncomment flag.
diff --git a/src/limb.rs b/src/limb.rs index 576cc21..88cabc6 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -132,14 +132,14 @@ impl fmt::Display for Limb { impl fmt::LowerHex for Limb { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::LowerHex::fmt(&self.0, f) + write...
2
14
2
acfc6e3263af0ac08c5f57e139f777a85af9ad93
Tony Arcieri
2022-01-18T15:18:33
v0.4.0-pre.0 (#63)
diff --git a/Cargo.lock b/Cargo.lock index c764e60..bcb3a4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,7 +49,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "crypto-bigint" -version = "0.4.0-pre" +version = "0.4.0-pre.0" dependencies = [ "der", "generi...
2
2
2
bb610c7baba5285abadd4614177c81f1b04de376
Tony Arcieri
2022-01-18T15:02:30
Bump `der` dependency to v0.6.0-pre.0 (#62)
diff --git a/Cargo.lock b/Cargo.lock index 7eacef5..c764e60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,8 +66,9 @@ dependencies = [ [[package]] name = "der" -version = "0.6.0-pre" -source = "git+https://github.com/RustCrypto/formats.git#86f682491d0534126f70fdc9f5312e483323f862" +version = "0.6.0-pre.0" +source ...
2
4
6
b113ba0b046959d36ff4c5d3bd4110666014f2f7
daxpedda
2022-01-06T19:26:38
Implement const-friendly `NonZero` from `UInt` (#56)
diff --git a/src/non_zero.rs b/src/non_zero.rs index 1fa0036..740bc83 100644 --- a/src/non_zero.rs +++ b/src/non_zero.rs @@ -232,6 +232,20 @@ impl From<NonZeroU64> for NonZero<Limb> { } impl<const LIMBS: usize> NonZero<UInt<LIMBS>> { + /// Create a [`NonZero<UInt>`] from a [`UInt`] (const-friendly) + pub cons...
1
14
0
0bd4413ab39b9027b69cbd326fb0508996fd466e
Tony Arcieri
2021-11-17T20:47:31
Add `Output = Self` to all bitwise ops on `Integer` trait (#53)
diff --git a/src/traits.rs b/src/traits.rs index a12734a..dc09e4d 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -15,9 +15,9 @@ use rand_core::{CryptoRng, RngCore}; pub trait Integer: 'static + AsRef<[Limb]> - + BitAnd - + BitOr - + BitXor + + BitAnd<Output = Self> + + BitOr<Output = Self> ...
1
5
5
2fca3e1552250d59f2d7ba2a1251069a2059a444
Tony Arcieri
2021-11-17T20:02:47
Add bitwise ops to `Integer` trait (#51) Adds the following bitwise operations: - `BitAnd` - `BitOr` - `BitXor` - `Shl` - `Shr` Additionally adds impls of the `Bit*` traits on `UInt<LIMBS>` directly, in addition to the existing impls on `Wrapping<UInt<LIMBS>>`. This is safe because there is no difference...
diff --git a/src/traits.rs b/src/traits.rs index d44cc29..a12734a 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -2,7 +2,7 @@ use crate::{Limb, NonZero}; use core::fmt::Debug; -use core::ops::{Div, Rem}; +use core::ops::{BitAnd, BitOr, BitXor, Div, Not, Rem, Shl, Shr}; use subtle::{ Choice, ConditionallySe...
5
158
7
fb78602f1afe74b68d7ebbb6bce1424fac763e3e
Tony Arcieri
2021-11-14T18:56:37
v0.3.0-pre.1 (#48)
diff --git a/Cargo.lock b/Cargo.lock index 88f7a9a..e969540 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,7 +49,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "crypto-bigint" -version = "0.3.0-pre" +version = "0.3.0-pre.1" dependencies = [ "generic-array",...
6
3
6
50e19ae8a6b0bef0ed3ed4297164959e5c25848c
Tony Arcieri
2021-11-14T18:50:06
Add `saturating_*` ops (#47) Adds the following saturating arithmetic operations to `UInt`: - `saturating_add` - `saturating_sub` - `saturating_mul`
diff --git a/src/limb/add.rs b/src/limb/add.rs index f5c72c6..3da83f6 100644 --- a/src/limb/add.rs +++ b/src/limb/add.rs @@ -20,7 +20,7 @@ impl Limb { /// Perform saturating addition. #[inline] - pub fn saturating_add(&self, rhs: Self) -> Self { + pub const fn saturating_add(&self, rhs: Self) -> Self ...
6
62
2
e1df409dede845163b3b4fb4d304517ef3a02358
Tony Arcieri
2021-11-14T18:10:37
Reduce number of inherent methods (#46) Uses traits consistently for `is_zero`, `is_odd`, and `is_even`
diff --git a/src/limb/add.rs b/src/limb/add.rs index 9ef698b..f5c72c6 100644 --- a/src/limb/add.rs +++ b/src/limb/add.rs @@ -1,6 +1,6 @@ //! Limb addition -use crate::{Checked, CheckedAdd, Limb, LimbUInt, WideLimbUInt, Wrapping}; +use crate::{Checked, CheckedAdd, Limb, LimbUInt, WideLimbUInt, Wrapping, Zero}; use c...
10
27
37
8f17162f80126047e61a72ad65fca43970508f92
Tony Arcieri
2021-11-14T18:02:04
Add `prelude` module (#45) Makes it simple to import traits used by this crate
diff --git a/src/lib.rs b/src/lib.rs index 92c56f1..a9d1a1e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -167,7 +167,7 @@ pub(crate) use limb::{LimbInt, WideLimbInt}; #[cfg(feature = "generic-array")] pub use { - self::array::{ArrayDecoding, ArrayEncoding, ByteArray}, + crate::array::{ArrayDecoding, ArrayEncod...
1
9
1
500bc97aae4b878875ccd143b5b90c8b31b62a3d
Tony Arcieri
2021-11-14T14:29:55
Remove deprecated `LIMB_BYTES` constant (#43) The replacement is: `Limb::BYTE_SIZE`
diff --git a/src/lib.rs b/src/lib.rs index 9ad37c8..a3fa709 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,13 +81,3 @@ pub use rlp; #[cfg(feature = "zeroize")] pub use zeroize; - -/// Number of bytes in a [`Limb`]. -#[cfg(target_pointer_width = "32")] -#[deprecated(since = "0.2.2", note = "use `Limb::BYTE_SIZE` in...
1
0
10
b0ec66f24af3129f0a139950fbff78b35449bd3e
Tony Arcieri
2021-11-14T14:16:09
Expand rustc lints (#42) Adds a number of additional lints as a `#![warn(...)]` directive, including `trivial_numeric_casts`, which caught a number of redundancies.
diff --git a/src/lib.rs b/src/lib.rs index 1c14427..9ad37c8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,15 @@ html_root_url = "https://docs.rs/crypto-bigint/0.3.0-pre" )] #![forbid(unsafe_code, clippy::unwrap_used)] -#![warn(missing_docs, rust_2018_idioms, unused_qualifications)] +#![warn( + missing...
8
18
7
95d15c22e1fdb51bf738f78ebd6e8c3c86b72f8c
Tony Arcieri
2021-11-14T02:26:09
`Checked*` traits (#41) Adds the following traits: - `CheckedAdd` - `CheckedSub` - `CheckedMul` Also changes the existing inherent methods to use the traits.
diff --git a/src/limb/add.rs b/src/limb/add.rs index 3d39032..9ef698b 100644 --- a/src/limb/add.rs +++ b/src/limb/add.rs @@ -1,7 +1,6 @@ //! Limb addition -use super::{Limb, LimbUInt, WideLimbUInt}; -use crate::{Checked, Wrapping}; +use crate::{Checked, CheckedAdd, Limb, LimbUInt, WideLimbUInt, Wrapping}; use core:...
11
111
81
ef7c780b024b47658cfcd942e59f4a36d4827796
Tony Arcieri
2021-11-14T00:57:41
Make `limb` module private; rename `limb::Inner` to `LimbUInt` (#40) Also promotes `limb::BIT_SIZE` and `limb::BYTE_SIZE` to inherent constants of the `Limb` type.
diff --git a/src/lib.rs b/src/lib.rs index 86c204e..1c14427 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,17 +44,24 @@ mod macros; #[cfg(feature = "generic-array")] mod array; mod checked; -pub mod limb; +mod limb; mod non_zero; mod traits; mod uint; mod wrapping; pub use crate::{ - checked::Checked, lim...
20
177
168
2051a63fe1f78949eb32da28d2fd4103db884501
Tony Arcieri
2021-11-14T00:12:36
Have `Div` and `Rem` impls always take `NonZero` args (#39) This prevents a potential panic condition if the `rhs` operand is zero by making it unrepresentable using the type system.
diff --git a/src/uint/div.rs b/src/uint/div.rs index 7ce2f17..5453638 100644 --- a/src/uint/div.rs +++ b/src/uint/div.rs @@ -195,46 +195,46 @@ where } } -impl<const LIMBS: usize> Div<&Wrapping<UInt<LIMBS>>> for &Wrapping<UInt<LIMBS>> { +impl<const LIMBS: usize> Div<NonZero<UInt<LIMBS>>> for Wrapping<UInt<LIMBS>...
1
35
35
5a9ead3a1d75bbf2a44465f13cfbcd57786d13eb
Tony Arcieri
2021-11-13T23:40:34
`Checked` improvements (#38) - Factor all `Checked` arithmetic into respective modules - `Checked` support for `Limb` - `Checked` support for reference types
diff --git a/src/checked.rs b/src/checked.rs index 951b6cb..5e00c45 100644 --- a/src/checked.rs +++ b/src/checked.rs @@ -1,7 +1,6 @@ //! Checked arithmetic. -use crate::UInt; -use core::ops::{Add, AddAssign, Deref, Mul, MulAssign, Sub, SubAssign}; +use core::ops::Deref; use subtle::{Choice, ConditionallySelectable,...
7
340
41
2ead332084135789771c4ccbc72463f3c705eca5
Tony Arcieri
2021-11-13T22:55:49
Impl `Zero` for `Wrapping` (#37) ...when the inner type impls `Zero`
diff --git a/src/wrapping.rs b/src/wrapping.rs index 9bfc871..f2a21aa 100644 --- a/src/wrapping.rs +++ b/src/wrapping.rs @@ -1,5 +1,6 @@ //! Wrapping arithmetic. +use crate::Zero; use core::fmt; use subtle::{Choice, ConditionallySelectable, ConstantTimeEq}; @@ -10,6 +11,10 @@ use subtle::{Choice, ConditionallySe...
1
5
0
ae5bedfbb909f913039508c88e6e2d7f2fb7993f
Tony Arcieri
2021-11-13T22:28:04
Fix `random_mod` performance for small moduli; `NonZero` moduli (#36) Changes the modulus for `random_mod` to be `NonZero`. Changes the algorithm used by `random_mod` to generate a number that can be represented by the same number of bytes as the modulus. Such a number can still be larger than the modulus, but ...
diff --git a/src/limb.rs b/src/limb.rs index f7cf860..fe763ff 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -8,6 +8,7 @@ mod bit_and; mod bit_not; mod bit_or; mod bit_xor; +mod bits; mod cmp; mod encoding; mod from; @@ -99,6 +100,12 @@ impl Limb { /// Maximum value this [`Limb`] can express. pub const M...
10
141
41
25fef4ee023a9d79b871a09b81f15dcecdc4a7f2
Tony Arcieri
2021-11-13T21:04:06
`Zero` trait (#35) Extracts a `Zero` trait from the `Integer` trait which contains only the associated `ZERO` constant and the `is_zero` method with a default implementation. Changes the mandatory bound for `NonZero` to be the `Zero` trait rather than the much more restrictive `Integer` This makes it possible...
diff --git a/src/limb.rs b/src/limb.rs index f61f363..f7cf860 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -17,6 +17,7 @@ mod sub; #[cfg(feature = "rand")] mod rand; +use crate::Zero; use core::fmt; use subtle::{Choice, ConditionallySelectable}; @@ -114,6 +115,10 @@ impl ConditionallySelectable for Limb { ...
4
154
106
333ac76d0a32b6f61d38f02c0870afa2e41ea26f
Tony Arcieri
2021-11-13T18:46:21
Reverse ordering of `UInt::mul_wide` return tuple (#34) Fixes the inconsistency between `UInt::mul_wide` and `Limb::mul_wide` by reversing the order of the `UInt` version so it returns `(lo, hi)`. This follows the "little endian" approach used in the rest of this crate for consistency. Closes #4
diff --git a/src/uint/mul.rs b/src/uint/mul.rs index 7113bdf..eb34781 100644 --- a/src/uint/mul.rs +++ b/src/uint/mul.rs @@ -7,6 +7,16 @@ use subtle::CtOption; impl<const LIMBS: usize> UInt<LIMBS> { /// Compute "wide" multiplication, with a product twice the size of the input. + /// + /// Returns a tuple ...
1
16
6
b215b299f86c9ef2254dd94f5348fe271c6bba86
Kert
2021-10-17T03:07:20
Add bitwise xor and not (#27)
diff --git a/src/limb.rs b/src/limb.rs index 4f37a53..f61f363 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -5,7 +5,9 @@ mod add; mod bit_and; +mod bit_not; mod bit_or; +mod bit_xor; mod cmp; mod encoding; mod from; diff --git a/src/limb/bit_not.rs b/src/limb/bit_not.rs new file mode 100644 index 0000000..26676...
9
191
2
f9aca89006cf0600089acd4bcb1fd51c5a703a68
James Peraire
2021-10-16T14:16:55
feat: Bitwise And/Or operations (#25) Co-authored-by: James Peraire <jamesperairebueno@gmail.com>
diff --git a/src/uint.rs b/src/uint.rs index fdc65f5..a975ac5 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -11,12 +11,14 @@ mod macros; mod add; mod add_mod; +mod and; mod cmp; mod div; mod encoding; mod from; mod mul; mod neg_mod; +mod or; mod shl; mod shr; mod sqrt; diff --git a/src/uint/and.rs b/src/ui...
4
223
0
a848cbee81d1d5ba0f11a878823f4c18371bc686
NoCtrlZ
2021-10-15T13:11:15
add add_mod proptests and change mod operation (#24)
diff --git a/tests/proptests.rs b/tests/proptests.rs index e1b4ad9..62c2d7d 100644 --- a/tests/proptests.rs +++ b/tests/proptests.rs @@ -30,8 +30,7 @@ prop_compose! { } prop_compose! { fn uint_mod_p(p: U256)(a in uint()) -> U256 { - // TODO: replace with mod operation on U256 - to_uint(to_biguint(&...
1
18
3
66795aed2bf33dce565cb51e6169c66cf39010f0
daxpedda
2021-09-21T17:38:02
Add traits to `ArrayDecoding` (#18)
diff --git a/src/array.rs b/src/array.rs index 424b439..ea4f437 100644 --- a/src/array.rs +++ b/src/array.rs @@ -31,7 +31,7 @@ pub trait ArrayEncoding: Encoding { #[cfg_attr(docsrs, doc(cfg(feature = "generic-array")))] pub trait ArrayDecoding { /// Big integer which decodes a `GenericArray`. - type Output: I...
2
5
2
abc670c78681f06ea84b1c21e82c7edc28575983
daxpedda
2021-09-21T17:17:34
Add conversion `core::num::NonZeroUx` (#16) * Add conversion `core::num::NonZeroUx` * Implement `From` `NonZeroX` for `NonZero`
diff --git a/src/non_zero.rs b/src/non_zero.rs index b32df66..ace62d2 100644 --- a/src/non_zero.rs +++ b/src/non_zero.rs @@ -2,8 +2,12 @@ #[cfg(feature = "rand")] use crate::Random; -use crate::{Encoding, Integer}; -use core::{fmt, ops::Deref}; +use crate::{Encoding, Integer, UInt}; +use core::{ + fmt, + num:...
1
86
2
43cda02f0a5aa3caef5e17cb9b58c8df79c079e0
daxpedda
2021-09-21T14:33:02
Rename `into_bigint_x` to `into_uint_x` (#15)
diff --git a/src/array.rs b/src/array.rs index 0c11d3b..424b439 100644 --- a/src/array.rs +++ b/src/array.rs @@ -34,8 +34,8 @@ pub trait ArrayDecoding { type Output: Integer; /// Deserialize from a big-endian `GenericArray`. - fn into_bigint_be(self) -> Self::Output; + fn into_uint_be(self) -> Self::O...
2
12
12
d37468d38f7c20463be000fcf263a05cc4a746fd
dAxpeDDa
2021-09-21T11:52:48
Fix copy-pasta
diff --git a/src/uint/div.rs b/src/uint/div.rs index 4647e51..754ea34 100644 --- a/src/uint/div.rs +++ b/src/uint/div.rs @@ -279,8 +279,8 @@ where type Output = UInt<LIMBS>; fn rem(self, rhs: NonZero<UInt<LIMBS>>) -> Self::Output { - let (q, _, _) = self.ct_div_rem(&rhs); - q + let (r, ...
1
4
4
13b8716c0668801e999b1b485103943a341cb7c4
dAxpeDDa
2021-09-21T10:28:10
Implement `Div` & `Rem` for `UInt` with `NonZero`
diff --git a/src/uint/div.rs b/src/uint/div.rs index dc5ce66..4647e51 100644 --- a/src/uint/div.rs +++ b/src/uint/div.rs @@ -2,7 +2,7 @@ use super::UInt; use crate::limb::{Inner, SignedInner, BIT_SIZE}; -use crate::{Limb, Wrapping}; +use crate::{Integer, Limb, NonZero, Wrapping}; use core::ops::{Div, DivAssign, Re...
1
129
1
99243aa0ca0ed63307f29bb31a5651935fc0a2dc
Tony Arcieri
2021-09-18T01:20:58
Add `NonZero` wrapper (#13) Adds a generic wrapper type for any `T` which impls `Integer`, which ensures that the inner value is non-zero.
diff --git a/src/lib.rs b/src/lib.rs index 6328280..243def5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,11 +45,14 @@ mod macros; mod array; mod checked; pub mod limb; +mod non_zero; mod traits; mod uint; mod wrapping; -pub use crate::{checked::Checked, limb::Limb, traits::*, uint::*, wrapping::Wrapping}; +p...
2
171
1
94c24cfdaa757e8d2cd3bd1ade388805a07c056e
daxpedda
2021-09-18T00:31:27
Implement `ArrayDecoding` (#12)
diff --git a/src/array.rs b/src/array.rs index 6e0c7fd..0c11d3b 100644 --- a/src/array.rs +++ b/src/array.rs @@ -1,6 +1,6 @@ //! Interop support for `generic-array` -use crate::Encoding; +use crate::{Encoding, Integer}; use core::ops::Add; use generic_array::{typenum::Unsigned, ArrayLength, GenericArray}; @@ -26...
4
64
5
ddce64c9c17c55f1919791be1318bea366285b45
Tony Arcieri
2021-09-16T21:14:37
Use `Inner::leading_zeros` to compute `UInt::bits` Replaces a while loop with a bit-counting intrinsic
diff --git a/src/uint/bits.rs b/src/uint/bits.rs index dfdc74e..b6174b2 100644 --- a/src/uint/bits.rs +++ b/src/uint/bits.rs @@ -8,15 +8,12 @@ impl<const LIMBS: usize> UInt<LIMBS> { while i > 0 && self.limbs[i].0 == 0 { i -= 1; } - let mut bits = BIT_SIZE * i; - let mut limb...
1
4
7
11e2bdf04a6dd6168ee94601bf4e1500f38b31eb
Michael Lodder
2021-09-16T21:07:20
implement sqrt (#9) Signed-off-by: Michael Lodder <redmike7@gmail.com>
diff --git a/proptests/Cargo.lock b/proptests/Cargo.lock index 2cb9a9d..75dc69f 100644 --- a/proptests/Cargo.lock +++ b/proptests/Cargo.lock @@ -43,7 +43,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "crypto-bigint" -version = "0.2.7" +version = "0.2.8" depen...
6
166
6
12358ab918a11d1021386a94fabb3f661862ccbc
Michael Lodder
2021-09-16T14:35:36
make div similar to other interfaces (#8) Signed-off-by: Michael Lodder <redmike7@gmail.com>
diff --git a/proptests/tests/equivalence.rs b/proptests/tests/equivalence.rs index 9c5474b..0a697c5 100644 --- a/proptests/tests/equivalence.rs +++ b/proptests/tests/equivalence.rs @@ -109,7 +109,7 @@ proptest! { if !b_bi.is_zero() { let expected = to_uint(a_bi / b_bi); - let actual =...
3
32
35
7a6c88163a298adc72fb40e253e8f4914924e1ff
Tony Arcieri
2021-09-14T18:57:32
Make `SignedWide` and `UInt::bits` visibility `pub(crate)` (#6) We can eventually expose these as part of the public API, but I'd like to nitpick the names first. I'd also like to immediately cut a release in order to update the repo location, so for now I'm removing these from the public API then we can add the...
diff --git a/src/limb.rs b/src/limb.rs index c3c70fb..4f37a53 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -47,7 +47,7 @@ pub type Wide = u64; /// SignedInner integer type: double the width of [`Limb`]. #[cfg(target_pointer_width = "32")] -pub type SignedWide = i64; +pub(crate) type SignedWide = i64; // // 64-...
2
3
3
a919f20e3cf6394b90e171881933caa095bd5ba9
Steven Allen
2025-12-06T16:34:54
Release 1.2.1
diff --git a/Cargo.lock b/Cargo.lock index 1d91492..2d56e41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "term" -version = "1.2.0" +version = "1.2.1" dependencies = [ "windows-sys", ] diff --git a/Cargo.toml b/Cargo.toml index 112a31b..414b2db 100644 --- a/Cargo.toml +...
2
2
2
bab644485838b44e8e3c0ab516a92dd2c6219fff
Pavel Roskin
2025-12-06T16:32:41
Fix precision in %d with the sign flag (#132)
diff --git a/src/terminfo/parm.rs b/src/terminfo/parm.rs index cc23525..1cbed71 100644 --- a/src/terminfo/parm.rs +++ b/src/terminfo/parm.rs @@ -503,10 +503,10 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8>, Error> { Number(d) => { match op { Digit => { + ...
1
12
2
4dc3940dcb4ae5c39f98af6d0d884927fc3b1595
Steven Allen
2025-09-08T20:07:15
chore: release 1.2.0
diff --git a/Cargo.lock b/Cargo.lock index c90c184..1d91492 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "term" -version = "1.1.0" +version = "1.2.0" dependencies = [ "windows-sys", ] diff --git a/Cargo.toml b/Cargo.toml index 60932a8..112a31b 100644 --- a/Cargo.toml +...
2
2
2
fb9bf9d974576641df753ed3a4284b41af94fedd
Steven Allen
2025-07-08T21:43:59
chore: release v1.1.0
diff --git a/Cargo.lock b/Cargo.lock index 2c21901..3f59d73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "term" -version = "1.0.2" +version = "1.1.0" dependencies = [ "windows-sys", ] diff --git a/Cargo.toml b/Cargo.toml index 6cd38b7..bfc2fd6 100644 --- a/Cargo.toml +...
2
2
2
9840bd32bf9f907c01f78665001ba0728a1b9bce
Steven Allen
2025-07-08T21:29:18
chore: allow windows-sys 0.59 Not all crates have updated to 0.60, so we might as well allow the previous version as well.
diff --git a/Cargo.toml b/Cargo.toml index d51cdfb..6cd38b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ edition = "2021" rust-version = "1.63" [target.'cfg(windows)'.dependencies.windows-sys] -version = "0.60.2" +version = ">=0.59, <0.61" features = [ "Win32_Storage", "Win32_Foundation",
1
1
1
d665f864c003fff14c3c3ab53d10d7a232cc32be
Steven Allen
2025-07-08T21:22:43
chore: pacify clippy lint for calling bytes on an unbuffered reader
diff --git a/src/terminfo/parser/compiled.rs b/src/terminfo/parser/compiled.rs index d84e21b..2b88a64 100644 --- a/src/terminfo/parser/compiled.rs +++ b/src/terminfo/parser/compiled.rs @@ -35,6 +35,9 @@ fn read_le_u32(r: &mut dyn io::Read) -> io::Result<u32> { } fn read_byte(r: &mut dyn io::Read) -> io::Result<u8> ...
1
3
0