/** * Blind Index Generation (WASM-backed) * * Thin wrappers over `@totalreclaw/core` WASM module for SHA-256 blind * indices with Porter stemming. The `generateTrapdoors` and utility * functions remain in TypeScript as they compose on top of the WASM * blind index output. * * Matches mcp/src/subgraph/crypto.ts:generateBlindIndices() exactly. */ /** * Tokenize text into words for blind indexing. * * Performs basic tokenization: * - Converts to lowercase * - Removes punctuation (keeps Unicode letters, numbers, whitespace) * - Splits on whitespace * - Filters out short tokens (< 2 chars) * * Note: This TS tokenizer is kept for callers that need raw tokens * (e.g., BM25 scoring). The WASM module has its own tokenizer used * internally by generateBlindIndices(). * * @param text - Text to tokenize * @returns Array of tokens */ export declare function tokenize(text: string): string[]; /** * Compute SHA-256 hash of a string. * * Uses Node.js crypto for callers that need ad-hoc hashing outside of * the blind index pipeline. * * @param input - String to hash * @returns Hex-encoded SHA-256 hash */ export declare function sha256Hash(input: string): string; /** * Generate blind indices from text. * * Delegates to the WASM module which performs tokenization, Porter * stemming, and SHA-256 hashing. Stemmed tokens are prefixed with * "stem:" before hashing to avoid collisions. * * Matches mcp/src/subgraph/crypto.ts:generateBlindIndices(). * * @param text - Document text * @returns Array of blind indices (hex-encoded SHA-256 hashes), deduplicated */ export declare function generateBlindIndices(text: string): string[]; /** * Generate trapdoors for search query. * * Trapdoors are SHA-256 hashes of: * 1. All tokens in the query (for keyword matching) * 2. Stemmed variants of tokens (for morphological matching) * 3. All LSH bucket identifiers from query embedding (for semantic matching) * * @param query - Search query text * @param lshBuckets - LSH bucket identifiers from query embedding (already blind-hashed) * @returns Array of trapdoors (hex-encoded SHA-256 hashes) */ export declare function generateTrapdoors(query: string, lshBuckets: string[]): string[]; /** * Generate only token-based blind indices (without LSH). * * Useful for keyword-only search or when embedding is not available. * * @param text - Text to index * @returns Array of blind indices for tokens only */ export declare function generateTokenIndices(text: string): string[]; /** * Verify that a blind index matches a trapdoor. * * Since both are SHA-256 hashes, this is a simple equality check. */ export declare function verifyBlindIndexMatch(blindIndex: string, trapdoor: string): boolean; /** * Compute the overlap between two sets of blind indices. * * Used to estimate recall quality during development. */ export declare function computeIndexOverlap(indices1: string[], indices2: string[]): number; //# sourceMappingURL=blind.d.ts.map