From 1cf5fd1c96355f22d4e881145d50ba086a9070ce Mon Sep 17 00:00:00 2001 From: Anastasios Andronidis Date: Wed, 14 Aug 2024 14:38:10 +0300 Subject: [PATCH] orb-qr-link: Signal user-centric signups (#185) Signal app-centric signups --- Cargo.lock | 2 +- orb-qr-link/Cargo.toml | 2 +- orb-qr-link/src/lib.rs | 4 +++- orb-qr-link/src/user_data.rs | 11 +++++++++++ orb-qr-link/tests/verification.rs | 1 + 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b5879383..cc5aed86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3069,7 +3069,7 @@ dependencies = [ [[package]] name = "orb-qr-link" -version = "0.0.4" +version = "0.0.5" dependencies = [ "blake3", "data-encoding", diff --git a/orb-qr-link/Cargo.toml b/orb-qr-link/Cargo.toml index a8467430..c4a12ec6 100644 --- a/orb-qr-link/Cargo.toml +++ b/orb-qr-link/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orb-qr-link" -version = "0.0.4" +version = "0.0.5" description = "Data link between Worldcoin App and Orb through QR-codes" authors = ["Valentyn Valiaiev "] publish = false diff --git a/orb-qr-link/src/lib.rs b/orb-qr-link/src/lib.rs index 9156cb9a..9bbed6a6 100644 --- a/orb-qr-link/src/lib.rs +++ b/orb-qr-link/src/lib.rs @@ -28,7 +28,8 @@ //! identity_commitment: String::new(), //! self_custody_public_key: String::new(), //! data_policy: DataPolicy::OptOut, -//! pcp_version: 2 +//! pcp_version: 2, +//! user_centric_signup: true, //! }; //! //! // Upload `user_data` to the backend by the `session_id` key. @@ -62,6 +63,7 @@ //! self_custody_public_key: String::new(), //! data_policy: DataPolicy::OptOut, //! pcp_version: 2, +//! user_centric_signup: true, //! }; //! //! // 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 2609944d..8de662de 100644 --- a/orb-qr-link/src/user_data.rs +++ b/orb-qr-link/src/user_data.rs @@ -16,6 +16,9 @@ pub struct UserData { /// Personal Custody Package version. #[serde(default = "pcp_version_default")] pub pcp_version: u16, + /// Whether the app should perform a app-centric signup. + #[serde(default = "default_false")] + pub user_centric_signup: bool, } /// User's biometric data policy. Part of [`UserData`]. @@ -57,6 +60,7 @@ impl UserData { self_custody_public_key, data_policy, pcp_version, + user_centric_signup, } = self; hasher.update(identity_commitment.as_bytes()); hasher.update(self_custody_public_key.as_bytes()); @@ -64,6 +68,9 @@ impl UserData { if *pcp_version != PCP_VERSION_DEFAULT { hasher.update(&pcp_version.to_ne_bytes()); } + if *user_centric_signup { + hasher.update(&[true as u8]); + } } } @@ -91,3 +98,7 @@ impl ToString for DataPolicy { const fn pcp_version_default() -> u16 { PCP_VERSION_DEFAULT } + +const fn default_false() -> bool { + false +} diff --git a/orb-qr-link/tests/verification.rs b/orb-qr-link/tests/verification.rs index fec7d44d..bc220732 100644 --- a/orb-qr-link/tests/verification.rs +++ b/orb-qr-link/tests/verification.rs @@ -13,6 +13,7 @@ MCowBQYDK2VuAyEA2boNBmJX4lGkA9kjthS5crXOBxu2BPycKRMakpzgLG4= self_custody_public_key: self_custody_public_key.to_string(), data_policy: DataPolicy::OptOut, pcp_version: 3, + user_centric_signup: true, }; let qr = encode_qr(&session_id, user_data.hash(16)); let (parsed_session_id, parsed_user_data_hash) = decode_qr(&qr).unwrap();