From 2880595651da546eea5069e2baca25b377944901 Mon Sep 17 00:00:00 2001 From: Anastasios Andronidis Date: Fri, 27 Sep 2024 16:47:59 +0200 Subject: [PATCH] orb-qr-link: Support UUID for orb-relay comms (#243) --- orb-qr-link/src/lib.rs | 2 ++ orb-qr-link/src/user_data.rs | 9 +++++++++ orb-qr-link/tests/verification.rs | 1 + 3 files changed, 12 insertions(+) diff --git a/orb-qr-link/src/lib.rs b/orb-qr-link/src/lib.rs index 9bbed6a6..165469ed 100644 --- a/orb-qr-link/src/lib.rs +++ b/orb-qr-link/src/lib.rs @@ -30,6 +30,7 @@ //! data_policy: DataPolicy::OptOut, //! pcp_version: 2, //! user_centric_signup: true, +//! orb_relay_app_id: Some("123123".to_string()), //! }; //! //! // Upload `user_data` to the backend by the `session_id` key. @@ -64,6 +65,7 @@ //! data_policy: DataPolicy::OptOut, //! pcp_version: 2, //! user_centric_signup: true, +//! orb_relay_app_id: Some("123123".to_string()), //! }; //! //! // Verify that the `user_data_hash` from the QR-code matches `user_data` diff --git a/orb-qr-link/src/user_data.rs b/orb-qr-link/src/user_data.rs index 1a3e32b4..c5b78125 100644 --- a/orb-qr-link/src/user_data.rs +++ b/orb-qr-link/src/user_data.rs @@ -3,6 +3,9 @@ use serde::{Deserialize, Serialize}; const PCP_VERSION_DEFAULT: u16 = 2; +// TODO(andronat): Some of these flags and types should be refactored (e.g. delete `user_centric_signup`) after both Orb +// and Worldcoin App are rolled out with their latest versions. + /// User's data to transfer from Worldcoin App to Orb. #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "camelCase")] @@ -19,6 +22,8 @@ pub struct UserData { /// Whether the orb should perform a app-centric signup. #[serde(default = "default_false")] pub user_centric_signup: bool, + /// A unique UUID that the Orb will use to send messages to the app through Orb Relay. + pub orb_relay_app_id: Option, } /// User's biometric data policy. Part of [`UserData`]. @@ -61,6 +66,7 @@ impl UserData { data_policy, pcp_version, user_centric_signup, + orb_relay_app_id, } = self; hasher.update(identity_commitment.as_bytes()); hasher.update(self_custody_public_key.as_bytes()); @@ -71,6 +77,9 @@ impl UserData { if *user_centric_signup { hasher.update(&[true as u8]); } + if let Some(app_id) = orb_relay_app_id { + hasher.update(app_id.as_bytes()); + } } } diff --git a/orb-qr-link/tests/verification.rs b/orb-qr-link/tests/verification.rs index bc220732..94e15d71 100644 --- a/orb-qr-link/tests/verification.rs +++ b/orb-qr-link/tests/verification.rs @@ -14,6 +14,7 @@ MCowBQYDK2VuAyEA2boNBmJX4lGkA9kjthS5crXOBxu2BPycKRMakpzgLG4= data_policy: DataPolicy::OptOut, pcp_version: 3, user_centric_signup: true, + orb_relay_app_id: Some("123123".to_string()), }; let qr = encode_qr(&session_id, user_data.hash(16)); let (parsed_session_id, parsed_user_data_hash) = decode_qr(&qr).unwrap();