/** * The heart seed — cryptographic entanglement of output with the heart. * * Two mechanisms that make output inseparable from the heart: * * 1. Token-Level HMAC Authentication (PRIMARY — cryptographic guarantee) * Every token is individually authenticated with an HMAC computed from the * session key. Mathematical. Either the HMAC verifies or it doesn't. * * 2. Dynamic Seed Generation (SECONDARY — behavioral defense-in-depth) * The heart dynamically generates a unique behavioral modification for every * interaction. No fixed library — the modification is constructed on the fly * from a continuous parameter space, making enumeration attacks infeasible * even with full source code access. * * The generator is deterministic from the session key: * HKDF(session_key, interaction_counter, query_hash) -> 256-bit nonce * Nonce bytes -> point in continuous behavioral space (verbosity, structure, formality) * Parameters -> unique system prompt addition * Both sides share the session key -> both derive identical parameters */ import { type CryptoProvider } from "../core/crypto-provider.js"; /** Configuration for seed derivation. */ export interface SeedConfig { sessionKey: Uint8Array; interactionCounter: number; } /** Behavioral parameters derived from the nonce — a point in continuous space. */ export interface BehavioralParams { /** 0.0–1.0: terse to detailed. */ verbosity: number; /** 0.0–1.0: front-loaded to back-loaded argument organization. */ structure: number; /** 0.0–1.0: casual to formal register. */ formality: number; } /** Expected behavioral region — what the verifier checks. */ export interface BehavioralRegion { verbosityRange: [number, number]; structureRange: [number, number]; formalityRange: [number, number]; } /** A derived seed for a single interaction. */ export interface HeartSeed { /** The HKDF-derived nonce, unique per interaction (hex-encoded). */ nonce: string; /** The interaction counter at derivation time. */ interactionCounter: number; /** Continuous behavioral parameters derived from the nonce. */ behavioralParams: BehavioralParams; /** The prompt text to append to the system prompt. */ promptModification: string; /** The behavioral region the verifier checks against. */ expectedBehavioralRegion: BehavioralRegion; } /** * Derive a heart seed for a specific interaction. * * Deterministic: same session key + counter + query = same seed. * The receiving party independently derives the same seed and verifies * that the response characteristics match the expected behavioral region. * * The search space is continuous (~10^6 distinct meaningful points with * 3 dimensions at 100 levels each). Even with full source code, predicting * the modification requires the session key — which only exists in the two * endpoints. This is cryptographically hard, not combinatorially annoying. */ export declare function deriveSeed(config: SeedConfig, queryHash: string, provider?: CryptoProvider): HeartSeed; /** * Apply a seed to a system prompt — modifies the input to influence generation. * This is NOT a watermark added after. It changes HOW the model generates. */ export declare function applySeed(systemPrompt: string, seed: HeartSeed): string; /** * Verify that a response's behavioral characteristics land within the expected * behavioral region. Returns per-dimension scores and an overall confidence. * * Verification is statistical, not exact. We measure observable output properties * that correspond to the seed's behavioral parameters and check whether they * fall in the expected region. */ export declare function verifySeedInfluence(responseText: string, seed: HeartSeed, baselineWordCount: number): { verified: boolean; confidence: number; details: string; perDimension: Record; }; /** * Derive an HMAC key from the session key for token authentication. * Separate from the session key itself — domain separation. */ export declare function deriveHmacKey(sessionKey: Uint8Array, provider?: CryptoProvider): Uint8Array; /** * Compute HMAC for a single token. * * HMAC(hmacKey, token || sequence || interactionCounter) * * Every token is individually authenticated. The receiver verifies * each HMAC as it arrives — a single mismatch = immediate RED. */ export declare function computeTokenHmac(hmacKey: Uint8Array, token: string, sequence: number, interactionCounter: number, provider?: CryptoProvider): string; /** * Verify a token's HMAC. Constant-time comparison. * Returns true if the token was authenticated by this heart. */ export declare function verifyTokenHmac(hmacKey: Uint8Array, token: string, sequence: number, interactionCounter: number, expectedHmac: string, provider?: CryptoProvider): boolean; //# sourceMappingURL=seed.d.ts.map