/** * An identity key pair consists of a public and private key. * This is the long-term identity for a user/device. */ export interface IdentityKeyPair { /** The public identity key (33 bytes - Curve25519 compressed) */ publicKey: Uint8Array; /** The private identity key (32 bytes) */ privateKey: Uint8Array; } /** * A pre-key record for the X3DH key agreement. * Multiple pre-keys are generated and uploaded to the server. */ export interface PreKeyRecord { /** Unique identifier for this pre-key */ id: number; /** The public pre-key */ publicKey: Uint8Array; /** The private pre-key */ privateKey: Uint8Array; } /** * A signed pre-key record for the X3DH key agreement. * Signed with the identity key to prove authenticity. */ export interface SignedPreKeyRecord { /** Unique identifier for this signed pre-key */ id: number; /** The public signed pre-key */ publicKey: Uint8Array; /** The private signed pre-key */ privateKey: Uint8Array; /** Signature of the public key using the identity key */ signature: Uint8Array; /** Timestamp when this key was generated */ timestamp: number; } /** * A pre-key bundle is fetched from the server when establishing * a new session with a recipient. */ export interface PreKeyBundle { /** The recipient's registration ID */ registrationId: number; /** The recipient's device ID */ deviceId: number; /** Pre-key ID */ preKeyId: number; /** Pre-key public key */ preKeyPublic: Uint8Array; /** The signed pre-key ID */ signedPreKeyId: number; /** The signed pre-key public key */ signedPreKeyPublic: Uint8Array; /** Signature of the signed pre-key */ signedPreKeySignature: Uint8Array; /** The recipient's identity public key */ identityKey: Uint8Array; /** Optional Kyber (post-quantum) pre-key ID */ kyberPreKeyId?: number; /** Optional Kyber pre-key public key */ kyberPreKey?: Uint8Array; /** Optional Kyber pre-key signature */ kyberPreKeySignature?: Uint8Array; } /** * An address identifies a specific user and device. */ export interface ProtocolAddress { /** User identifier (e.g., phone number, UUID) */ name: string; /** Device identifier within the user's devices */ deviceId: number; } /** * Message types in the Signal Protocol. */ export type CiphertextMessageType = 'whisper' | 'preKey' | 'senderKey' | 'plaintext'; /** * An encrypted message ready to be sent. */ export interface CiphertextMessage { /** The type of ciphertext message */ type: CiphertextMessageType; /** The encrypted message body */ body: Uint8Array; } /** * A decrypted message with sender information. */ export interface DecryptedMessage { /** The decrypted plaintext */ plaintext: Uint8Array; } /** * A Kyber (post-quantum) pre-key record for PQXDH key agreement. * Provides quantum-resistant key exchange. */ export interface KyberPreKeyRecord { /** Unique identifier for this Kyber pre-key */ id: number; /** The public Kyber pre-key */ publicKey: Uint8Array; /** Signature of the public key using the identity key */ signature: Uint8Array; /** Timestamp when this key was generated */ timestamp: number; /** Serialized record for persistence (includes private key) */ serialized: Uint8Array; }