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
e3fea9ca4662fe85cdeafdb86a2cf5f7ff969cf9
Tony Arcieri
2024-08-05T01:09:37
Add `Gcd::gcd_vartime` (#636) Adds a method to the `Gcd` trait for computing greatest common divisor in variable time, permitting a faster implementation.
diff --git a/Cargo.toml b/Cargo.toml index bc33daa..79c00dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ edition = "2021" rust-version = "1.73" [dependencies] -subtle = { version = "2.5", default-features = false } +subtle = { version = "2.6", default-features = false } # optional dependencies der...
4
24
10
94a825c45fc08f244bbba65f3675d8d1e22c87b8
Tony Arcieri
2024-08-05T00:10:00
Constant-time heap-allocated Bernstein-Yang (#635) The previous implementation runs in variable-time with respect to `g`. However in the event both inputs are secret a fully constant-time implementation is required. This implements Bernstein-Yang in constant-time with respect to both parameters by computing a wo...
diff --git a/src/modular/bernstein_yang.rs b/src/modular/bernstein_yang.rs index 44217bf..162d1f2 100644 --- a/src/modular/bernstein_yang.rs +++ b/src/modular/bernstein_yang.rs @@ -197,7 +197,7 @@ const fn divsteps<const LIMBS: usize>( let mut delta = 1; let mut matrix; let mut i = 0; - let m = iterat...
3
77
7
cdc848743f722e95e035596558d8d88bb7ab88d2
Tony Arcieri
2024-08-04T19:53:45
Initial constant-time stack-allocated Bernstein-Yang (#632) The previous implementation runs in variable-time with respect to `g`. However in the event both inputs are secret a fully constant-time implementation is required. This implements the method described in section 11 of https://eprint.iacr.org/2019/266.p...
diff --git a/benches/uint.rs b/benches/uint.rs index 9c5df6c..1d03fce 100644 --- a/benches/uint.rs +++ b/benches/uint.rs @@ -111,6 +111,36 @@ fn bench_division(c: &mut Criterion) { group.finish(); } +fn bench_gcd(c: &mut Criterion) { + let mut group = c.benchmark_group("greatest common divisor"); + + grou...
5
169
4
f87a2c6e224167cce22edbac47d037e3df78114d
Tony Arcieri
2024-08-04T01:07:34
Bernstein-Yang: have `BoxedInt62L::{is_zero, is_one}` return `Choice` (#631) Similar change to #630, which was for `Int62L`. Addresses some data-dependent branching and use of `bool` noted in #627
diff --git a/src/modular/bernstein_yang.rs b/src/modular/bernstein_yang.rs index 3c210b7..25789a0 100644 --- a/src/modular/bernstein_yang.rs +++ b/src/modular/bernstein_yang.rs @@ -178,6 +178,7 @@ const fn divsteps<const LIMBS: usize>( let mut delta = 1; let mut matrix; + // TODO(tarcieri): run in a fixe...
2
20
16
3190fdc98d9d8cc7ae5c88cc7d95f932be5a33cc
Tony Arcieri
2024-08-04T00:53:26
Make Bernstein-Yang `Int62L::eq` return `ConstChoice` (#630) Addresses some data-dependent branching and use of `bool` noted in #627
diff --git a/src/const_choice.rs b/src/const_choice.rs index d079477..d45f6f2 100644 --- a/src/const_choice.rs +++ b/src/const_choice.rs @@ -69,6 +69,12 @@ impl ConstChoice { Self::from_u32_lsb((value | value.wrapping_neg()) >> (u32::BITS - 1)) } + /// Returns the truthy value if `value != 0`, and th...
3
26
13
dd79c547fb869b1ae701590302a7c693afbb1983
Tony Arcieri
2024-08-04T00:34:47
BoxedUint: constant-time Bernstein-Yang `is_negative` (#629) Similar to #628, changes `Int64L::is_negative` to return `Choice` rather than `bool`. This eliminates some of the branching in the implementation (#627)
diff --git a/src/modular/bernstein_yang/boxed.rs b/src/modular/bernstein_yang/boxed.rs index b72d5f9..3b1e634 100644 --- a/src/modular/bernstein_yang/boxed.rs +++ b/src/modular/bernstein_yang/boxed.rs @@ -6,8 +6,8 @@ use super::{inv_mod2_62, jump, Matrix}; use crate::{BoxedUint, Inverter, Limb, Odd, Word}; use alloc...
1
68
52
b1403a5f96d8312f4796bbfe5b28b2b2ed3c64e1
Tony Arcieri
2024-08-02T23:30:25
Uint: constant-time Bernstein-Yang `is_negative` (#628) Changes `Int64L::is_negative` to return `ConstChoice` rather than `bool`, also adding a `Int64L::select` method for selecting between two values predicated on a `ConstChoice`. This eliminates some of the branching in the implementation (#627)
diff --git a/src/const_choice.rs b/src/const_choice.rs index eb0235a..d079477 100644 --- a/src/const_choice.rs +++ b/src/const_choice.rs @@ -21,6 +21,18 @@ impl ConstChoice { self.0 as u32 } + #[inline] + #[cfg(target_pointer_width = "32")] + pub(crate) const fn as_u64_mask(&self) -> u64 { + ...
3
106
32
c9b61241d3a51a6d199dd9f728ebf915491c8d4a
Bogdan Opanchuk
2024-08-02T22:35:06
Make `mul_rem()` primitive constant-time (#625)
diff --git a/src/non_zero.rs b/src/non_zero.rs index fe91b1e..7ffd06b 100644 --- a/src/non_zero.rs +++ b/src/non_zero.rs @@ -84,6 +84,20 @@ where } impl NonZero<Limb> { + /// Creates a new non-zero limb in a const context. + /// Panics if the value is zero. + /// + /// In future versions of Rust it shou...
5
36
12
6370b087bd5162c287145723719149d5b01e9934
Andrew Whitehead
2024-08-02T19:08:50
Faster vartime division for `BoxedUint` (#626) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/benches/boxed_uint.rs b/benches/boxed_uint.rs index 7713579..99b73e6 100644 --- a/benches/boxed_uint.rs +++ b/benches/boxed_uint.rs @@ -1,5 +1,5 @@ use criterion::{black_box, criterion_group, criterion_main, BatchSize, Criterion}; -use crypto_bigint::{BoxedUint, RandomBits}; +use crypto_bigint::{BoxedUint...
3
275
73
e948539b01765f48da5677c4b6700e7bddb6ef06
Andrew Whitehead
2024-07-31T20:16:33
Faster vartime division for `Uint` (#608) Implements faster vartime division (vartime with the divisor only) for `Uint` based on Knuth's TAOCP volume 2, as outlined at: https://janmr.com/blog/2014/04/basic-multiple-precision-long-division/ This does not address vartime division for BoxedUint or the other TODOs ...
diff --git a/benches/uint.rs b/benches/uint.rs index 0c10425..9c5df6c 100644 --- a/benches/uint.rs +++ b/benches/uint.rs @@ -18,6 +18,18 @@ fn bench_division(c: &mut Criterion) { ) }); + group.bench_function("div/rem_vartime, U256/U128, full size", |b| { + b.iter_batched( + || { + ...
3
315
59
ff7f3a58bbdf797ba007ba2eef70c8977801ef6c
Tony Arcieri
2024-07-27T19:35:53
Split `Uint::mul_mod` and `Uint::mul_mod_vartime` (#623) The previous `mul_mod` was variable-time with respect to the modulus. This adds a proper constant-time version. It also changes the `p` argument to be `NonZero<Self>`.
diff --git a/Cargo.lock b/Cargo.lock index 7b3f99f..3117135 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -210,7 +210,7 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.6.0-rc.1" +version = "0.6.0-rc.2" dependencies = [ "bincode", "...
3
30
14
1a38df0b00c5c141951e970393bdadaf38845fc5
Tony Arcieri
2024-07-26T23:32:56
v0.6.0-rc.2 (#622)
diff --git a/Cargo.toml b/Cargo.toml index f404c9f..bc33daa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crypto-bigint" -version = "0.6.0-rc.1" +version = "0.6.0-rc.2" description = """ Pure Rust implementation of a big integer library which has been designed from the ground-up for us...
1
1
1
70d04b563fb7953c1ad488c5202115f28f7ba72f
Andrew Whitehead
2024-07-26T18:58:46
Implement `from_str_radix_vartime` for `Uint`, `BoxedUint` (#603) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/lib.rs b/src/lib.rs index b4681cc..7afa680 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -189,7 +189,7 @@ pub use crate::{ pub use subtle; #[cfg(feature = "alloc")] -pub use crate::uint::boxed::{encoding::DecodeError, BoxedUint}; +pub use crate::uint::boxed::BoxedUint; #[cfg(feature = "hybrid-arra...
4
451
37
295d2224c62d7a7f30f6ecb03bed78aa366436f5
David
2024-07-26T17:26:30
Add `NonZero::new_unwrap` (#602) Co-authored-by: Tony Arcieri <bascule@gmail.com>
diff --git a/src/non_zero.rs b/src/non_zero.rs index 7ee4021..fe91b1e 100644 --- a/src/non_zero.rs +++ b/src/non_zero.rs @@ -111,6 +111,20 @@ impl NonZero<Limb> { } impl<const LIMBS: usize> NonZero<Uint<LIMBS>> { + /// Creates a new non-zero integer in a const context. + /// Panics if the value is zero. + ...
1
14
0
ee13f660c1f137be8607907c400e3dfcde88629e
David
2024-07-25T15:05:43
Implement a few more traits for `Odd` (#621) The `Odd` wrapper type does not implement the same traits as it's sibling `NonZero`. This PR attempts to rectify that and make them more similar. In particular the PR implements: - `ConstantTimeEq` - `zeroize::Zeroize` - `fmt::Display` - `fmt::Binary`, `fmt::Octa...
diff --git a/src/odd.rs b/src/odd.rs index 6a4862d..1fdd2be 100644 --- a/src/odd.rs +++ b/src/odd.rs @@ -1,8 +1,8 @@ //! Wrapper type for non-zero integers. use crate::{Integer, Limb, NonZero, Uint}; -use core::{cmp::Ordering, ops::Deref}; -use subtle::{Choice, ConditionallySelectable, CtOption}; +use core::{cmp::O...
1
62
3
be6a3abf7e65279ba0b5e4b1ce09eb0632e443f6
Tony Arcieri
2024-07-16T13:35:44
v0.6.0-rc.1 (#620)
diff --git a/Cargo.lock b/Cargo.lock index 984624d..7b3f99f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -210,7 +210,7 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.6.0-rc.0" +version = "0.6.0-rc.1" dependencies = [ "bincode", "...
2
2
2
d7b3eabe296e0424df0d1ddbd822e8e5cd8b724c
Tony Arcieri
2024-07-16T00:50:49
BoxedUint: even GCD support (#618) Uses an implementation similar to `Uint::gcd` as added in #617
diff --git a/src/traits.rs b/src/traits.rs index 1dde926..1e1f3e7 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -197,12 +197,12 @@ pub trait FixedInteger: Bounded + ConditionallySelectable + Constants + Copy + I const LIMBS: usize; } -/// Compute greatest common divisor of two integers. +/// Compute the gre...
3
48
15
001f89f36b31a547a56076498eec1714732ab9fe
Tony Arcieri
2024-07-13T15:06:36
Make `Uint::gcd` calculation infallible (#619) See also: #618 The computation was previously fallible because even values were unsupported. Now that they're supported, the computation no longer needs to be fallible. We can eventually remove `type Output` from the `Gcd` trait after a similar treatment is ap...
diff --git a/src/uint/gcd.rs b/src/uint/gcd.rs index 96783b2..e736d23 100644 --- a/src/uint/gcd.rs +++ b/src/uint/gcd.rs @@ -1,16 +1,13 @@ //! Support for computing the greatest common divisor of two `Uint`s. -use crate::{ - modular::BernsteinYangInverter, ConstChoice, ConstCtOption, Gcd, Odd, PrecomputeInverter,...
2
19
24
dbc02cbbcf27aa28502cc77439548e32d9ef6132
Tony Arcieri
2024-07-13T02:46:58
Add support for computing `Uint::gcd` with even modulus (#617) Uses a similar method to `Uint::inv_mod` for extending `Uint::gcd` with support for an even modulus, first dividing out `2^k` from both operands where this operation will ensure at least one value is odd, and then applying Bernstein-Yang to the odd modu...
diff --git a/src/uint/gcd.rs b/src/uint/gcd.rs index 0ebb1f1..96783b2 100644 --- a/src/uint/gcd.rs +++ b/src/uint/gcd.rs @@ -1,6 +1,8 @@ -//! Support for computing greatest common divisor of two `Uint`s. +//! Support for computing the greatest common divisor of two `Uint`s. -use crate::{modular::BernsteinYangInverter...
2
37
15
27b1a367a33dfb602f28256afb1978a959d3a222
Tony Arcieri
2024-06-25T02:36:11
Cargo.lock: bump deps (#616) Updates the following dependencies: $ cargo update Updating crates.io index Locking 70 packages to latest compatible versions Updating aho-corasick v1.1.2 -> v1.1.3 Updating anstyle v1.0.4 -> v1.0.7 Updating autocfg v1.1.0 -> v1.3.0 Removing bitflags v...
diff --git a/Cargo.lock b/Cargo.lock index cf80266..984624d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa7603...
1
151
196
193d5e865827349f10d1262273813c20837fd714
Tony Arcieri
2024-06-23T21:08:26
v0.6.0-rc.0 (#612)
diff --git a/Cargo.lock b/Cargo.lock index f533347..cf80266 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.6.0-pre.12" +version = "0.6.0-rc.0" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index 7c65...
2
3
3
8a821e90256d035bdf4a33fa7c147b575dc8eb58
Tony Arcieri
2024-06-21T01:51:33
Fix `bernstein_yang_nlimbs!` calculation (#610) The previous calculation of the number of unsaturated 62-bit limbs needed to represent an integer of a given size was incorrect, leading to miscomputed results as seen in #606. This commit switches to a much simpler calculation based on `div_ceiling(62)`, and also ...
diff --git a/src/macros.rs b/src/macros.rs index e173ba2..5fa7a2f 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -11,10 +11,16 @@ macro_rules! nlimbs { /// Calculate the number of 62-bit unsaturated limbs required to represent the given number of bits when performing /// Bernstein-Yang inversions. +/// +/// We n...
2
13
1
2b81eae18c6dd89927b66f0f9af4413402b6bbea
daxpedda
2024-06-11T14:47:43
Account for Bincode allowing trailing bytes by default (#607)
diff --git a/src/odd.rs b/src/odd.rs index 5fbc2c8..6a4862d 100644 --- a/src/odd.rs +++ b/src/odd.rs @@ -255,19 +255,23 @@ mod tests { assert_eq!(&error_message, "io error: unexpected end of file"); } - // @reviewers: I expected an error when deserializing an Odd<U128> into an Odd<U64>, i...
1
11
7
876b125dcfc4fcb5c32417947f7fbf699c7a82f7
David
2024-06-05T18:04:56
Implement serde for `Odd` (#604)
diff --git a/src/odd.rs b/src/odd.rs index 7ba5f73..5fbc2c8 100644 --- a/src/odd.rs +++ b/src/odd.rs @@ -13,6 +13,14 @@ use {crate::Random, rand_core::CryptoRngCore}; #[cfg(all(feature = "alloc", feature = "rand_core"))] use crate::RandomBits; +#[cfg(feature = "serde")] +use crate::Zero; +#[cfg(feature = "serde")] ...
1
96
0
5167b123c2224a60da32df707cedcf0872646c5f
Andrew Whitehead
2024-05-31T17:04:10
add impls for fmt::Binary (#601) Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
diff --git a/src/limb.rs b/src/limb.rs index cbdf34b..ae1598a 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -157,6 +157,13 @@ impl fmt::Display for Limb { } } +impl fmt::Binary for Limb { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:0width$b}", &self.0, wi...
4
40
0
ea6e005e2128a2cc533583a81af087df54561c38
Tony Arcieri
2024-05-07T12:56:26
Remove vestigial sidefuzz support (#597) Originally added in #119 along with dudect support, however it was incomplete. This is now triggering warnings on the latest nightly versions.
diff --git a/src/lib.rs b/src/lib.rs index f9e8fc7..b4681cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -213,10 +213,3 @@ pub mod prelude { #[cfg(feature = "hybrid-array")] pub use crate::array::{ArrayDecoding, ArrayEncoding}; } - -#[cfg(sidefuzz)] -#[no_mangle] -pub extern "C" fn fuzz() { - let input = s...
1
0
7
29dba537948c1c905f327a1e90b928164c4c53e8
Bruce
2024-04-23T17:08:36
Boxed inv even mod (#594) * Ported inv_mod unit tests for BoxedUint * Ported inv_mod with even modulus for BoxedUint from Uint * Notes about strange acrobatics
diff --git a/src/uint/boxed/inv_mod.rs b/src/uint/boxed/inv_mod.rs index e642dae..1dee99f 100644 --- a/src/uint/boxed/inv_mod.rs +++ b/src/uint/boxed/inv_mod.rs @@ -43,18 +43,45 @@ impl BoxedUint { (x, is_some) } + + /// Computes the multiplicaitve inverse of `self` mod `modulus` + /// + /// `s...
1
153
8
8177e7aab050ef897e658371f5941f9f7cf2b29e
Thomas Coratger
2024-03-11T14:16:35
Small refactoring in mul mod (#582)
diff --git a/src/uint/mul_mod.rs b/src/uint/mul_mod.rs index 8010ebb..b1a130f 100644 --- a/src/uint/mul_mod.rs +++ b/src/uint/mul_mod.rs @@ -21,10 +21,7 @@ impl<const LIMBS: usize> Uint<LIMBS> { match p.to_odd().into() { Some(odd_p) => { let params = MontyParams::new_vartime(odd_p...
1
2
7
0a7d71af7a332bda3a24e2509116986be7b55755
Tony Arcieri
2024-03-06T02:00:27
Fix unused qualification (#581)
diff --git a/src/uint/encoding/rlp.rs b/src/uint/encoding/rlp.rs index 112efb1..2ec5d94 100644 --- a/src/uint/encoding/rlp.rs +++ b/src/uint/encoding/rlp.rs @@ -27,7 +27,7 @@ where fn decode(rlp: &Rlp<'_>) -> Result<Self, DecoderError> { rlp.decoder().decode_value(|bytes| { if bytes.first().c...
1
1
1
1c9da5b6c3bff698353a2ee87df290da6dfc7bda
Thomas Coratger
2024-03-01T18:25:55
Some efficiency improvements in div_rem (#578)
diff --git a/src/uint/div.rs b/src/uint/div.rs index ee0ab29..7eeb5ee 100644 --- a/src/uint/div.rs +++ b/src/uint/div.rs @@ -45,10 +45,10 @@ impl<const LIMBS: usize> Uint<LIMBS> { let mut i = Self::BITS; let mut done = ConstChoice::FALSE; loop { - let (mut r, borrow) = rem.sbb(&c, ...
1
8
8
0cb5cd04899c18fbb2e24febf2b163727c258cbb
Aaron Feickert
2024-02-27T14:21:44
Fix documentation nit (#576)
diff --git a/src/uint/bit_xor.rs b/src/uint/bit_xor.rs index 7042b61..a255ba9 100644 --- a/src/uint/bit_xor.rs +++ b/src/uint/bit_xor.rs @@ -20,7 +20,7 @@ impl<const LIMBS: usize> Uint<LIMBS> { Self { limbs } } - /// Perform wrapping bitwise `XOR``. + /// Perform wrapping bitwise `XOR`. /// ...
1
1
1
4ff410500d0453e6e1a28d0de1130e4b65ee1f3c
Tony Arcieri
2024-02-08T01:29:25
Use `ConstZero` trait from `num_traits` (#573) Added in rust-num/num-traits#303
diff --git a/Cargo.lock b/Cargo.lock index 5b494c4..a562db9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -424,9 +424,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d16...
4
17
13
2a61f1dd5853b10c998fbadd0b4e8b3488f7d20d
Tony Arcieri
2024-01-28T00:47:46
Address `BoxedUint::is_nonzero` TODO (#567)
diff --git a/Cargo.lock b/Cargo.lock index 051c910..ff94355 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.6.0-pre.11" +version = "0.6.0-pre.12" dependencies = [ "bincode", "criterion", diff --git a/src/uint/boxed.rs b/src/uint/box...
2
4
6
6ccbe7412ffbb041e79c520be623af330ee8730f
Tony Arcieri
2024-01-17T14:31:17
v0.6.0-pre.12 (#564)
diff --git a/Cargo.toml b/Cargo.toml index 63a4fb3..f7b4665 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crypto-bigint" -version = "0.6.0-pre.11" +version = "0.6.0-pre.12" description = """ Pure Rust implementation of a big integer library which has been designed from the ground-up fo...
1
1
1
85f70433cf5da6ae956fe1f9884e5c81fd540e3f
Tony Arcieri
2024-01-17T14:13:39
Bump `hybrid-array` to v0.2.0-rc.1 (#563) This was supposed to be a "backwards compatible" release but it did wind up adding some trait impls which break inference in certain cases. This bumps the dependency and fixes the ambiguities.
diff --git a/Cargo.lock b/Cargo.lock index 0a16d2e..051c910 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -303,9 +303,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "hybrid-array" -version = "0.2.0-rc.0" +version = "0.2.0-rc.1" source = "registry+https://github....
3
5
5
d62278bd0db8ca044d5efcac9a614fd859e415ec
Tony Arcieri
2024-01-16T23:29:40
v0.6.0-pre.11 (#561)
diff --git a/Cargo.lock b/Cargo.lock index 40b8751..0a16d2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.6.0-pre.10" +version = "0.6.0-pre.11" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index 1d...
2
2
2
8f4c7f5eee83ba2d247bbe8afeaa9d9daedd3ea6
Tony Arcieri
2024-01-16T18:51:48
Refactor `Uint::{concat, concat_mixed}` (#558) Does a similar treatment to what #556 and #557 did for `split*` methods, moving `concat_mixed` to be a method on `Uint` that accepts `&self`, making the method public, and redefining `Uint::concat` generically with bounds on `Self: Concat`.
diff --git a/src/uint/concat.rs b/src/uint/concat.rs index 9dce8fb..eba11ca 100644 --- a/src/uint/concat.rs +++ b/src/uint/concat.rs @@ -1,34 +1,45 @@ use crate::{Concat, ConcatMixed, Limb, Uint}; -impl<T> Concat for T -where - T: ConcatMixed<T>, -{ - type Output = Self::MixedOutput; -} +impl<const L: usize> U...
3
44
42
f1761221454faa3b664cff545dbc53e0ad76d431
Tony Arcieri
2024-01-16T18:27:15
Make `Uint::split` const generic over inputs (#557) This allows a `const fn` to be written which is bounded on the `Split` trait, and generic over a number of input limbs.
diff --git a/src/uint/macros.rs b/src/uint/macros.rs index b43ef1a..689482f 100644 --- a/src/uint/macros.rs +++ b/src/uint/macros.rs @@ -136,13 +136,6 @@ macro_rules! impl_uint_concat_split_even { { type Output = Uint<{ <$name>::LIMBS / 2 }>; } - - impl $name { - /// Spl...
2
9
8
15959649e60b621c7942e4641a61e11af2811ef0
Tony Arcieri
2024-01-16T18:00:20
Uint: change `split_mixed` to accept `self`; make `pub` (#556) The `split_mixed` method provides a `const fn`-friendly way to split numbers. This refactors it to be a method that accepts `self` as an argument so it can be called as `uint.split_mixed()` and also exposes it as `pub`, allowing downstream users to u...
diff --git a/src/uint/from.rs b/src/uint/from.rs index cb8e549..7a80370 100644 --- a/src/uint/from.rs +++ b/src/uint/from.rs @@ -1,6 +1,6 @@ //! `From`-like conversions for [`Uint`]. -use crate::{ConcatMixed, Limb, Uint, WideWord, Word, U128, U64}; +use crate::{ConcatMixed, Limb, SplitMixed, Uint, WideWord, Word, U1...
3
31
25
313505f9e748ad462033c957bf0cdad1715934b8
Tony Arcieri
2024-01-12T01:46:41
Add a `const fn` version of `Uint::to_le_bytes` (#555) Previously only `Uint::to_be_bytes` was defined this way.
diff --git a/src/uint/macros.rs b/src/uint/macros.rs index 180b1f4..6d594db 100644 --- a/src/uint/macros.rs +++ b/src/uint/macros.rs @@ -40,6 +40,11 @@ macro_rules! impl_uint_aliases { pub const fn to_be_bytes(&self) -> [u8; $bits / 8] { encoding::uint_to_be_bytes::<{ nlimbs!($bits...
1
5
0
9bcccf4c30448aa7e93f2da7a6e254ccaaf853fb
Tony Arcieri
2024-01-10T23:38:25
v0.6.0-pre.10 (#551)
diff --git a/Cargo.lock b/Cargo.lock index 95d34c4..40b8751 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.6.0-pre.9" +version = "0.6.0-pre.10" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index 6bf...
2
2
2
1876975ecb3d967e134a8f4140902e9b777eb3d8
Tony Arcieri
2024-01-10T23:22:23
Uint: simplify `as(_mut)_words` pointer casts (#553) Uses `cast()` to perform the pointer cast, which is much simpler, and fixes the `trivial_pointer_casts` lint. Also adds tests.
diff --git a/src/uint.rs b/src/uint.rs index a150c2a..f5ba5e6 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -141,18 +141,18 @@ impl<const LIMBS: usize> Uint<LIMBS> { /// Borrow the inner limbs as an array of [`Word`]s. pub const fn as_words(&self) -> &[Word; LIMBS] { // SAFETY: `Limb` is a `repr(tran...
1
19
6
3d915cd846c2ea6def7995327fb38451e5cf6cc9
Tony Arcieri
2024-01-10T22:50:25
Add `Uint::{shl_vartime, shr_vartime}` (#552) Adds panicking wrappers for `overflowing_sh*_vartime` which panic-on-overflow.
diff --git a/src/uint/shl.rs b/src/uint/shl.rs index 85a309d..7b033c0 100644 --- a/src/uint/shl.rs +++ b/src/uint/shl.rs @@ -13,6 +13,14 @@ impl<const LIMBS: usize> Uint<LIMBS> { .expect("`shift` within the bit size of the integer") } + /// Computes `self << shift` in variable time. + /// + ...
2
16
0
0083e3438421bc19213d7e11f419c6ad5c4a15e3
Tony Arcieri
2024-01-10T21:57:14
Cleanup Uint tests (#549) Some formatting changes, and also test bitwise ops regardless of if the rhs param is zero (appears to be copypasta from division tests).
diff --git a/tests/uint.rs b/tests/uint.rs index 7295657..1ecdf46 100644 --- a/tests/uint.rs +++ b/tests/uint.rs @@ -237,6 +237,19 @@ proptest! { } } + #[test] + fn wrapping_rem(a in uint(), b in uint()) { + let a_bi = to_biguint(&a); + let b_bi = to_biguint(&b); + + if !b_bi....
1
23
31
a89f574ac6266c535b2b2b1fc50b2de090e49ecb
Tony Arcieri
2024-01-10T18:39:20
v0.6.0-pre.9 (#548)
diff --git a/Cargo.lock b/Cargo.lock index 56fff98..95d34c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.6.0-pre.8" +version = "0.6.0-pre.9" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index 400e...
2
2
2
b48a031883b9d63f3f385c4d0ae73cc291cf198b
Tony Arcieri
2024-01-10T18:18:27
Bump `hybrid-array` to v0.2.0-rc.0 (#547)
diff --git a/Cargo.lock b/Cargo.lock index 05357fe..56fff98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -303,9 +303,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "hybrid-array" -version = "0.2.0-pre.8" +version = "0.2.0-rc.0" source = "registry+https://github...
2
3
3
1e136734a1b7e62694946b14e05e594fe916a7c6
Tony Arcieri
2024-01-09T15:19:21
Rename `ZeroConstant` => `ConstZero` (#546) Renames the trait to match the prospective name it might potentially receive upstream in `num-traits`: rust-num/num-traits#303
diff --git a/src/limb.rs b/src/limb.rs index f64d1e8..cbdf34b 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -19,7 +19,7 @@ mod sub; #[cfg(feature = "rand_core")] mod rand; -use crate::{Bounded, ConstCtOption, Constants, NonZero, ZeroConstant}; +use crate::{Bounded, ConstCtOption, ConstZero, Constants, NonZero}; us...
4
10
10
1d887c37783e3f94506823aaa00bcd6613bb4539
Tony Arcieri
2024-01-08T01:58:02
v0.6.0-pre.8 (#545)
diff --git a/Cargo.lock b/Cargo.lock index 0c5021a..05357fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.6.0-pre.7" +version = "0.6.0-pre.8" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index 002a...
2
2
2
b3a9b88dc26ca5097b061f5c724599ea8ed999f9
Tony Arcieri
2024-01-07T22:26:02
Bump `serdect` to v0.3.0-pre.0 (#543)
diff --git a/Cargo.lock b/Cargo.lock index 7ef9487..da825c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -715,9 +715,9 @@ dependencies = [ [[package]] name = "serdect" -version = "0.2.0" +version = "0.3.0-pre.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84f14a19e9a014bb9f4512488...
2
3
3
f02ea8ff1148156c1baacd581283d7806cb4f3dd
Tony Arcieri
2024-01-07T22:22:48
Bump `der` dependency to v0.8.0-pre.0 (#542)
diff --git a/Cargo.lock b/Cargo.lock index 81f64c4..7ef9487 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -240,9 +240,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.8" +version = "0.8.0-pre.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f74...
2
3
3
bc5b77258654cbedcd5f88c1362370fb84895f18
Bruce
2024-01-06T21:17:06
Boxed sqrt reduce cloning (#541)
diff --git a/benches/boxed_uint.rs b/benches/boxed_uint.rs index 52e4213..7713579 100644 --- a/benches/boxed_uint.rs +++ b/benches/boxed_uint.rs @@ -43,6 +43,25 @@ fn bench_shifts(c: &mut Criterion) { group.finish(); } -criterion_group!(benches, bench_shifts); +fn bench_boxed_sqrt(c: &mut Criterion) { + let ...
2
21
3
50c576ce05b1bb7fc971febbaad2d32c2366e1fd
Dustin Ray
2024-01-03T22:36:54
docs: a few usage examples for div (#540) Co-authored-by: Dr. Capybara <dustinray313@gmail.com>
diff --git a/src/uint/div.rs b/src/uint/div.rs index 4ee6c63..ee0ab29 100644 --- a/src/uint/div.rs +++ b/src/uint/div.rs @@ -159,7 +159,19 @@ impl<const LIMBS: usize> Uint<LIMBS> { /// Computes `self` % 2^k. Faster than reduce since its a power of 2. /// Limited to 2^16-1 since Uint doesn't support higher. ...
2
63
11
0383b208e2cef4bdcc297ee23a394bc311e4e776
Tony Arcieri
2023-12-31T00:00:58
Use explicit types in pointer casts (#539) It's safer to use explicit types than to let the compiler infer them in these situations
diff --git a/src/uint.rs b/src/uint.rs index e483e0b..30d0e35 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -143,7 +143,7 @@ impl<const LIMBS: usize> Uint<LIMBS> { // SAFETY: `Limb` is a `repr(transparent)` newtype for `Word` #[allow(trivial_casts, unsafe_code)] unsafe { - &*((&sel...
2
4
4
980dfea750bb86423919afd657c71dddb08595aa
Tony Arcieri
2023-12-29T23:41:16
MontyParams: refactor const generic `WIDE_LIMBS` parameter (#536) Moves the `const WIDE_LIMBS` generic parameter from `MontyParams::new` to the outer scope, since it's intended to be inferred via the `Concat` trait rather than explicitly specified.
diff --git a/src/modular/monty_form.rs b/src/modular/monty_form.rs index 2e01879..95c4aad 100644 --- a/src/modular/monty_form.rs +++ b/src/modular/monty_form.rs @@ -32,13 +32,13 @@ pub struct MontyParams<const LIMBS: usize> { mod_neg_inv: Limb, } -impl<const LIMBS: usize> MontyParams<LIMBS> { +impl<const LIMBS:...
1
8
6
e3c56a849419dcc8e23f4adcefca4be8d569d9b6
Tony Arcieri
2023-12-29T19:51:29
v0.6.0-pre.7 (#535)
diff --git a/Cargo.lock b/Cargo.lock index bc7a350..81f64c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.6.0-pre.6" +version = "0.6.0-pre.7" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index 77ef...
2
2
2
553e72ec77485c1350b5282ce611d4cca4656ec2
Bogdan Opanchuk
2023-12-29T19:05:46
Additional methods for `Integer` and `Monty` (#533) * Add `Integer::from_limb_like()`, `one_like()`, `zero_like()`. * Add `Monty::params()` and `as_montgomery()`
diff --git a/src/modular/boxed_monty_form.rs b/src/modular/boxed_monty_form.rs index 2c6fe07..5098d5d 100644 --- a/src/modular/boxed_monty_form.rs +++ b/src/modular/boxed_monty_form.rs @@ -256,6 +256,14 @@ impl Monty for BoxedMontyForm { BoxedMontyForm::one(params) } + fn params(&self) -> &Self::Para...
5
50
0
793d098ffdebc4d604af922dd82d62ef8dc0c129
Tony Arcieri
2023-12-28T18:33:48
Move `Uint::square` const param `WIDE_LIMBS` to impl block (#532) This parameter is inferred via `Concat<Output = Uint<WIDE_LIMBS>`.
diff --git a/src/uint/mul.rs b/src/uint/mul.rs index e2c7555..0843e94 100644 --- a/src/uint/mul.rs +++ b/src/uint/mul.rs @@ -90,15 +90,6 @@ impl<const LIMBS: usize> Uint<LIMBS> { Self::select(&res, &Self::MAX, overflow.is_nonzero()) } - /// Square self, returning a concatenated "wide" result. - pu...
1
11
9
711144e1cbea988bab25871105247130f648e8e9
Tony Arcieri
2023-12-28T17:15:52
Uint: remove `UNSAT_LIMBS` from `inv_*mod` (#531) It's really an implementation detail of the Bernstein-Yang inverter, and not actually customizable by the caller, so get it out of the way.
diff --git a/src/uint/inv_mod.rs b/src/uint/inv_mod.rs index 03f46b2..38a54cf 100644 --- a/src/uint/inv_mod.rs +++ b/src/uint/inv_mod.rs @@ -81,25 +81,21 @@ impl<const LIMBS: usize> Uint<LIMBS> { ConstCtOption::new(x, is_some) } +} +impl<const LIMBS: usize, const UNSAT_LIMBS: usize> Uint<LIMBS> +where...
1
7
11
f372474628abfcbda9dda478c76cbfa06ffdc102
Tony Arcieri
2023-12-28T16:28:18
Uint: fix macro-generated concat/split docs (#530) It wasn't updated to reflect the low/high ordering changes from #526
diff --git a/src/uint/macros.rs b/src/uint/macros.rs index a275d98..180b1f4 100644 --- a/src/uint/macros.rs +++ b/src/uint/macros.rs @@ -113,8 +113,8 @@ macro_rules! impl_uint_concat_split_even { } impl Uint<{ <$name>::LIMBS / 2 }> { - /// Concatenate the two values, with `self` as most s...
1
3
4
0977d826033be4238008b1439cd2fd577813e671
Tony Arcieri
2023-12-28T15:38:46
Remove docs about `const_eval_limit` (#529) It has been removed in recent Rust releases, and replaced with a printed warning: https://github.com/rust-lang/rust/pull/103877
diff --git a/src/lib.rs b/src/lib.rs index 569f5f5..0890712 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,15 +56,6 @@ //! pub const MODULUS_SHR1: U256 = MODULUS.shr(1); //! ``` //! -//! Note that large constant computations may accidentally trigger a the `const_eval_limit` of the compiler. -//! The current way to ...
1
0
9
3b73e08ecffcac9345d0c85f2db1657db8e8461b
Tony Arcieri
2023-12-28T15:29:50
Documentation improvements (#528) - Expand documentation on `Limb` representations - Bernstein-Yang doc cleanups
diff --git a/src/limb.rs b/src/limb.rs index 4e177e5..f64d1e8 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -53,8 +53,11 @@ pub type Word = u64; #[cfg(target_pointer_width = "64")] pub type WideWord = u128; -/// Big integers are represented as an array of smaller CPU word-size integers -/// called "limbs". +/// Big...
3
29
19
b811e5e0f42b6891fe9665522adac3618b0a68d0
Tony Arcieri
2023-12-28T14:52:10
v0.6.0-pre.6 (#527)
diff --git a/Cargo.lock b/Cargo.lock index 0ff03fc..bc7a350 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.6.0-pre.5" +version = "0.6.0-pre.6" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index e838...
3
3
4
dc64fb41a2651b052ea5443dcebb0359642de20f
Tony Arcieri
2023-12-28T14:27:41
Reverse `Concat(Mixed)`/`Split(Mixed)` argument ordering (#526) Changes to a "little endian" `lo, hi` convention for the ordering of arguments to concatenation methods and the ordering of the returned 2-tuple from split methods. This is more consistent with the rest of the crate, and the `Uint { limbs }` array w...
diff --git a/src/modular.rs b/src/modular.rs index b33eae8..6b22279 100644 --- a/src/modular.rs +++ b/src/modular.rs @@ -121,7 +121,7 @@ mod tests { #[test] fn test_reducing_r2_wide() { // Divide the value ONE^2 by R, which should equal ONE - let (hi, lo) = Modulus2::ONE.square().split(); + ...
8
49
53
49b54aa8ffad62b071237bdef0f0b316a1a946dc
Bogdan Opanchuk
2023-12-27T23:40:18
Add "vartime" suffix to Monty::new_params() (#525)
diff --git a/src/modular/boxed_monty_form.rs b/src/modular/boxed_monty_form.rs index 0479744..2c6fe07 100644 --- a/src/modular/boxed_monty_form.rs +++ b/src/modular/boxed_monty_form.rs @@ -240,8 +240,8 @@ impl Monty for BoxedMontyForm { type Integer = BoxedUint; type Params = BoxedMontyParams; - fn new_p...
3
6
5
42ea8e6965573e8039294adfaa6a59909859eadd
Bogdan Opanchuk
2023-12-27T22:18:45
Add a proper handling of `bit_length = 0` in RandomBits (#524)
diff --git a/src/uint/rand.rs b/src/uint/rand.rs index 9ca9a12..7571a05 100644 --- a/src/uint/rand.rs +++ b/src/uint/rand.rs @@ -18,11 +18,18 @@ impl<const LIMBS: usize> Random for Uint<LIMBS> { } } +/// Fill the given limbs slice with random bits. +/// +/// NOTE: Assumes that the limbs in the given slice are z...
1
24
3
fcd621bae1e2fd2d17d3cad598f585fb3da485c7
Tony Arcieri
2023-12-27T21:55:29
Handle even `s` in `Uint::inv_mod` (#523) This is an oversight from #501 which switched to using Bernstein-Yang inversions for `Uint::inv_odd_mod`. The new implementation assumes `s` is always `Odd` but doesn't actually check for that and set the `ConstCtOption` to be "none" accordingly.
diff --git a/src/const_choice.rs b/src/const_choice.rs index 7268715..eb0235a 100644 --- a/src/const_choice.rs +++ b/src/const_choice.rs @@ -240,6 +240,13 @@ impl<T> ConstCtOption<T> { assert!(self.is_some.is_true_vartime()); self.value } + + /// Apply an additional [`ConstChoice`] requirement...
2
10
1
efb267bc1f105d02981f7e7b25364d9244171e95
Tony Arcieri
2023-12-27T20:52:07
rustdoc: rewrite "Usage" intro (#520) Provide a more comprehensive overview of the main types in the crate
diff --git a/src/lib.rs b/src/lib.rs index b2682bd..569f5f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,16 +20,24 @@ //! ## Usage //! -//! 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 intege...
1
18
10
5e1c2b6e42b0eb534711a503ede387cb74325903
Tony Arcieri
2023-12-27T20:50:29
Bump `num-modular` to v0.6 (#522)
diff --git a/Cargo.lock b/Cargo.lock index 8a6e378..0ff03fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -414,9 +414,9 @@ dependencies = [ [[package]] name = "num-modular" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a5fe11d4135c3bcdf3a95b18b1...
2
3
3
90d7b0a75a3ec1ba4e6eea70e9e9fe0ccf0a76b1
Bogdan Opanchuk
2023-12-27T20:50:13
Add `RandomBits` trait (#510) Adds a trait for generating a random number of a given bit size.
diff --git a/benches/boxed_monty.rs b/benches/boxed_monty.rs index d5a0738..b621a1f 100644 --- a/benches/boxed_monty.rs +++ b/benches/boxed_monty.rs @@ -4,7 +4,7 @@ use criterion::{ }; use crypto_bigint::{ modular::{BoxedMontyForm, BoxedMontyParams}, - BoxedUint, Odd, RandomMod, + BoxedUint, Odd, RandomBit...
7
259
42
8746be86996b1d349e10534bee8db9042b103150
Tony Arcieri
2023-12-27T18:40:27
Add benchmarks for `MontyParams::new` (#521) The vartime constructor is 2.75X faster: Dynamic Montgomery arithmetic/MontyParams::new time: [5.8611 µs 5.8708 µs 5.8812 µs] Dynamic Montgomery arithmetic/MontyParams::new_vartime time: [2.1284 µs 2.1405 µs 2.1567...
diff --git a/benches/monty.rs b/benches/monty.rs index 7141951..984af6a 100644 --- a/benches/monty.rs +++ b/benches/monty.rs @@ -12,7 +12,15 @@ use rand_core::OsRng; use crypto_bigint::MultiExponentiate; fn bench_montgomery_conversion<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) { - group.bench_function("M...
1
10
2
3ce99d4ea91f6198797c91ad944a684adcdb4b6d
Bogdan Opanchuk
2023-12-27T16:32:39
Add `BitOperations` trait (#507)
diff --git a/src/const_choice.rs b/src/const_choice.rs index 5152ff0..7268715 100644 --- a/src/const_choice.rs +++ b/src/const_choice.rs @@ -163,6 +163,13 @@ impl From<ConstChoice> for Choice { } } +impl From<Choice> for ConstChoice { + #[inline] + fn from(choice: Choice) -> Self { + ConstChoice::f...
7
378
245
efaaa05c99e32e515a76a93cafb7f7ab4691283f
Tony Arcieri
2023-12-27T01:45:19
Have `(Boxed)MontyParams::modulus` return `&Odd<_>` (#517) Notably `Odd` permits a simple reference conversion to `NonZero` which makes it possible to clean up some tests.
diff --git a/benches/boxed_monty.rs b/benches/boxed_monty.rs index 45068e5..d5a0738 100644 --- a/benches/boxed_monty.rs +++ b/benches/boxed_monty.rs @@ -4,7 +4,7 @@ use criterion::{ }; use crypto_bigint::{ modular::{BoxedMontyForm, BoxedMontyParams}, - BoxedUint, NonZero, Odd, RandomMod, + BoxedUint, Odd, ...
5
15
12
df8b716b85578d5449740f668cfbec770377afe8
Tony Arcieri
2023-12-27T01:26:02
Rename `MontyParams::new` => `::new_vartime` (#516) For consistency with `BoxedMontyParams::new_vartime` and our general labeling strategy.
diff --git a/benches/monty.rs b/benches/monty.rs index a59de91..7141951 100644 --- a/benches/monty.rs +++ b/benches/monty.rs @@ -15,12 +15,12 @@ fn bench_montgomery_conversion<M: Measurement>(group: &mut BenchmarkGroup<'_, M> group.bench_function("MontyParams creation", |b| { b.iter_batched( ...
8
15
17
4cfc8c1905f76fd3d35573a493b0f9fc0cd0c600
Tony Arcieri
2023-12-27T01:16:06
Make `Uint::widening_mul` into a `const fn` (#515) Similar to #514
diff --git a/src/uint/mul.rs b/src/uint/mul.rs index 66acd67..672e41d 100644 --- a/src/uint/mul.rs +++ b/src/uint/mul.rs @@ -56,15 +56,15 @@ macro_rules! impl_schoolbook_multiplication { impl<const LIMBS: usize> Uint<LIMBS> { /// Multiply `self` by `rhs`, returning a concatenated "wide" result. - pub fn wide...
1
10
8
47933c72ca02bd1ca810fffd20c2ffd7587f10b8
Tony Arcieri
2023-12-27T01:07:38
Make `Uint::square` into a `const fn` (#514) Wound up being pretty trivial to do.
diff --git a/src/uint/mul.rs b/src/uint/mul.rs index fb3175e..66acd67 100644 --- a/src/uint/mul.rs +++ b/src/uint/mul.rs @@ -2,6 +2,7 @@ // TODO(tarcieri): use Karatsuba for better performance +use super::concat::concat_mixed; use crate::{ Checked, CheckedMul, Concat, ConcatMixed, Limb, Uint, WideningMul, Wr...
1
4
3
c714e437aacff13dbe54fed81a920ddb92d33e0b
Bogdan Opanchuk
2023-12-26T17:25:19
Add `SquareRoot` trait (#508)
diff --git a/src/traits.rs b/src/traits.rs index a2e8da7..1223090 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -138,6 +138,7 @@ pub trait Integer: + for<'a> Sub<&'a Self, Output = Self> + SubMod<Output = Self> + Sync + + SquareRoot + WrappingAdd + WrappingSub + WrappingMul @@ -463,...
3
32
2
f2dde0d585003f8b8642eee008c615e5e41afd48
Bogdan Opanchuk
2023-12-26T17:24:24
Add `ShrVartime` and `ShlVartime` traits (#509)
diff --git a/src/traits.rs b/src/traits.rs index 881b164..a2e8da7 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -130,8 +130,10 @@ pub trait Integer: + Sized + Shl<u32, Output = Self> + ShlAssign<u32> + + ShlVartime + Shr<u32, Output = Self> + ShrAssign<u32> + + ShrVartime + Sub<O...
5
80
18
1e7cb73038f8b1c9d89ebc5c5220b020a8b68744
Tony Arcieri
2023-12-23T21:43:24
v0.6.0-pre.5 (#506)
diff --git a/Cargo.lock b/Cargo.lock index 023b1f4..8a6e378 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.6.0-pre.4" +version = "0.6.0-pre.5" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index a8ba...
2
2
2
bc061383cb4f63d69b89b23232fdce3e5b0d898c
Tony Arcieri
2023-12-23T16:32:21
Add `InvMod` trait (#505) Adds a trait for computing modular inverses with the modulus provided as an argument, impl'd for both `Uint` and `BoxedUint`.
diff --git a/src/traits.rs b/src/traits.rs index 2888ee6..881b164 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -346,6 +346,12 @@ pub trait MulMod<Rhs = Self> { fn mul_mod(&self, rhs: &Rhs, p: &Self) -> Self::Output; } +/// Compute `1 / self mod p`. +pub trait InvMod: Sized { + /// Compute `1 / self mod ...
3
36
6
84d5495fb232b244e05660ae0deafc6a96916109
Tony Arcieri
2023-12-23T15:55:46
tests: extract `common` module (#504) Extracts a module containing shared functionality which can be reused between various tests. Currently it just contains `to_biguint` (which has been adapted to work with both `Uint` and `BoxedUint`)
diff --git a/src/odd.rs b/src/odd.rs index 81251a5..b4b4d1c 100644 --- a/src/odd.rs +++ b/src/odd.rs @@ -1,6 +1,6 @@ //! Wrapper type for non-zero integers. -use crate::{Integer, NonZero, Uint}; +use crate::{Integer, Limb, NonZero, Uint}; use core::{cmp::Ordering, ops::Deref}; use subtle::{Choice, ConditionallySel...
8
58
42
7c65c663ed3bc521ad2afa313efa67c6cd19613c
Bogdan Opanchuk
2023-12-23T14:47:08
Add `DivRemLimb` and `RemLimb` traits (#496) * Add more bounds for Monty::Params * Use num-bigint instead of num-bigint-dig * Add From<Limb> bound for Integer * Fix vartime method usage in constant-time methods
diff --git a/Cargo.lock b/Cargo.lock index 29acab7..023b1f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -77,12 +77,6 @@ version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" -[[package]] -name = "byteorder" -...
11
146
59
90432fc9d09116869f4ade507f32171ef41a6732
Tony Arcieri
2023-12-23T02:49:35
Boxed Bernstein-Yang: reduce allocations (#502) Performs more operations in-place Boxed Montgomery arithmetic/invert, 4096-bit time: [208.34 µs 208.70 µs 209.08 µs] change: [-23.092% -22.837% -22.579%] (p = 0.00 < 0.05) Performance has imp...
diff --git a/benches/boxed_monty.rs b/benches/boxed_monty.rs index 7636364..45068e5 100644 --- a/benches/boxed_monty.rs +++ b/benches/boxed_monty.rs @@ -19,7 +19,7 @@ fn to_biguint(uint: &BoxedUint) -> BigUint { fn bench_montgomery_ops<M: Measurement>(group: &mut BenchmarkGroup<'_, M>) { let params = BoxedMontyPa...
2
128
116
6a293f9ea07d73544abfac3b3e47d91d588592ad
Tony Arcieri
2023-12-23T02:19:50
BoxedUint: rename `inv_odd_mod` for consistency
diff --git a/src/uint/boxed/inv_mod.rs b/src/uint/boxed/inv_mod.rs index d35cab7..32513dc 100644 --- a/src/uint/boxed/inv_mod.rs +++ b/src/uint/boxed/inv_mod.rs @@ -7,9 +7,8 @@ use crate::{ use subtle::{Choice, ConstantTimeEq, ConstantTimeLess, CtOption}; impl BoxedUint { - /// Computes the multiplicative invers...
3
3
6
b04f2f1b09b21af5473187e5df282ea2f06c378e
Tony Arcieri
2023-12-23T01:38:28
Impl `PrecomputeInterver(WithAdjuster)` on `Odd` (#500) Moves all of the impls for these traits to `Odd<Uint<_>>`/`Odd<BoxedUint>`. They infallibly return an inverter, but previously panicked if called on even numbers. This commit replaces the panic condition with type safety instead.
diff --git a/src/modular/boxed_monty_form/inv.rs b/src/modular/boxed_monty_form/inv.rs index 6017fd8..f7e357a 100644 --- a/src/modular/boxed_monty_form/inv.rs +++ b/src/modular/boxed_monty_form/inv.rs @@ -33,7 +33,7 @@ impl PrecomputeInverter for BoxedMontyParams { fn precompute_inverter(&self) -> BoxedMontyForm...
10
82
54
687b99079b89150d8e2b7b468a4673282b6807f6
Tony Arcieri
2023-12-23T01:11:58
Add `Gcd` trait (#499) Adds a trait for computing the greatest common divisor of two numbers. Uses a fallible impl for the `*Uint` types, and an infallible one for `Odd<*Uint>`.
diff --git a/src/traits.rs b/src/traits.rs index 79c2442..80c8838 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -197,21 +197,18 @@ pub trait FixedInteger: Bounded + ConditionallySelectable + Constants + Copy + I const LIMBS: usize; } -/// Obtain a precomputed inverter for efficiently computing modular inver...
4
62
18
3ca5068aa95f114c57c61da49de60df167845703
Bogdan Opanchuk
2023-12-23T01:08:21
Fix random Odd generation (#498)
diff --git a/src/odd.rs b/src/odd.rs index 608a0d8..81251a5 100644 --- a/src/odd.rs +++ b/src/odd.rs @@ -126,20 +126,20 @@ impl PartialOrd<Odd<BoxedUint>> for BoxedUint { #[cfg(feature = "rand_core")] impl<const LIMBS: usize> Random for Odd<Uint<LIMBS>> { - /// Generate a random `NonZero<Uint<T>>`. + /// Gene...
1
4
4
25ec62a4026cdc49787433ae34dff5c66d2a7d08
Tony Arcieri
2023-12-23T00:31:47
Add `BoxedUint::gcd` (#497) Support for computing the greatest common divisor of two `BoxedUint`s using Bernstein-Yang
diff --git a/src/modular.rs b/src/modular.rs index e2106cb..b33eae8 100644 --- a/src/modular.rs +++ b/src/modular.rs @@ -21,7 +21,7 @@ mod monty_form; mod reduction; mod add; -mod bernstein_yang; +pub(crate) mod bernstein_yang; mod div_by_2; mod mul; mod pow; diff --git a/src/modular/bernstein_yang/boxed.rs b/sr...
6
77
2
336dda1b9676de85c28905864d53c2725b085241
Tony Arcieri
2023-12-23T00:01:04
Refactor Bernstein-Yang implementation(s) (#495) - Extracts a `divsteps` function in both the stack-allocated and boxed implementations which can be reused for both inversions and GCD - Changes the boxed implementation to use more in-place operations
diff --git a/src/modular/bernstein_yang.rs b/src/modular/bernstein_yang.rs index 31fa3b3..a995897 100644 --- a/src/modular/bernstein_yang.rs +++ b/src/modular/bernstein_yang.rs @@ -75,18 +75,13 @@ impl<const SAT_LIMBS: usize, const UNSAT_LIMBS: usize> /// Returns either the adjusted modular multiplicative inverse ...
2
74
57
17ae7410417b506c51e3a56f5a09d311796fe5fd
Tony Arcieri
2023-12-22T22:50:55
Use Bernstein-Yang for `BoxedMontyForm::invert` (#494) Results in a massive performance improvement: Boxed Montgomery arithmetic/invert, U256 time: [273.74 µs 274.79 µs 275.90 µs] change: [-95.729% -95.714% -95.696%] (p = 0.00 < 0.05) Perf...
diff --git a/src/modular/boxed_monty_form/inv.rs b/src/modular/boxed_monty_form/inv.rs index 4fd45a7..6017fd8 100644 --- a/src/modular/boxed_monty_form/inv.rs +++ b/src/modular/boxed_monty_form/inv.rs @@ -2,8 +2,8 @@ use super::{BoxedMontyForm, BoxedMontyParams}; use crate::{ - modular::{reduction::montgomery_re...
1
4
19
19840aebf6c4f0b9667b8a229fc58f76674ec864
Tony Arcieri
2023-12-22T18:29:36
v0.6.0-pre.4 (#492)
diff --git a/Cargo.lock b/Cargo.lock index 92c389e..29acab7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,7 +224,7 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.6.0-pre.3" +version = "0.6.0-pre.4" dependencies = [ "bincode", "criterion", diff --git a/Cargo.toml b/Cargo.toml index a56b...
2
2
2
e13b0604dc0ac6f223173734b104bd980ec49eff
Tony Arcieri
2023-12-21T23:51:01
Rename `MontgomeryMultiplier` => `MontyMultiplier` (#491)
diff --git a/src/modular/boxed_monty_form/mul.rs b/src/modular/boxed_monty_form/mul.rs index e5b2fc3..bb3f37d 100644 --- a/src/modular/boxed_monty_form/mul.rs +++ b/src/modular/boxed_monty_form/mul.rs @@ -23,7 +23,7 @@ impl BoxedMontyForm { /// Multiplies by `rhs`. pub fn mul(&self, rhs: &Self) -> Self { ...
2
12
12
ca80b71858a78dd3fdf0dcd7ee7ac0e665e02ec3
Bogdan Opanchuk
2023-12-21T23:00:46
Add `div_by_2()` to `Monty` trait (#490)
diff --git a/src/modular/boxed_monty_form.rs b/src/modular/boxed_monty_form.rs index fec97ac..44410cd 100644 --- a/src/modular/boxed_monty_form.rs +++ b/src/modular/boxed_monty_form.rs @@ -220,11 +220,7 @@ impl BoxedMontyForm { self.montgomery_form.clone() } - /// Performs the modular division by 2, ...
5
29
31
f9ef5aa597bc16ecf56d9fece89ba13fe818b3d0
Bruce
2023-12-21T19:26:05
Expand integer trait (#489) See also: #436 and entropyxyz/crypto-primes#37
diff --git a/src/const_choice.rs b/src/const_choice.rs index bd070f4..5152ff0 100644 --- a/src/const_choice.rs +++ b/src/const_choice.rs @@ -1,6 +1,6 @@ use subtle::{Choice, CtOption}; -use crate::{modular::BernsteinYangInverter, NonZero, Odd, Uint, Word}; +use crate::{modular::BernsteinYangInverter, Limb, NonZero, ...
14
668
8
871b6450978e35a49f672567f2af56a11b0fce79
Bogdan Opanchuk
2023-12-21T05:00:32
make Monty::new_params() take an Odd-wrapped modulus (#488)
diff --git a/src/modular/boxed_monty_form.rs b/src/modular/boxed_monty_form.rs index 049cb69..c3395f2 100644 --- a/src/modular/boxed_monty_form.rs +++ b/src/modular/boxed_monty_form.rs @@ -12,8 +12,7 @@ use super::{ reduction::{montgomery_reduction_boxed, montgomery_reduction_boxed_mut}, Retrieve, }; -use cr...
3
8
15
c6aceaaa14ab791ad8df7ed4705d30fd8ec3b30f
Tony Arcieri
2023-12-21T02:21:51
Bernstein-Yang: comment reformatting
diff --git a/src/modular/bernstein_yang.rs b/src/modular/bernstein_yang.rs index ae56aa1..c6e5447 100644 --- a/src/modular/bernstein_yang.rs +++ b/src/modular/bernstein_yang.rs @@ -18,22 +18,22 @@ use subtle::CtOption; /// Modular multiplicative inverter based on the Bernstein-Yang method. /// -/// The inverter can...
1
58
55
8416c2462e0ad28e41510df21b3ad4ee8fcf87b4
Bogdan Opanchuk
2023-12-20T21:30:38
Add traits to connect integers and residue represenations (#431) - add `Monty` associated type to `Integer` linking it to the corresponding Montgomery form - add `Monty` trait with an associated type linking back to the corresponding `Integer` and a bunch of bounds (similar to `Integer`) - remove the bound on `Squar...
diff --git a/src/modular/boxed_monty_form.rs b/src/modular/boxed_monty_form.rs index c2b3f2a..fd956bb 100644 --- a/src/modular/boxed_monty_form.rs +++ b/src/modular/boxed_monty_form.rs @@ -12,7 +12,7 @@ use super::{ reduction::{montgomery_reduction_boxed, montgomery_reduction_boxed_mut}, Retrieve, }; -use cr...
7
130
18
1ef81728591d11c5642a4773cd025ecb0253686b
Tony Arcieri
2023-12-20T16:35:39
NonZero: remove `from_uint`; reorganize module (#486) The `NonZero::from_uint` method duplicates the `Uint::to_nz` method, and isn't actually used anywhere in this codebase. Also reorganizes the module to place all the inherent impls at the top, and the trait impls at the bottom.
diff --git a/src/non_zero.rs b/src/non_zero.rs index ebec827..dd8921e 100644 --- a/src/non_zero.rs +++ b/src/non_zero.rs @@ -83,6 +83,65 @@ where } } +impl NonZero<Limb> { + /// Create a [`NonZero<Limb>`] from a [`NonZeroU8`] (const-friendly) + // TODO(tarcieri): replace with `const impl From<NonZeroU8>` ...
1
104
118
eb85103b41d4a6179052cf522ef3a9b2f0fc847d
Tony Arcieri
2023-12-20T01:50:11
Use `{Limb, Uint}::to_nz` to convert to `NonZero` (#484) Replaces the previous type-specific `NonZero::const_new` methods with more idiomatic `Limb::to_nz`/`Uint::to_nz` methods which can be called on a value and return `ConstCtChoice<NonZero<_>>`.
diff --git a/src/limb.rs b/src/limb.rs index cc2119f..4e177e5 100644 --- a/src/limb.rs +++ b/src/limb.rs @@ -19,7 +19,7 @@ mod sub; #[cfg(feature = "rand_core")] mod rand; -use crate::{Bounded, Constants, ZeroConstant}; +use crate::{Bounded, ConstCtOption, Constants, NonZero, ZeroConstant}; use core::fmt; use sub...
6
24
29
40410782292745b41e3a360ea9673d63bd71aa50
Tony Arcieri
2023-12-20T01:35:37
NonZero: remove `Zero` bounds except where needed (#483)
diff --git a/src/non_zero.rs b/src/non_zero.rs index e0691bc..8364761 100644 --- a/src/non_zero.rs +++ b/src/non_zero.rs @@ -22,7 +22,8 @@ use serdect::serde::{ /// Wrapper type for non-zero integers. #[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq, PartialOrd, Ord)] -pub struct NonZero<T: Zero>(pub(crate...
1
18
23
e40261d37a135dfbac309183d3856377e1c7dc4f
Tony Arcieri
2023-12-19T23:24:44
Bernstein-Yang: add `Int62L` arithmetic tests (#482) Adds some basic tests for `Int62L` arithmetic
diff --git a/src/modular/bernstein_yang.rs b/src/modular/bernstein_yang.rs index 117b47a..ae56aa1 100644 --- a/src/modular/bernstein_yang.rs +++ b/src/modular/bernstein_yang.rs @@ -444,3 +444,45 @@ impl<const LIMBS: usize> Int62L<LIMBS> { self.0[0] } } + +impl<const LIMBS: usize> PartialEq for Int62L<LIM...
1
42
0