Skip to content

Commit

Permalink
Fix iris shares JSON to match orb output
Browse files Browse the repository at this point in the history
  • Loading branch information
danielle-tfh committed Sep 24, 2024
1 parent b90b0e8 commit 6d1369c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 45 deletions.
34 changes: 17 additions & 17 deletions iris-mpc-common/src/bin/shares_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ struct IrisCodeSharesJson {
iris_version: String,
#[serde(rename = "IRIS_shares_version")]
iris_shares_version: String,
left_iris_code_share: String,
left_mask_code_share: String,
right_iris_code_share: String,
right_mask_code_share: String,
left_iris_code_shares: String,
left_mask_code_shares: String,
right_iris_code_shares: String,
right_mask_code_shares: String,
}

/// Iris code shares.
Expand Down Expand Up @@ -109,12 +109,12 @@ fn main() {
.enumerate()
{
let iris_code_shares = IrisCodeSharesJson {
iris_version: IRIS_VERSION.to_string(),
iris_shares_version: IRIS_MPC_VERSION.to_string(),
left_iris_code_share: li.clone(),
left_mask_code_share: lm.clone(),
right_iris_code_share: ri.clone(),
right_mask_code_share: rm.clone(),
iris_version: IRIS_VERSION.to_string(),
iris_shares_version: IRIS_MPC_VERSION.to_string(),
left_iris_code_shares: li.clone(),
left_mask_code_shares: lm.clone(),
right_iris_code_shares: ri.clone(),
right_mask_code_shares: rm.clone(),
};
let json_u8 = serde_json::to_string(&SerializeWithSortedKeys(&iris_code_shares))
.unwrap()
Expand Down Expand Up @@ -144,15 +144,15 @@ mod tests {
#[test]
fn test_iris_code_shares_json() {
let iris_code_shares = IrisCodeSharesJson {
iris_version: IRIS_VERSION.to_string(),
iris_shares_version: IRIS_MPC_VERSION.to_string(),
left_iris_code_share: "left_iris_code_share".to_string(),
left_mask_code_share: "left_mask_code_share".to_string(),
right_iris_code_share: "right_iris_code_share".to_string(),
right_mask_code_share: "right_mask_code_share".to_string(),
iris_version: IRIS_VERSION.to_string(),
iris_shares_version: IRIS_MPC_VERSION.to_string(),
left_iris_code_shares: "left_iris_code_shares".to_string(),
left_mask_code_shares: "left_mask_code_shares".to_string(),
right_iris_code_shares: "right_iris_code_shares".to_string(),
right_mask_code_shares: "right_mask_code_shares".to_string(),
};

let expected = r#"{"IRIS_shares_version":"1.0","IRIS_version":"1.1","left_iris_code_share":"left_iris_code_share","left_mask_code_share":"left_mask_code_share","right_iris_code_share":"right_iris_code_share","right_mask_code_share":"right_mask_code_share"}"#;
let expected = r#"{"IRIS_shares_version":"1.0","IRIS_version":"1.1","left_iris_code_shares":"left_iris_code_shares","left_mask_code_shares":"left_mask_code_shares","right_iris_code_shares":"right_iris_code_shares","right_mask_code_shares":"right_mask_code_shares"}"#;
assert_eq!(
serde_json::to_string(&SerializeWithSortedKeys(&iris_code_shares)).unwrap(),
expected
Expand Down
12 changes: 6 additions & 6 deletions iris-mpc-common/src/helpers/smpc_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ pub struct SharesS3Object {
#[derive(PartialEq, Serialize, Deserialize, Debug, Clone)]
pub struct IrisCodesJSON {
#[serde(rename = "IRIS_version")]
pub iris_version: String,
pub iris_version: String,
#[serde(rename = "IRIS_shares_version")]
pub iris_shares_version: String,
pub left_iris_code_share: String, // these are base64 encoded strings
pub right_iris_code_share: String, // these are base64 encoded strings
pub left_mask_code_share: String, // these are base64 encoded strings
pub right_mask_code_share: String, // these are base64 encoded strings
pub iris_shares_version: String,
pub left_iris_code_shares: String, // these are base64 encoded strings
pub right_iris_code_shares: String, // these are base64 encoded strings
pub left_mask_code_shares: String, // these are base64 encoded strings
pub right_mask_code_shares: String, // these are base64 encoded strings
}

impl SharesS3Object {
Expand Down
24 changes: 12 additions & 12 deletions iris-mpc-common/tests/smpc_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ mod tests {

fn mock_iris_codes_json() -> IrisCodesJSON {
IrisCodesJSON {
iris_version: "1.0".to_string(),
iris_shares_version: "1.3".to_string(),
left_iris_code_share: STANDARD.encode("left_iris_code_mock"),
right_iris_code_share: STANDARD.encode("right_iris_code_mock"),
left_mask_code_share: STANDARD.encode("left_iris_mask_mock"),
right_mask_code_share: STANDARD.encode("right_iris_mask_mock"),
iris_version: "1.0".to_string(),
iris_shares_version: "1.3".to_string(),
left_iris_code_shares: STANDARD.encode("left_iris_code_mock"),
right_iris_code_shares: STANDARD.encode("right_iris_code_mock"),
left_mask_code_shares: STANDARD.encode("left_iris_mask_mock"),
right_mask_code_shares: STANDARD.encode("right_iris_mask_mock"),
}
}

Expand Down Expand Up @@ -103,12 +103,12 @@ mod tests {
async fn test_decrypt_iris_share_success() {
// Mocked base64 encoded JSON string
let iris_codes_json = IrisCodesJSON {
iris_version: "1.0".to_string(),
iris_shares_version: "1.3".to_string(),
left_iris_code_share: "left_code".to_string(),
right_iris_code_share: "right_code".to_string(),
left_mask_code_share: "left_mask".to_string(),
right_mask_code_share: "right_mask".to_string(),
iris_version: "1.0".to_string(),
iris_shares_version: "1.3".to_string(),
left_iris_code_shares: "left_code".to_string(),
right_iris_code_shares: "right_code".to_string(),
left_mask_code_shares: "left_mask".to_string(),
right_mask_code_shares: "right_mask".to_string(),
};

let decoded_public_key = STANDARD.decode(CURRENT_PUBLIC_KEY.as_bytes()).unwrap();
Expand Down
12 changes: 6 additions & 6 deletions iris-mpc/src/bin/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,12 @@ async fn main() -> eyre::Result<()> {

for i in 0..3 {
let iris_codes_json = IrisCodesJSON {
iris_version: "1.0".to_string(),
iris_shares_version: "1.3".to_string(),
right_iris_code_share: shared_code[i].to_base64(),
right_mask_code_share: shared_mask[i].to_base64(),
left_iris_code_share: shared_code[i].to_base64(),
left_mask_code_share: shared_mask[i].to_base64(),
iris_version: "1.0".to_string(),
iris_shares_version: "1.3".to_string(),
right_iris_code_shares: shared_code[i].to_base64(),
right_mask_code_shares: shared_mask[i].to_base64(),
left_iris_code_shares: shared_code[i].to_base64(),
left_mask_code_shares: shared_mask[i].to_base64(),
};
let serialized_iris_codes_json = to_string(&iris_codes_json)
.expect("Serialization failed")
Expand Down
8 changes: 4 additions & 4 deletions iris-mpc/src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,13 @@ async fn receive_batch(
}

let (left_code, left_mask) = decode_iris_message_shares(
iris_message_share.left_iris_code_share,
iris_message_share.left_mask_code_share,
iris_message_share.left_iris_code_shares,
iris_message_share.left_mask_code_shares,
)?;

let (right_code, right_mask) = decode_iris_message_shares(
iris_message_share.right_iris_code_share,
iris_message_share.right_mask_code_share,
iris_message_share.right_iris_code_shares,
iris_message_share.right_mask_code_shares,
)?;

// Preprocess shares for left eye.
Expand Down

0 comments on commit 6d1369c

Please sign in to comment.