Skip to main content

Module payload

Module payload 

Source
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_payload convenience 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§

InvitePayloadError
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, but RECOMMENDED_EXTERNAL_GROUP_ID_LEN random 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_id when 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 GroupInfo blob referenced by an ExternalInvitePayload.

Functions§

build_payload
Build an ExternalInvitePayload wrapping a ExternalInvitePayloadV1 with the supplied fields.
generate_external_group_id
Generate a fresh random external_group_id of the recommended length (RECOMMENDED_EXTERNAL_GROUP_ID_LEN bytes 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.version carries a recognised variant and that the V1 fields meet their length requirements.