summaryrefslogtreecommitdiffstats
path: root/vendor/crypto-bigint/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
commita0b8f38ab54ac451646aa00cd5e91b6c76f22a84 (patch)
treefc451898ccaf445814e26b46664d78702178101d /vendor/crypto-bigint/tests
parentAdding debian version 1.71.1+dfsg1-2. (diff)
downloadrustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.tar.xz
rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/crypto-bigint/tests')
-rw-r--r--vendor/crypto-bigint/tests/proptests.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/vendor/crypto-bigint/tests/proptests.rs b/vendor/crypto-bigint/tests/proptests.rs
index 9f489f0a8..572d990d1 100644
--- a/vendor/crypto-bigint/tests/proptests.rs
+++ b/vendor/crypto-bigint/tests/proptests.rs
@@ -282,4 +282,25 @@ proptest! {
assert_eq!(expected, actual);
}
+
+ #[test]
+ fn residue_div_by_2(a in uint_mod_p(P)) {
+ let a_bi = to_biguint(&a);
+ let p_bi = to_biguint(&P);
+ let two = BigUint::from(2u32);
+
+ let expected = if a_bi.is_even() {
+ &a_bi / two
+ }
+ else {
+ (&a_bi + &p_bi) / two
+ };
+ let expected = to_uint(expected);
+
+ let params = DynResidueParams::new(&P);
+ let a_m = DynResidue::new(&a, params);
+ let actual = a_m.div_by_2().retrieve();
+
+ assert_eq!(expected, actual);
+ }
}