Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generate 144-bit group IDs #5986

Merged
merged 1 commit into from
Sep 20, 2024
Merged

feat: generate 144-bit group IDs #5986

merged 1 commit into from
Sep 20, 2024

Conversation

link2xt
Copy link
Collaborator

@link2xt link2xt commented Sep 20, 2024

Instead of generating 72 random bits
and reducing them to 66 bits of Base64 characters, generate 144 bits (18 bytes)
which is exactly 24 Base64 characters.

This should still be accepted by existing
Delta Chat clients which expect group ID
to be between 11 and 32 characters.

Message-ID creation is also simplified
to not have Mr. prefix
and dot in between two IDs.
Now it is a single ID followed by @localhost.

Some outdated documentation comments
are removed, e.g. group messages
don't start with Gr. already.

src/tools.rs Outdated
/// IDs generated by this function are 66 bit wide and are returned as 11 base64 characters.
/// The generated ID should be short but unique:
/// - short, because it used in Message-ID and Chat-Group-ID headers and in QR codes
/// - unique as two IDs generated on two devices should not be the same. However, collisions are not world-wide but only by the few contacts.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The second sentence is a bit hard to understand. Probably it's meant that we don't protect from collisions globally, but only at account and chat scale.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, makes no sense, I think I will remove it.

@@ -961,7 +957,6 @@ DKIM Results: Passed=true";
#[test]
fn test_create_outgoing_rfc724_mid() {
let mid = create_outgoing_rfc724_mid();
assert!(mid.starts_with("Mr."));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe check the length at least?

Instead of generating 72 random bits
and reducing them to 66 bits of Base64 characters,
generate 144 bits (18 bytes)
which is exactly 24 Base64 characters.

This should still be accepted by existing
Delta Chat clients which expect group ID
to be between 11 and 32 characters.

Message-ID creation is also simplified
to not have `Mr.` prefix
and dot in between two IDs.
Now it is a single ID followed by `@localhost`.

Some outdated documentation comments
are removed, e.g. group messages
don't start with `Gr.` already.
@link2xt link2xt merged commit f6b5c5d into main Sep 20, 2024
37 checks passed
@link2xt link2xt deleted the link2xt/message-id branch September 20, 2024 22:38
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