From 5a44e674b8b08f6d8c58d7a8807248f1a54b2efc Mon Sep 17 00:00:00 2001 From: danielle-tfh Date: Tue, 24 Sep 2024 16:54:29 +0200 Subject: [PATCH] Fix iris shares JSON --- iris-mpc-common/src/bin/shares_encoding.rs | 26 ++++++++++----------- iris-mpc-common/src/helpers/smpc_request.rs | 10 ++++---- iris-mpc-common/tests/smpc_request.rs | 18 +++++++------- iris-mpc/src/bin/client.rs | 9 +++---- 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/iris-mpc-common/src/bin/shares_encoding.rs b/iris-mpc-common/src/bin/shares_encoding.rs index 9484e7971..5357a5e15 100644 --- a/iris-mpc-common/src/bin/shares_encoding.rs +++ b/iris-mpc-common/src/bin/shares_encoding.rs @@ -34,10 +34,10 @@ struct IrisCodeSharesJson { iris_version: String, #[serde(rename = "IRIS_shares_version")] iris_shares_version: String, - left_iris_code_shares: String, - left_iris_mask_shares: String, - right_iris_code_shares: String, - right_iris_mask_shares: String, + left_iris_code_share: String, + left_mask_code_share: String, + right_iris_code_share: String, + right_mask_code_share: String, } /// Iris code shares. @@ -111,10 +111,10 @@ fn main() { let iris_code_shares = IrisCodeSharesJson { iris_version: IRIS_VERSION.to_string(), iris_shares_version: IRIS_MPC_VERSION.to_string(), - left_iris_code_shares: li.clone(), - left_iris_mask_shares: lm.clone(), - right_iris_code_shares: ri.clone(), - right_iris_mask_shares: rm.clone(), + left_iris_code_share: li.clone(), + left_mask_code_share: lm.clone(), + right_iris_code_share: ri.clone(), + right_mask_code_share: rm.clone(), }; let json_u8 = serde_json::to_string(&SerializeWithSortedKeys(&iris_code_shares)) .unwrap() @@ -146,13 +146,13 @@ mod tests { let iris_code_shares = IrisCodeSharesJson { 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_iris_mask_shares: "left_iris_mask_shares".to_string(), - right_iris_code_shares: "right_iris_code_shares".to_string(), - right_iris_mask_shares: "right_iris_mask_shares".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(), }; - let expected = r#"{"IRIS_shares_version":"1.0","IRIS_version":"1.1","left_iris_code_shares":"left_iris_code_shares","left_iris_mask_shares":"left_iris_mask_shares","right_iris_code_shares":"right_iris_code_shares","right_iris_mask_shares":"right_iris_mask_shares"}"#; + 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_iris_mask_share","right_iris_code_share":"right_iris_code_share","right_mask_code_share":"right_mask_code_share"}"#; assert_eq!( serde_json::to_string(&SerializeWithSortedKeys(&iris_code_shares)).unwrap(), expected diff --git a/iris-mpc-common/src/helpers/smpc_request.rs b/iris-mpc-common/src/helpers/smpc_request.rs index 199bb2f42..d90dca213 100644 --- a/iris-mpc-common/src/helpers/smpc_request.rs +++ b/iris-mpc-common/src/helpers/smpc_request.rs @@ -172,10 +172,12 @@ pub struct SharesS3Object { pub struct IrisCodesJSON { #[serde(rename = "IRIS_version")] pub iris_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_iris_mask_shares: String, // these are base64 encoded strings - pub right_iris_mask_shares: String, // these are base64 encoded strings + #[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 } impl SharesS3Object { diff --git a/iris-mpc-common/tests/smpc_request.rs b/iris-mpc-common/tests/smpc_request.rs index ab0f12090..be3cf3f7f 100644 --- a/iris-mpc-common/tests/smpc_request.rs +++ b/iris-mpc-common/tests/smpc_request.rs @@ -33,10 +33,11 @@ mod tests { fn mock_iris_codes_json() -> IrisCodesJSON { IrisCodesJSON { iris_version: "1.0".to_string(), - left_iris_code_shares: STANDARD.encode("left_iris_code_mock"), - right_iris_code_shares: STANDARD.encode("right_iris_code_mock"), - left_iris_mask_shares: STANDARD.encode("left_iris_mask_mock"), - right_iris_mask_shares: STANDARD.encode("right_iris_mask_mock"), + 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"), } } @@ -103,10 +104,11 @@ mod tests { // Mocked base64 encoded JSON string let iris_codes_json = IrisCodesJSON { iris_version: "1.0".to_string(), - left_iris_code_shares: "left_code".to_string(), - right_iris_code_shares: "right_code".to_string(), - left_iris_mask_shares: "left_mask".to_string(), - right_iris_mask_shares: "right_mask".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(), }; let decoded_public_key = STANDARD.decode(CURRENT_PUBLIC_KEY.as_bytes()).unwrap(); diff --git a/iris-mpc/src/bin/client.rs b/iris-mpc/src/bin/client.rs index 783692802..b9caf20ae 100644 --- a/iris-mpc/src/bin/client.rs +++ b/iris-mpc/src/bin/client.rs @@ -330,10 +330,11 @@ async fn main() -> eyre::Result<()> { for i in 0..3 { let iris_codes_json = IrisCodesJSON { iris_version: "1.0".to_string(), - right_iris_code_shares: shared_code[i].to_base64(), - right_iris_mask_shares: shared_mask[i].to_base64(), - left_iris_code_shares: shared_code[i].to_base64(), - left_iris_mask_shares: shared_mask[i].to_base64(), + 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(), }; let serialized_iris_codes_json = to_string(&iris_codes_json) .expect("Serialization failed")