From 27ce74f319d355eff8eec8c07bdc67ed81760760 Mon Sep 17 00:00:00 2001 From: Bassam Sayed Date: Tue, 10 Dec 2024 16:49:00 -0500 Subject: [PATCH 1/3] Added new boolean field in the UserData struct to enable/disable age verification on the orb. --- qr-link/src/user_data.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qr-link/src/user_data.rs b/qr-link/src/user_data.rs index c5b78125..5a169863 100644 --- a/qr-link/src/user_data.rs +++ b/qr-link/src/user_data.rs @@ -24,6 +24,9 @@ pub struct UserData { 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, + /// Whether the Orb should perform the age verification. + #[serde(default = "default_false")] + pub bypass_age_verification: bool, } /// User's biometric data policy. Part of [`UserData`]. @@ -67,6 +70,7 @@ impl UserData { pcp_version, user_centric_signup, orb_relay_app_id, + bypass_age_verification, } = self; hasher.update(identity_commitment.as_bytes()); hasher.update(self_custody_public_key.as_bytes()); @@ -80,6 +84,9 @@ impl UserData { if let Some(app_id) = orb_relay_app_id { hasher.update(app_id.as_bytes()); } + if *bypass_age_verification { + hasher.update(&[true as u8]); + } } } From ea348ac27a5b0f4afa80f3950919420b9c0d8244 Mon Sep 17 00:00:00 2001 From: Bassam Sayed Date: Tue, 10 Dec 2024 17:04:27 -0500 Subject: [PATCH 2/3] Fixed the unit test. --- qr-link/tests/verification.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/qr-link/tests/verification.rs b/qr-link/tests/verification.rs index 94e15d71..f333a51a 100644 --- a/qr-link/tests/verification.rs +++ b/qr-link/tests/verification.rs @@ -15,6 +15,7 @@ MCowBQYDK2VuAyEA2boNBmJX4lGkA9kjthS5crXOBxu2BPycKRMakpzgLG4= pcp_version: 3, user_centric_signup: true, orb_relay_app_id: Some("123123".to_string()), + bypass_age_verification: false, }; let qr = encode_qr(&session_id, user_data.hash(16)); let (parsed_session_id, parsed_user_data_hash) = decode_qr(&qr).unwrap(); From 068750c7d5b8b2e1fbe7cdf874cd2033748d50ec Mon Sep 17 00:00:00 2001 From: Bassam Sayed Date: Wed, 11 Dec 2024 11:54:19 -0500 Subject: [PATCH 3/3] Changed the data type of the bypass_age_verification to a string based ona request from POP team. --- qr-link/src/lib.rs | 3 +++ qr-link/src/user_data.rs | 11 +++++------ qr-link/tests/verification.rs | 27 +++++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/qr-link/src/lib.rs b/qr-link/src/lib.rs index 165469ed..7d1b7754 100644 --- a/qr-link/src/lib.rs +++ b/qr-link/src/lib.rs @@ -24,6 +24,7 @@ //! //! // Generate a new session id and user data. //! let session_id = Uuid::new_v4(); +//! let sample_jwt_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"; //! let user_data = UserData { //! identity_commitment: String::new(), //! self_custody_public_key: String::new(), @@ -31,6 +32,7 @@ //! pcp_version: 2, //! user_centric_signup: true, //! orb_relay_app_id: Some("123123".to_string()), +//! bypass_age_verification_token: Some(sample_jwt_token.to_string()), //! }; //! //! // Upload `user_data` to the backend by the `session_id` key. @@ -66,6 +68,7 @@ //! pcp_version: 2, //! user_centric_signup: true, //! orb_relay_app_id: Some("123123".to_string()), +//! bypass_age_verification_token: None, //! }; //! //! // Verify that the `user_data_hash` from the QR-code matches `user_data` diff --git a/qr-link/src/user_data.rs b/qr-link/src/user_data.rs index 5a169863..881176e1 100644 --- a/qr-link/src/user_data.rs +++ b/qr-link/src/user_data.rs @@ -24,9 +24,8 @@ pub struct UserData { 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, - /// Whether the Orb should perform the age verification. - #[serde(default = "default_false")] - pub bypass_age_verification: bool, + /// Whether the Orb should perform the age verification. If the token exists we skip the age verification. + pub bypass_age_verification_token: Option, } /// User's biometric data policy. Part of [`UserData`]. @@ -70,7 +69,7 @@ impl UserData { pcp_version, user_centric_signup, orb_relay_app_id, - bypass_age_verification, + bypass_age_verification_token, } = self; hasher.update(identity_commitment.as_bytes()); hasher.update(self_custody_public_key.as_bytes()); @@ -84,8 +83,8 @@ impl UserData { if let Some(app_id) = orb_relay_app_id { hasher.update(app_id.as_bytes()); } - if *bypass_age_verification { - hasher.update(&[true as u8]); + if let Some(age_verification_token) = bypass_age_verification_token { + hasher.update(age_verification_token.as_bytes()); } } } diff --git a/qr-link/tests/verification.rs b/qr-link/tests/verification.rs index f333a51a..afd9bd42 100644 --- a/qr-link/tests/verification.rs +++ b/qr-link/tests/verification.rs @@ -2,7 +2,7 @@ use orb_qr_link::{decode_qr, encode_qr, DataPolicy, UserData}; use uuid::Uuid; #[test] -fn test_encode_decode_verify() { +fn test_encode_decode_verify_without_age_verification_token() { let session_id = Uuid::new_v4(); let self_custody_public_key = r#"-----BEGIN PUBLIC KEY----- MCowBQYDK2VuAyEA2boNBmJX4lGkA9kjthS5crXOBxu2BPycKRMakpzgLG4= @@ -15,7 +15,30 @@ MCowBQYDK2VuAyEA2boNBmJX4lGkA9kjthS5crXOBxu2BPycKRMakpzgLG4= pcp_version: 3, user_centric_signup: true, orb_relay_app_id: Some("123123".to_string()), - bypass_age_verification: false, + bypass_age_verification_token: None, + }; + let qr = encode_qr(&session_id, user_data.hash(16)); + let (parsed_session_id, parsed_user_data_hash) = decode_qr(&qr).unwrap(); + assert_eq!(parsed_session_id, session_id); + assert!(user_data.verify(parsed_user_data_hash)); +} + +#[test] +fn test_encode_decode_verify_with_age_verification_token() { + let session_id = Uuid::new_v4(); + let self_custody_public_key = r#"-----BEGIN PUBLIC KEY----- +MCowBQYDK2VuAyEA2boNBmJX4lGkA9kjthS5crXOBxu2BPycKRMakpzgLG4= +-----END PUBLIC KEY-----"#; + let sample_jwt_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"; + let identity_commitment = "0xabcd"; + let user_data = UserData { + identity_commitment: identity_commitment.to_string(), + self_custody_public_key: self_custody_public_key.to_string(), + data_policy: DataPolicy::OptOut, + pcp_version: 3, + user_centric_signup: true, + orb_relay_app_id: Some("123123".to_string()), + bypass_age_verification_token: Some(sample_jwt_token.to_string()), }; let qr = encode_qr(&session_id, user_data.hash(16)); let (parsed_session_id, parsed_user_data_hash) = decode_qr(&qr).unwrap();