diff --git a/iris-mpc-common/Cargo.toml b/iris-mpc-common/Cargo.toml index 3be0d57ec..383cda00a 100644 --- a/iris-mpc-common/Cargo.toml +++ b/iris-mpc-common/Cargo.toml @@ -5,37 +5,37 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config.workspace = true -aws-sdk-kms.workspace = true -aws-sdk-sns.workspace = true -aws-sdk-s3.workspace = true -aws-sdk-secretsmanager.workspace = true -clap.workspace = true -rand.workspace = true -bytemuck.workspace = true -eyre.workspace = true +aws-config = { version = "1.5.4", features = ["behavior-version-latest"] } +aws-sdk-kms = { version = "1.37.0" } +aws-sdk-sns = { version = "1.37.0" } +aws-sdk-s3 = { version = "1.42.0" } +aws-sdk-secretsmanager = { version = "1.41.0" } +clap = { version = "4", features = ["derive", "env"] } +rand = "0.8" +bytemuck = "1.17" +eyre = "0.6" thiserror = "1" -rayon.workspace = true -itertools.workspace = true -base64.workspace = true -serde.workspace = true -serde_json.workspace = true +rayon = "1.5.1" +itertools = "0.13" +base64 = "0.22.1" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1" config = "0.14.0" -tokio.workspace = true -tracing.workspace = true -tracing-subscriber.workspace = true +tokio = { version = "1.39", features = ["full", "rt-multi-thread"] } +tracing = "0.1.40" +tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } -reqwest = { workspace = true, features = ["blocking", "json"] } +reqwest = { version = "0.12", features = ["blocking", "json"] } sodiumoxide = "0.2.7" hmac = "0.12" http = "1.1.0" opentelemetry = "0.21.0" -telemetry-batteries.workspace = true +telemetry-batteries = { git = "https://github.com/worldcoin/telemetry-batteries.git", rev = "802a4f39f358e077b11c8429b4c65f3e45b85959" } percent-encoding = "2" sha2 = "0.10" time = { version = "^0.3.6", features = ["formatting", "macros"] } url = "2" -hex.workspace = true +hex = "0.4.3" zeroize = "1.8.1" wiremock = "0.6.1" digest = "0.10.7" diff --git a/iris-mpc-common/src/galois_engine.rs b/iris-mpc-common/src/galois_engine.rs index c76b03d2e..7e75f33ef 100644 --- a/iris-mpc-common/src/galois_engine.rs +++ b/iris-mpc-common/src/galois_engine.rs @@ -238,10 +238,13 @@ pub mod degree4 { }; use base64::{prelude::BASE64_STANDARD, Engine}; use rand::{CryptoRng, Rng}; + use serde::{Deserialize, Serialize}; + use serde_big_array::BigArray; - #[derive(Debug, Clone, PartialEq, Eq, Hash)] + #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct GaloisRingIrisCodeShare { pub id: usize, + #[serde(with = "BigArray")] pub coefs: [u16; IRIS_CODE_LENGTH], } @@ -457,13 +460,13 @@ pub mod degree4 { } pub fn to_base64(&self) -> String { - BASE64_STANDARD.encode(bytemuck::cast_slice(&self.coefs)) + let as_vec_u8 = bincode::serialize(&self).expect("to serialize"); + BASE64_STANDARD.encode::>(as_vec_u8) } - pub fn from_base64(id: usize, s: &str) -> eyre::Result { - let mut coefs = [0u16; IRIS_CODE_LENGTH]; - BASE64_STANDARD.decode_slice(s, bytemuck::cast_slice_mut(&mut coefs))?; - Ok(Self::new(id, coefs)) + pub fn from_base64(s: &str) -> eyre::Result { + let decoded_bytes = BASE64_STANDARD.decode(s)?; + Ok(bincode::deserialize(&decoded_bytes)?) } } @@ -598,7 +601,7 @@ pub mod degree4 { let shares = GaloisRingIrisCodeShare::encode_mask_code(&code, &mut rng); for i in 0..3 { let s = shares[i].to_base64(); - let decoded = GaloisRingIrisCodeShare::from_base64(i + 1, &s).unwrap(); + let decoded = GaloisRingIrisCodeShare::from_base64(&s).unwrap(); assert_eq!(shares[i].coefs, decoded.coefs); } } diff --git a/iris-mpc/src/bin/server.rs b/iris-mpc/src/bin/server.rs index 6984603ed..402c82cab 100644 --- a/iris-mpc/src/bin/server.rs +++ b/iris-mpc/src/bin/server.rs @@ -63,7 +63,6 @@ static CURRENT_BATCH_SIZE: LazyLock> = LazyLock::new(|| Mutex::new( #[allow(clippy::type_complexity)] fn preprocess_iris_message_shares( - party_id: usize, code_shares: String, mask_shares: String, ) -> eyre::Result<( @@ -74,9 +73,9 @@ fn preprocess_iris_message_shares( Vec, Vec, )> { - let mut iris_share = GaloisRingIrisCodeShare::from_base64(party_id + 1, &code_shares) + let mut iris_share = GaloisRingIrisCodeShare::from_base64(&code_shares) .context("Failed to base64 parse iris code")?; - let mut mask_share = GaloisRingIrisCodeShare::from_base64(party_id + 1, &mask_shares) + let mut mask_share = GaloisRingIrisCodeShare::from_base64(&mask_shares) .context("Failed to base64 parse iris mask")?; // Original for storage. @@ -204,7 +203,6 @@ async fn receive_batch( // Preprocess shares for left eye. let left_future = spawn_blocking(move || { preprocess_iris_message_shares( - party_id, iris_message_share.left_iris_code_shares, iris_message_share.left_iris_mask_shares, ) @@ -213,7 +211,6 @@ async fn receive_batch( // Preprocess shares for right eye. let right_future = spawn_blocking(move || { preprocess_iris_message_shares( - party_id, iris_message_share.right_iris_code_shares, iris_message_share.right_iris_mask_shares, )