import { randomBytes } from "@noble/hashes/utils.js"; import type { DaemonId, EphemeralKeyPair, IdentityKeyPair, SessionKeys } from "./types.js"; import { Direction } from "./types.js"; /** Generate a new Ed25519 identity keypair */ export declare function generateIdentityKeyPair(): IdentityKeyPair; /** Generate a new X25519 ephemeral keypair */ export declare function generateEphemeralKeyPair(): EphemeralKeyPair; /** Compute SHA-256 fingerprint of an identity public key */ export declare function computeFingerprint(identityPublicKey: Uint8Array): string; /** * Create the signature payload for handshake authentication. * * payload = SHA256("sbrp-v1-handshake" || daemonId || clientPublicKey || daemonEphemeralPublicKey) */ export declare function createSignaturePayload(daemonId: DaemonId, clientPublicKey: Uint8Array, daemonEphemeralPublicKey: Uint8Array): Uint8Array; /** Sign a payload with an Ed25519 identity private key */ export declare function signPayload(payload: Uint8Array, identityPrivateKey: Uint8Array): Uint8Array; /** Verify an Ed25519 signature */ export declare function verifySignature(payload: Uint8Array, signature: Uint8Array, identityPublicKey: Uint8Array): boolean; /** Compute X25519 shared secret */ export declare function computeSharedSecret(myPrivateKey: Uint8Array, peerPublicKey: Uint8Array): Uint8Array; /** * Create the transcript hash for key derivation. * * transcript = SHA256("sbrp-v1-transcript" || daemonId || clientPublicKey || daemonPublicKey || signature) */ export declare function createTranscriptHash(daemonId: DaemonId, clientPublicKey: Uint8Array, daemonPublicKey: Uint8Array, signature: Uint8Array): Uint8Array; /** * Derive session keys using HKDF-SHA256. * * Keys are derived with transcript hash as salt to bind to the authenticated session. */ export declare function deriveSessionKeys(sharedSecret: Uint8Array, transcriptHash: Uint8Array): SessionKeys; /** * Construct a nonce for ChaCha20-Poly1305. * * Nonce format (12 bytes): * - Bytes 0-3: Direction (0x00000001 = client→daemon, 0x00000002 = daemon→client) * - Bytes 4-11: Sequence number (big-endian uint64) */ export declare function constructNonce(direction: Direction, seq: bigint): Uint8Array; /** * Encrypt a message using ChaCha20-Poly1305. * * Returns: nonce (12 bytes) || ciphertext || authTag (16 bytes) */ export declare function encrypt(key: Uint8Array, direction: Direction, seq: bigint, plaintext: Uint8Array): Uint8Array; /** * Decrypt a message using ChaCha20-Poly1305. * * Input format: nonce (12 bytes) || ciphertext || authTag (16 bytes) * Returns the plaintext, or throws on decryption failure. */ export declare function decrypt(key: Uint8Array, data: Uint8Array): Uint8Array; /** * Extract sequence number from encrypted message data. * * Reads bytes 4-11 of the nonce as big-endian uint64. */ export declare function extractSequence(data: Uint8Array): bigint; /** * Best-effort zeroization of sensitive key material. * * Note: JavaScript/GC limitations mean this is not guaranteed to prevent * key material from remaining in memory. */ export declare function zeroize(data: Uint8Array): void; /** Generate random bytes */ export { randomBytes }; //# sourceMappingURL=crypto.d.ts.map