Repository navigation
feat(chat-cipher): group invite cipher in the shared core - #1866
Merged
Merged
Conversation
DefaultInviteCipher implements chat.v1.Invite, InviteKeyEnvelope and InviteSecretEnvelope from flipcash2-protobuf-api: the invite token, wrap key and invite id derived from the link's 32-byte secret, the invite's signed copy of the chat key, and the secret wrapped for its owner. It reuses DefaultChatCipher's HKDF, XChaCha20-Poly1305 and X25519 steps, so pairKey, seal, randomNonce and ensureSodium go from private to internal. openInviteKeyBundle checks wrapped_by, then the signature against the creator's key, then the member's secret envelope, then the copy, and returns the step that failed. It takes the bundle's invite_id because the secret envelope's info and aad bind it, so the secret cannot be opened without it. InviteLink encodes https://app.flipcash.com/chat/invite#s=<secret> in unpadded base64url, parses a fragment strictly (one s= pair, canonical encoding of 32 bytes), and classifies a URL as invite, invalid invite, chat or other so a router can match /chat/invite ahead of /chat/{uuid}. None of the types holding a secret, token or chat key print their bytes. InviteVectorTest runs every section of invite.json from the orchestrator repo, including each reject case at its failsAt step.
SharedInviteCipher wraps DefaultInviteCipher and InviteLink with Data in and out, maps InviteBundleResult to a thrown BundleError and InviteLinkRoute to a Swift enum. InviteCipherTests runs invite.json through the facade; sealing under the fixture's fixed nonces stays on the Kotlin side, so here sealing is checked by round trip.
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the crypto for private-group invite links to
libs/encryption/chat-cipher, so both apps call one implementation through:kmp:shared-core. No UI or app wiring.What's in it
InviteCipher/DefaultInviteCipher: invite token, invite id and wrap key from the link's 32-byte secret; seal and openInviteKeyEnvelope(XChaCha20-Poly1305, signed with the inviter's Ed25519 key); seal and openInviteSecretEnvelope(the self-wrappedKeyEnvelopeconstruction). It reusesDefaultChatCipher's HKDF, AEAD and X25519 steps, which go fromprivatetointernal.openInviteKeyBundlechecks in the order theInviteKeyEnvelopecomment sets:wrapped_by, signature against the creator's key, the member's secret envelope, then the copy. It returnsInviteBundleResult.Rejected(failsAt)rather than throwing.InviteLink: buildshttps://app.flipcash.com/chat/invite#s=<unpadded base64url>, parses a fragment strictly (exactly ones=, canonical encoding of 32 bytes, other keys ignored), and classifies a URL as invite, invalid invite, chat or other so routers can match/chat/inviteahead of/chat/{uuid}.SharedInviteCipherinSharedCoreKit, the Swift facade withDatain and out.wrapKeystaysinternal. It never leaves the device, and the vector test reaches it from the same module.One signature differs from the brief
openInviteKeyBundletakesinviteId, fromInviteKeyBundle.invite_id. The secret envelope's info and aad both bind the invite id, so the secret can't be opened without it. The bundle cases ininvite.jsoncarryinviteIdonly as an output, soInviteVectorTesttakes it from the fixture's successful bundle. Adding it as an input on the reject cases would make that explicit.Tests
InviteVectorTestruns every section ofinvite.json(copied from the orchestrator'stest-vectors/), with each reject case asserted at itsfailsAtstep.InviteCipherTestsruns the same fixture through the Swift facade; sealing under fixed nonces is internal to Kotlin, so the facade checks sealing by round trip.Release
iOS needs the next shared-core release, 0.17.0, through
publish-shared-core.ymlworkflow_dispatch. I haven't triggered it.