Skip to content

feat!: Add new QR version for new session flow#655

Merged
danielle-tfh merged 5 commits into
mainfrom
make-fields-optional-for-user-data
Aug 26, 2025
Merged

feat!: Add new QR version for new session flow#655
danielle-tfh merged 5 commits into
mainfrom
make-fields-optional-for-user-data

Conversation

@danielle-tfh
Copy link
Copy Markdown
Contributor

@danielle-tfh danielle-tfh commented Aug 21, 2025

Notes

We are planning a new roll-out of the session validation flow: https://www.notion.so/worldcoin/Proposal-Eliminate-Session-Centric-Verification-Flow-2418614bdf8c802893d9c3fe43ebba81.

This PR prepares a new version of qr codes where the orb knows the version of the QR code

@danielle-tfh danielle-tfh requested a review from a team as a code owner August 21, 2025 15:36
@danielle-tfh danielle-tfh force-pushed the make-fields-optional-for-user-data branch from f3a88f8 to 754d012 Compare August 21, 2025 15:38
@danielle-tfh danielle-tfh changed the title Add optional fields for new session flow feat!: Add optional fields for new session flow Aug 21, 2025
@TheButlah TheButlah requested review from andronat, bsayed and valff August 21, 2025 19:28
Copy link
Copy Markdown
Member

@andronat andronat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry i might be too tired but i think this won't work. if apps upgrade to thid version the hash will be calculated differently between app and orb. also if we upgrade the orbs first, we will have the same issue. both chancing fields have issues. i think the only way to roll this out is either by doing 2 hash functions or by 2 releases. let's discuss tomorrow. again i might be completely wrong and my brain hallucinate..

Comment thread qr-link/src/user_data.rs Outdated
use serde::{Deserialize, Serialize};

const PCP_VERSION_DEFAULT: u16 = 2;
pub const PCP_VERSION_DEFAULT: u16 = 2;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this public? is it for orb relay messages?

@danielle-tfh danielle-tfh force-pushed the make-fields-optional-for-user-data branch 3 times, most recently from 14c92fb to a7be680 Compare August 22, 2025 12:08
@danielle-tfh danielle-tfh force-pushed the make-fields-optional-for-user-data branch from a7be680 to 34f672d Compare August 22, 2025 12:21
@danielle-tfh
Copy link
Copy Markdown
Contributor Author

Sorry i might be too tired but i think this won't work. if apps upgrade to thid version the hash will be calculated differently between app and orb. also if we upgrade the orbs first, we will have the same issue. both chancing fields have issues. i think the only way to roll this out is either by doing 2 hash functions or by 2 releases. let's discuss tomorrow. again i might be completely wrong and my brain hallucinate..

I added tests for this in a new commit. It should work with the new changes introduced in both cases. Let me know if i am missing something. I also outlined the roll out here https://www.notion.so/worldcoin/Proposal-Eliminate-Session-Centric-Verification-Flow-2418614bdf8c802893d9c3fe43ebba81

@danielle-tfh danielle-tfh force-pushed the make-fields-optional-for-user-data branch from 2d4e2c9 to 1fbce7e Compare August 22, 2025 16:50
@danielle-tfh danielle-tfh changed the title feat!: Add optional fields for new session flow feat!: Add new QR version for new session flow Aug 22, 2025
Comment thread qr-link/src/app_authenticated_data.rs Outdated
hasher.update(os_version.as_bytes());
hasher.update(os.as_bytes());
if *pcp_version != PCP_VERSION_DEFAULT {
hasher.update(&pcp_version.to_ne_bytes());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm actually this is dangerous no? ne is for native endianness and if different platforms have different endianness this will break... We are actually lucky that arm and x86 are little endian by default. Could we do it _le_?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find! Let me update it

Comment thread qr-link/src/decode.rs Outdated
/// Parses `session_id` and `user_data_hash` from a QR-code string.
/// This decode version does not support v4 since no v4 should be used with this method
/// All orbs should be updated to support v4 since it requires specific logic
pub fn decode_qr(qr: &str) -> Result<(Uuid, Vec<u8>), DecodeError> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove this or break the current api. in any case the code doesn't need to be backwards compatible. Only the QR handling needs to. The plan will be we update all the orbs first to have the new v3+v4 decoders everywhere and then we update the apps to generate v4 only QRs.

Comment thread qr-link/src/encode.rs
}

/// Generates a QR-code (V4) string from `orb relay id` and `app_authenticated_data`
pub fn encode_static_qr(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my comments above, we should remove the old encode_qr and just update it with the following code. We no longer need to generate v3s if we move to v4.

Copy link
Copy Markdown
Contributor Author

@danielle-tfh danielle-tfh Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially kept it for unit tests for ensuring backwards compatibility with decode.

But if you feel that its not needed - then let me remove

Comment thread qr-link/src/lib.rs Outdated
//! let success = user_data.verify(user_data_hash);
//! ```
//!
//! # New flow
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar here. Just remove the old examples and make this the canonical one.

@danielle-tfh danielle-tfh force-pushed the make-fields-optional-for-user-data branch from 8ed7a28 to 3b71597 Compare August 26, 2025 17:38
@danielle-tfh danielle-tfh force-pushed the make-fields-optional-for-user-data branch from 3b71597 to 5121be0 Compare August 26, 2025 17:43
@danielle-tfh danielle-tfh enabled auto-merge (squash) August 26, 2025 17:45
@danielle-tfh danielle-tfh disabled auto-merge August 26, 2025 17:45
@danielle-tfh danielle-tfh enabled auto-merge (squash) August 26, 2025 17:45
@danielle-tfh danielle-tfh merged commit b21c0b6 into main Aug 26, 2025
26 of 28 checks passed
@danielle-tfh danielle-tfh deleted the make-fields-optional-for-user-data branch August 26, 2025 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants