Skip to content

Commit

Permalink
orb-qr-link: Support UUID for orb-relay comms (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
andronat authored Sep 27, 2024
1 parent f001b42 commit 2880595
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions orb-qr-link/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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`
Expand Down
9 changes: 9 additions & 0 deletions orb-qr-link/src/user_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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<String>,
}

/// User's biometric data policy. Part of [`UserData`].
Expand Down Expand Up @@ -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());
Expand All @@ -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());
}
}
}

Expand Down
1 change: 1 addition & 0 deletions orb-qr-link/tests/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 2880595

Please sign in to comment.