Skip to content

Commit

Permalink
Upgrade to Rust 1.85 (#1526)
Browse files Browse the repository at this point in the history
* Upgrade to Rust 1.85

* Fix nightly lints

* Remove another redundant into_iter call
  • Loading branch information
akoshelev authored Mar 1, 2025
1 parent cb7a54e commit ec55a8e
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 28 deletions.
2 changes: 1 addition & 1 deletion ipa-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = "0.1.0"
# rust:slim-bullseye docker image is available.
# 2. Update the rust version used for draft in
# https://github.com/private-attribution/draft/blob/main/sidecar/ansible/provision.yaml.
rust-version = "1.84.0"
rust-version = "1.85.0"
edition = "2021"
build = "build.rs"

Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/ff/galois_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn clmul<GF: GaloisField>(a: GF, b: GF) -> u128 {
let a = u128::from(a);
let mut product = 0;
for i in 0..GF::BITS {
let bit = u128::from(b >> i & 1);
let bit = u128::from((b >> i) & 1);
product ^= bit * (a << i);
}
product
Expand Down
16 changes: 4 additions & 12 deletions ipa-core/src/helpers/buffers/circular.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,7 @@ mod test {
assert!(buf.can_read());

while buf.can_read() {
output.extend(
CircularBuf::read_once(&mut buf)
.into_iter()
.map(usize::from),
);
output.extend(CircularBuf::read_once(&mut buf));
}

assert!(buf.can_write());
Expand All @@ -478,11 +474,7 @@ mod test {
}

assert!(buf.can_write());
output.extend(
CircularBuf::read_once(&mut buf)
.into_iter()
.map(usize::from),
);
output.extend(CircularBuf::read_once(&mut buf));

assert!(buf.is_empty());
assert_eq!(input, output);
Expand Down Expand Up @@ -521,14 +513,14 @@ mod test {
Six::fill(&mut buf);

let mut output = Vec::new();
output.extend(Six::read_once(&mut buf).into_iter().map(usize::from));
output.extend(Six::read_once(&mut buf));
buf.next().write(&TwoBytes::from(&6));
buf.next().write(&TwoBytes::from(&7));
assert!(!buf.is_closed());
buf.close();
assert!(buf.is_closed());

output.extend(Six::read_once(&mut buf).into_iter().map(usize::from));
output.extend(Six::read_once(&mut buf));

assert_eq!((0..8).collect::<Vec<_>>(), output);
}
Expand Down
2 changes: 0 additions & 2 deletions ipa-core/src/hpke/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,12 @@ impl KeyRegistry<KeyPair> {
}

impl PrivateKeyRegistry for KeyRegistry<KeyPair> {
#[must_use]
fn private_key(&self, key_id: KeyIdentifier) -> Option<&IpaPrivateKey> {
self.key(key_id).map(|v| &v.sk)
}
}

impl PrivateKeyRegistry for KeyRegistry<PrivateKeyOnly> {
#[must_use]
fn private_key(&self, key_id: KeyIdentifier) -> Option<&IpaPrivateKey> {
self.key(key_id).map(|sk| &**sk)
}
Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/protocol/context/dzkp_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ pub mod tests {
let bit0 = (b0 >> j) & 1_u128;
let bit1 = (b1 >> j) & 1_u128;
let bit2 = (b2 >> j) & 1_u128;
let expected = bit2 << 2 | bit1 << 1 | bit0;
let expected = (bit2 << 2) | (bit1 << 1) | bit0;
let actual = (z >> i) & 0xf;
assert_eq!(
actual, expected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ mod test {
let y = y_ba64.as_u128();

let expected = (x + y) % (1 << 64);
let expected_carry = (x + y) >> 64 & 1;
let expected_carry = ((x + y) >> 64) & 1;

let (result, carry) = world
.dzkp_semi_honest((x_ba64, y_ba64), |ctx, x_y| async move {
Expand Down Expand Up @@ -266,7 +266,7 @@ mod test {
let y = y_ba32.as_u128();

let expected = (x + y) % (1 << 64);
let expected_carry = (x + y) >> 64 & 1;
let expected_carry = ((x + y) >> 64) & 1;

let (result, carry) = world
.dzkp_semi_honest((x_ba64, y_ba32), |ctx, x_y| async move {
Expand All @@ -288,7 +288,7 @@ mod test {

let x = x & ((1 << 32) - 1);
let expected = (x + y) % (1 << 32);
let expected_carry = (x + y) >> 32 & 1;
let expected_carry = ((x + y) >> 32) & 1;
let (result, carry) = world
.dzkp_semi_honest((y_ba32, x_ba64), |ctx, x_y| async move {
integer_add::<_, DefaultBitStep, 1>(
Expand Down
16 changes: 8 additions & 8 deletions ipa-core/src/secret_sharing/vector/transpose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ pub fn transpose_8x8<B: Borrow<[u8; 8]>>(x: B) -> [u8; 8] {
let mut x = u64::from_le_bytes(*x.borrow());

x = x & 0xaa55_aa55_aa55_aa55
| (x & 0x00aa_00aa_00aa_00aa) << 7
| ((x & 0x00aa_00aa_00aa_00aa) << 7)
| (x >> 7) & 0x00aa_00aa_00aa_00aa;

x = x & 0xcccc_3333_cccc_3333
| (x & 0x0000_cccc_0000_cccc) << 14
| ((x & 0x0000_cccc_0000_cccc) << 14)
| (x >> 14) & 0x0000_cccc_0000_cccc;

x = x & 0xf0f0_f0f0_0f0f_0f0f
| (x & 0x0000_0000_f0f0_f0f0) << 28
| ((x & 0x0000_0000_f0f0_f0f0) << 28)
| (x >> 28) & 0x0000_0000_f0f0_f0f0;

x.to_le_bytes()
Expand All @@ -138,11 +138,11 @@ pub fn transpose_16x16(src: &[u8; 32]) -> [u8; 32] {
let s1 = 30;
for i in 0..4 {
y0[i] = x[i] & 0xaaaa_5555_aaaa_5555
| (x[i] & 0x0000_aaaa_0000_aaaa) << s0
| ((x[i] & 0x0000_aaaa_0000_aaaa) << s0)
| (x[i] >> s0) & 0x0000_aaaa_0000_aaaa;

y1[i] = y0[i] & 0xcccc_cccc_3333_3333
| (y0[i] & 0x0000_0000_cccc_cccc) << s1
| ((y0[i] & 0x0000_0000_cccc_cccc) << s1)
| (y0[i] >> s1) & 0x0000_0000_cccc_cccc;
}

Expand All @@ -158,15 +158,15 @@ pub fn transpose_16x16(src: &[u8; 32]) -> [u8; 32] {
let s2 = 4;
let mut y2 = [0u64; 4];
for i in 0..4 {
y2[i] = y1[i] & m2a[i] | (y1_swp[i] << s2) & m2b[i] | (y1_swp[i] & m2c[i]) >> s2;
y2[i] = y1[i] & m2a[i] | (y1_swp[i] << s2) & m2b[i] | ((y1_swp[i] & m2c[i]) >> s2);
}

let mut y3 = [0u64; 4];
for i in 0..2 {
y3[i] = y2[i] & 0x00ff_00ff_00ff_00ff | (y2[i + 2] & 0x00ff_00ff_00ff_00ff) << 8;
y3[i] = y2[i] & 0x00ff_00ff_00ff_00ff | ((y2[i + 2] & 0x00ff_00ff_00ff_00ff) << 8);
}
for i in 0..2 {
y3[i + 2] = (y2[i] & 0xff00_ff00_ff00_ff00) >> 8 | y2[i + 2] & 0xff00_ff00_ff00_ff00;
y3[i + 2] = ((y2[i] & 0xff00_ff00_ff00_ff00) >> 8) | y2[i + 2] & 0xff00_ff00_ff00_ff00;
}

let mut dst = [0u8; 32];
Expand Down

0 comments on commit ec55a8e

Please sign in to comment.