Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNM] Remove Cargo workspace as Nix doesn't support it 2 #288

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions iris-mpc-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 10 additions & 7 deletions iris-mpc-common/src/galois_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
}

Expand Down Expand Up @@ -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::<Vec<u8>>(as_vec_u8)
}

pub fn from_base64(id: usize, s: &str) -> eyre::Result<Self> {
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<Self> {
let decoded_bytes = BASE64_STANDARD.decode(s)?;
Ok(bincode::deserialize(&decoded_bytes)?)
}
}

Expand Down Expand Up @@ -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);
}
}
Expand Down
7 changes: 2 additions & 5 deletions iris-mpc/src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static CURRENT_BATCH_SIZE: LazyLock<Mutex<usize>> = LazyLock::new(|| Mutex::new(

#[allow(clippy::type_complexity)]
fn preprocess_iris_message_shares(
party_id: usize,
code_shares: String,
mask_shares: String,
) -> eyre::Result<(
Expand All @@ -74,9 +73,9 @@ fn preprocess_iris_message_shares(
Vec<GaloisRingIrisCodeShare>,
Vec<GaloisRingIrisCodeShare>,
)> {
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.
Expand Down Expand Up @@ -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,
)
Expand All @@ -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,
)
Expand Down
Loading