Expand description
Helpers for the ExternalInvitePayload proto.
Centralises the small but easy-to-get-wrong pieces of building and validating an external-invite payload:
- fresh symmetric keys / nonces / external-group-ids from the workspace CSPRNG
- recognising / unwrapping the
oneof version { V1 v1 }envelope - a
build_payloadconvenience constructor
The actual encryption of the GroupInfo blob is performed by the
sibling encrypted_group_info module (which also owns the blob-side
expiry semantics, since expires_at_ns lives on the
EncryptedGroupInfoBlob envelope and not the payload).
Enums§
- Invite
Payload Error - Errors returned when validating an
ExternalInvitePayload.
Constants§
- MIN_
EXTERNAL_ GROUP_ ID_ LEN - Minimum length of
external_group_id. The proto schema enforces this as MUST; tiny services that don’t need much collision resistance may pick the floor, butRECOMMENDED_EXTERNAL_GROUP_ID_LENrandom bytes is the libxmtp default when no application-specific scheme is in use. - NONCE_
LEN - Length in bytes of the ChaCha20Poly1305 nonce used alongside
SYMMETRIC_KEY_LEN-byte keys. - RECOMMENDED_
EXTERNAL_ GROUP_ ID_ LEN - Recommended random length for
external_group_idwhen callers don’t have an application-specific scheme. 16 bytes (128 bits) gives ample collision resistance for any realistic single-service deployment. - SYMMETRIC_
KEY_ LEN - Length in bytes of the ChaCha20Poly1305 key used to wrap the encrypted
GroupInfoblob referenced by anExternalInvitePayload.
Functions§
- build_
payload - Build an
ExternalInvitePayloadwrapping aExternalInvitePayloadV1with the supplied fields. - generate_
external_ group_ id - Generate a fresh random
external_group_idof the recommended length (RECOMMENDED_EXTERNAL_GROUP_ID_LENbytes from the workspace CSPRNG). - generate_
nonce - Generate a fresh 12-byte nonce from the workspace CSPRNG.
- generate_
symmetric_ key - Generate a fresh 32-byte symmetric key from the workspace CSPRNG.
- validate
- Validate that
payload.versioncarries a recognised variant and that the V1 fields meet their length requirements.