diff --git a/iris-mpc-gpu/tests/bitinject.rs b/iris-mpc-gpu/tests/bitinject.rs index f296dae22..f896644e4 100644 --- a/iris-mpc-gpu/tests/bitinject.rs +++ b/iris-mpc-gpu/tests/bitinject.rs @@ -130,7 +130,7 @@ mod bitinject_test { let mut result = Vec::with_capacity(n_devices * INPUTS_PER_GPU_SIZE); for (mut a, b, c) in izip!(a, b, c) { for (a, b, c) in izip!(a.iter_mut(), b, c) { - *a += b + c; + *a = a.wrapping_add(b).wrapping_add(c); } result.extend(a); } diff --git a/iris-mpc-gpu/tests/bucket_threshold.rs b/iris-mpc-gpu/tests/bucket_threshold.rs index 99979e3cb..d3b2a30d9 100644 --- a/iris-mpc-gpu/tests/bucket_threshold.rs +++ b/iris-mpc-gpu/tests/bucket_threshold.rs @@ -32,7 +32,7 @@ mod bucket_threshold_test { let mut x = rng.gen_range::(0..=IrisCodeArray::IRIS_CODE_SIZE as u16); let neg = rng.gen::(); if neg { - x = u16::MAX - x + 1; + x = (u16::MAX - x).wrapping_add(1); } x }) @@ -48,7 +48,7 @@ mod bucket_threshold_test { fn rep_share(value: u16, rng: &mut R) -> (u16, u16, u16) { let a = rng.gen(); let b = rng.gen(); - let c = value - a - b; + let c = value.wrapping_sub(a).wrapping_sub(b); (a, b, c) } @@ -110,7 +110,10 @@ mod bucket_threshold_test { let mod_ = 1u64 << (16 + B_BITS); let mut res = Vec::with_capacity(code_input.len()); for (c, m) in code_input.into_iter().zip(mask_input) { - let r = ((m as u64) * A - ((c as u64) << B_BITS) - 1) % mod_; + let r = (((m as u64) * A) + .wrapping_sub((c as u64) << B_BITS) + .wrapping_sub(1)) + % mod_; let msb = r >> (B_BITS + 16 - 1) & 1 == 1; res.push(msb) } diff --git a/iris-mpc-gpu/tests/buckets.rs b/iris-mpc-gpu/tests/buckets.rs index 4159d4569..4b53390da 100644 --- a/iris-mpc-gpu/tests/buckets.rs +++ b/iris-mpc-gpu/tests/buckets.rs @@ -33,7 +33,7 @@ mod buckets_test { let mut x = rng.gen_range::(0..=IrisCodeArray::IRIS_CODE_SIZE as u16); let neg = rng.gen::(); if neg { - x = u16::MAX - x + 1; + x = (u16::MAX - x).wrapping_add(1); } x }) @@ -49,7 +49,7 @@ mod buckets_test { fn rep_share(value: u16, rng: &mut R) -> (u16, u16, u16) { let a = rng.gen(); let b = rng.gen(); - let c = value - a - b; + let c = value.wrapping_sub(a).wrapping_sub(b); (a, b, c) } @@ -101,7 +101,10 @@ mod buckets_test { let mut count = 0; for (c, m) in code_input.iter().cloned().zip(mask_input.iter().cloned()) { - let r = ((m as u64) * a - ((c as u64) << B_BITS) - 1) % mod_; + let r = (((m as u64) * a) + .wrapping_sub((c as u64) << B_BITS) + .wrapping_sub(1)) + % mod_; let msb = r >> (B_BITS + 16 - 1) & 1 == 1; count += msb as u32; } diff --git a/iris-mpc-gpu/tests/extract_msb_mod.rs b/iris-mpc-gpu/tests/extract_msb_mod.rs index fb0653e86..c21b0eb1e 100644 --- a/iris-mpc-gpu/tests/extract_msb_mod.rs +++ b/iris-mpc-gpu/tests/extract_msb_mod.rs @@ -38,7 +38,7 @@ mod extract_msb_mod_test { let mut x = rng.gen_range::(0..=IrisCodeArray::IRIS_CODE_SIZE as u16); let neg = rng.gen::(); if neg { - x = u16::MAX - x + 1; + x = (u16::MAX - x).wrapping_add(1); } x }) @@ -48,7 +48,7 @@ mod extract_msb_mod_test { fn rep_share(value: u16, rng: &mut R) -> (u16, u16, u16) { let a = rng.gen(); let b = rng.gen(); - let c = value - a - b; + let c = value.wrapping_sub(a).wrapping_sub(b); (a, b, c) } diff --git a/iris-mpc-gpu/tests/lift.rs b/iris-mpc-gpu/tests/lift.rs index f58e60837..2c83bab6d 100644 --- a/iris-mpc-gpu/tests/lift.rs +++ b/iris-mpc-gpu/tests/lift.rs @@ -38,7 +38,7 @@ mod lift_test { fn rep_share(value: u16, rng: &mut R) -> (u16, u16, u16) { let a = rng.gen(); let b = rng.gen(); - let c = value - a - b; + let c= value.wrapping_sub(a).wrapping_sub(b); (a, b, c) } diff --git a/iris-mpc-gpu/tests/one_bucket.rs b/iris-mpc-gpu/tests/one_bucket.rs index d49656634..c4bbf1151 100644 --- a/iris-mpc-gpu/tests/one_bucket.rs +++ b/iris-mpc-gpu/tests/one_bucket.rs @@ -31,7 +31,7 @@ mod one_bucket_test { let mut x = rng.gen_range::(0..=IrisCodeArray::IRIS_CODE_SIZE as u16); let neg = rng.gen::(); if neg { - x = u16::MAX - x + 1; + x = (u16::MAX - x).wrapping_add(1); } x }) @@ -47,7 +47,7 @@ mod one_bucket_test { fn rep_share(value: u16, rng: &mut R) -> (u16, u16, u16) { let a = rng.gen(); let b = rng.gen(); - let c = value - a - b; + let c = value.wrapping_sub(a).wrapping_sub(b); (a, b, c) } @@ -94,7 +94,10 @@ mod one_bucket_test { let mod_ = 1u64 << (16 + B_BITS); let mut count = 0; for (c, m) in code_input.into_iter().zip(mask_input) { - let r = ((m as u64) * A - ((c as u64) << B_BITS) - 1) % mod_; + let r = (((m as u64) * A) + .wrapping_sub((c as u64) << B_BITS) + .wrapping_sub(1)) + % mod_; let msb = r >> (B_BITS + 16 - 1) & 1 == 1; count += msb as u32; } diff --git a/iris-mpc-gpu/tests/threshold.rs b/iris-mpc-gpu/tests/threshold.rs index fb40c1886..c4393a004 100644 --- a/iris-mpc-gpu/tests/threshold.rs +++ b/iris-mpc-gpu/tests/threshold.rs @@ -32,7 +32,7 @@ mod threshold_test { let mut x = rng.gen_range::(0..=IrisCodeArray::IRIS_CODE_SIZE as u16); let neg = rng.gen::(); if neg { - x = u16::MAX - x + 1; + x = (u16::MAX - x).wrapping_add(1); } x }) @@ -48,7 +48,7 @@ mod threshold_test { fn rep_share(value: u16, rng: &mut R) -> (u16, u16, u16) { let a = rng.gen(); let b = rng.gen(); - let c = value - a - b; + let c = value.wrapping_sub(a).wrapping_sub(b); (a, b, c) } @@ -110,7 +110,10 @@ mod threshold_test { let mod_ = 1u64 << (16 + B_BITS); let mut res = Vec::with_capacity(code_input.len()); for (c, m) in code_input.into_iter().zip(mask_input) { - let r = ((m as u64) * A - ((c as u64) << B_BITS) - 1) % mod_; + let r = (((m as u64) * A) + .wrapping_sub((c as u64) << B_BITS) + .wrapping_sub(1)) + % mod_; let msb = r >> (B_BITS + 16 - 1) & 1 == 1; res.push(msb) } diff --git a/iris-mpc-gpu/tests/threshold_and_or_tree.rs b/iris-mpc-gpu/tests/threshold_and_or_tree.rs index 59ee1addf..03ccef420 100644 --- a/iris-mpc-gpu/tests/threshold_and_or_tree.rs +++ b/iris-mpc-gpu/tests/threshold_and_or_tree.rs @@ -30,7 +30,7 @@ mod test_threshold_and_or_tree_test { let mut x = rng.gen_range::(0..=IrisCodeArray::IRIS_CODE_SIZE as u16); let neg = rng.gen::(); if neg { - x = u16::MAX - x + 1; + x = (u16::MAX - x).wrapping_add(1); } x }) @@ -46,7 +46,7 @@ mod test_threshold_and_or_tree_test { fn rep_share(value: u16, rng: &mut R) -> (u16, u16, u16) { let a = rng.gen(); let b = rng.gen(); - let c = value - a - b; + let c = value.wrapping_sub(a).wrapping_sub(b); (a, b, c) } @@ -93,7 +93,10 @@ mod test_threshold_and_or_tree_test { let mod_ = 1u64 << (16 + B_BITS); let mut res = false; for (c, m) in code_input.into_iter().zip(mask_input) { - let r = ((m as u64) * A - ((c as u64) << B_BITS) - 1) % mod_; + let r = (((m as u64) * A) + .wrapping_sub((c as u64) << B_BITS) + .wrapping_sub(1)) + % mod_; let msb = r >> (B_BITS + 16 - 1) & 1 == 1; res |= msb; }