Skip to content

Commit

Permalink
orb-qr-link: Signal user-centric signups (#185)
Browse files Browse the repository at this point in the history
Signal app-centric signups
  • Loading branch information
andronat authored Aug 14, 2024
1 parent 7c31679 commit 1cf5fd1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion orb-qr-link/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <valentyn.valiaiev@toolsforhumanity.com>"]
publish = false
Expand Down
4 changes: 3 additions & 1 deletion orb-qr-link/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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`
Expand Down
11 changes: 11 additions & 0 deletions orb-qr-link/src/user_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
Expand Down Expand Up @@ -57,13 +60,17 @@ 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());
hasher.update(&[*data_policy as u8]);
if *pcp_version != PCP_VERSION_DEFAULT {
hasher.update(&pcp_version.to_ne_bytes());
}
if *user_centric_signup {
hasher.update(&[true as u8]);
}
}
}

Expand Down Expand Up @@ -91,3 +98,7 @@ impl ToString for DataPolicy {
const fn pcp_version_default() -> u16 {
PCP_VERSION_DEFAULT
}

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

0 comments on commit 1cf5fd1

Please sign in to comment.