/** * EGRW - Expander Graph Random Walk Problem * * Based on random walks on Ramanujan graphs (Cayley graphs of SL(2, Z_p)). * Graph-theoretic hardness with no known relationship to lattice/tensor problems. * * Problem: Given start/end vertices of a walk, find the generator sequence used. * * Security Properties: * - Hardness based on navigating Cayley graphs of SL(2, Z_p) * - Group order ā‰ˆ p³, providing exponential security in log(p) * - Walk length k with 4 generators provides 4^k possible paths * - Entropy: k * log2(4) = 2k bits (k=128→256 bits, k=256→512 bits) * - No known quantum speedup for this specific problem * * Performance: * - All operations are O(k) where k is walk length * - Fastest of the three kMOSAIC problems */ import type { EGRWParams, EGRWPublicKey, EGRWSecretKey, EGRWCiphertext, SL2Element } from '../../types.js'; /** * Evict oldest cache entries when cache exceeds max size * Uses access counter for LRU-style eviction */ export declare function evictOldestCacheEntries(): void; /** * Extended Euclidean algorithm for modular inverse * Returns a^(-1) mod p * * Performance: O(log p) operations * * @param a - Number to invert * @param p - Modulus * @returns Modular inverse * @throws Error if a is 0 */ export declare function modInverse(a: number, p: number): number; /** * Standard generators for Cayley graph of SL(2, Z_p) * Using S = [0 -1; 1 0] and T = [1 1; 0 1] * * These generate SL(2, Z_p) and the resulting Cayley graph is a Ramanujan graph * (optimal expansion properties). * * Performance: Cached per prime p with LRU eviction to bound memory usage * * @param p - Prime modulus * @returns Array of 4 generators [S, S^-1, T, T^-1] */ export declare function getGenerators(p: number): SL2Element[]; /** * Serialize SL2 element to bytes * * @param m - Matrix * @returns 16-byte representation */ declare function sl2ToBytes(m: SL2Element): Uint8Array; /** * Deserialize SL2 element from bytes * * @param data - 16-byte representation * @returns Matrix */ declare function bytesToSl2(data: Uint8Array): SL2Element; export interface EGRWKeyPair { publicKey: EGRWPublicKey; secretKey: EGRWSecretKey; } /** * Generate EGRW key pair * * Security: The public key reveals only the start and end vertices. * The secret walk is hidden by the discrete-log-like hardness of * finding the generator sequence. * * Performance: O(k) where k is walk length * * @param params - EGRW parameters * @param seed - Random seed * @returns Key pair */ export declare function egrwKeyGen(params: EGRWParams, seed: Uint8Array): EGRWKeyPair; /** * EGRW Encryption (for KEM) * Encodes a message fragment using the graph structure * * Security: Uses an ephemeral random walk to create a shared secret point. * The keystream is derived from the ephemeral endpoint and the recipient's * public key endpoints. Only the ephemeral vertex is stored in the ciphertext, * not the randomness used to derive the walk. * * @param publicKey - Recipient's public key * @param message - Message to encrypt * @param params - EGRW parameters * @param randomness - Randomness for encryption * @returns Ciphertext */ export declare function egrwEncrypt(publicKey: EGRWPublicKey, message: Uint8Array, params: EGRWParams, randomness: Uint8Array): EGRWCiphertext; /** * EGRW Decryption (for KEM) * * Security: Derives the keystream using the ephemeral vertex from the ciphertext * and the public key. The recipient doesn't need the secret walk for decryption * in this KEM construction since the keystream is derived from public values. * * Note: This is a hash-based KEM construction. True graph-based security would * require the recipient to use their secret walk to compute a shared point. * * @param ciphertext - Ciphertext to decrypt * @param secretKey - Recipient's secret key * @param publicKey - Recipient's public key * @param params - EGRW parameters * @returns Decrypted message */ export declare function egrwDecrypt(ciphertext: EGRWCiphertext, secretKey: EGRWSecretKey, publicKey: EGRWPublicKey, params: EGRWParams): Uint8Array; /** * Serialize EGRW public key * * @param pk - Public key * @returns Serialized bytes */ export declare function egrwSerializePublicKey(pk: EGRWPublicKey): Uint8Array; /** * Deserialize EGRW public key * * @param data - Serialized bytes * @returns Public key */ export declare function egrwDeserializePublicKey(data: Uint8Array): EGRWPublicKey; /** * Serialize SL2 element */ export { sl2ToBytes, bytesToSl2 }; //# sourceMappingURL=index.d.ts.map