import { type KeyDerivationFunction } from './symmetric.js'; export type Ed25519SecretKey = CryptoKey; export type Ed25519PublicKey = CryptoKey; export type X25519SecretKey = CryptoKey; export type X25519PublicKey = CryptoKey; /** * Type returned from the server when initiating a connection. */ export type InitServerInfo = { IdentityKey: string; SignedPreKey: { Signature: string; PreKey: string; }; OneTimeKey?: string; }; /** * Type sent from the sender to the recipient when initiating a connection. */ export type InitSenderInfo = { Sender: string; IdentityKey: string; PreKey: string; EphemeralKey: string; OneTimeKey?: string; }; /** * Signed bundle of one-time keys. */ export type SignedBundle = { signature: string; bundle: string[]; }; /** * X3DH key bundle. */ export type X3DHKeys = { identitySecret: Ed25519SecretKey; identityPublic: Ed25519PublicKey; preKeySecret: X25519SecretKey; preKeyPublic: X25519PublicKey; }; /** * Result from initSend - includes shared secret */ export type InitSendResult = { sharedSecret: Uint8Array; handshakeData: InitSenderInfo; }; /** * Result from initReceive - includes shared secret and sender identity */ export type InitReceiveResult = { sharedSecret: Uint8Array; senderIdentity: string; }; /** * X3DH implementation using Web Crypto API. * Keys are passed in instead of being managed internally. */ export declare class X3DH { kdf: KeyDerivationFunction; keys: X3DHKeys; identityString: string; oneTimeKeys: Map; static prekeys(): Promise; static X3DHKeys(idKeys: { privateWriteKey: Ed25519SecretKey; publicWriteKey: Ed25519PublicKey; }, preKeypair: { privateKey: X25519SecretKey; publicKey: X25519PublicKey; }): X3DHKeys; constructor(keys: X3DHKeys, identityString: string, kdf?: KeyDerivationFunction); /** * Generates and signs a bundle of one-time keys. * Stores them locally for later use. * * @param {number} [numKeys=100] * @returns {Promise} */ generateOneTimeKeys(numKeys?: number): Promise; private fetchAndWipeOneTimeSecretKey; /** * Initiate X3DH key exchange as the sender. * Returns the shared secret and handshake data to send to recipient. * * @param {string} recipientIdentity * @param {InitServerInfo} recipientKeys */ initSend(recipientIdentity: string, recipientKeys: InitServerInfo): Promise; /** * Receive and process an initial X3DH handshake message. * Returns the shared secret and sender's identity. * * @param {InitSenderInfo} req * @returns {Promise} */ initReceive(req: InitSenderInfo): Promise; /** * Sign a pre-key with the identity key. * This is what should be used for signed pre-keys in X3DH. * * @param {Ed25519SecretKey} signingKey * @param {X25519PublicKey} preKey */ signPreKey(signingKey: Ed25519SecretKey, preKey: X25519PublicKey): Promise; /** * Sets the identity string for the current user. * * @param {string} id */ setIdentityString(id: string): void; } export * from './symmetric'; export * from './util'; //# sourceMappingURL=index.d.ts.map