import { x25519 } from '@noble/curves/ed25519'; export interface KeyPair { /** Ed25519 identity pair: signs hello + frames. */ priv: Uint8Array; pub: Uint8Array; /** Separate X25519 pair for E2E payload ECDH (DAP/1 addendum). */ xpriv: Uint8Array; xpub: Uint8Array; } export declare const b64: (b: Uint8Array) => string; export declare const unb64: (s: string) => Uint8Array; export declare const utf8: (s: string) => Uint8Array; export declare const unutf8: (b: Uint8Array) => string; /** Canonical JSON: UTF-8, keys sorted recursively, no whitespace (DAP/1 spec). * JSON.stringify never HTML-escapes `<>&` — matches the Go hub's * SetEscapeHTML(false) canonicalizer byte for byte. */ export declare function canonicalJSON(value: unknown): string; /** sigPayload = "dap1|" + op + "|" + ts + "|" + hex(sha256(canonicalJSON(frame))) — DAP/1 spec. */ export declare function sigPayload(op: string, ts: number, frame: unknown): string; /** Ed25519-sign a frame; the `sig` field itself is excluded from the payload. */ export declare function signFrame(priv: Uint8Array, op: string, frame: Record): string; export declare function verifyFrame(pub: Uint8Array, op: string, frame: Record): boolean; /** agentId = hex(sha256(pubkey_raw))[:16] — DAP/1 spec. */ export declare const agentIdFor: (pub: Uint8Array) => string; /** Load the agent keys from disk (0600), creating them on first run: * one JSON file holds the Ed25519 identity pair and the X25519 E2E pair. */ export declare function loadOrCreateKeys(path: string): KeyPair; /** Key = HKDF-SHA256(ikm = ecdh_secret, salt = frame_id, info = "dap1/v1") -> 32 bytes */ export declare function deriveKey(secret: Uint8Array, frameId: string): Uint8Array; /** AAD = "dap1|" + frame_id + "|" + recipient agentId (DM) / channel name — DAP/1 spec. */ export declare const dmAAD: (frameId: string, recipient: string) => string; export declare const channelAAD: (frameId: string, channel: string) => string; /** ciphertext = base64( nonce(12) || ct || tag(16) ) */ export declare function encryptPayload(plain: string, key: Uint8Array, aad: string): string; export declare function decryptPayload(blob: string, key: Uint8Array, aad: string): string; export { x25519 };