import type { Sha3Exports } from '../mldsa/types.js'; import type { Sha2Exports } from '../sha2/types.js'; /** FIPS 205 §10.2.2 approved pre-hash functions, same surface as FIPS 204 * §5.4.1. Names follow the FIPS 204 / FIPS 205 spelling (no hyphen * between SHAKE and the digit). The SHAKE entries are XOFs with fixed * output lengths set by FIPS 205 §10.2.2 Algorithm 23: SHAKE128 → 256-bit * (32-byte) output, SHAKE256 → 512-bit (64-byte). */ export type PreHashAlgorithm = 'SHA2-224' | 'SHA2-256' | 'SHA2-384' | 'SHA2-512' | 'SHA2-512/224' | 'SHA2-512/256' | 'SHA3-224' | 'SHA3-256' | 'SHA3-384' | 'SHA3-512' | 'SHAKE128' | 'SHAKE256'; /** Look up the FIPS 205 §10.2.2 OID DER bytes for `algo`. Returns a fresh * Uint8Array each call so callers can wipe / mutate without aliasing the * module-private constant. */ export declare function getOid(algo: PreHashAlgorithm): Uint8Array; /** FIPS 205 §10.2.2 PH_M byte length for `algo`. SHAKE128 / SHAKE256 are * XOFs but the spec fixes their HashSLH-DSA output to 32 / 64 bytes * respectively; the SHA-3 and SHA-2 entries return their natural digest * size. Used by `validateDigest` to bound the caller-supplied prehash. * * Duplicated from `src/ts/mldsa/hashvariant.ts:digestSize`; extraction * is deferred until a third consumer materialises. */ export declare function digestSize(algo: PreHashAlgorithm): number; /** True iff `algo` is one of the SHA-2 family pre-hashes (and therefore * requires `init({ sha2: ... })`). The SHA-3 family and SHAKE variants * use the `sha3` module. */ export declare function algoNeedsSha2(algo: PreHashAlgorithm): boolean; /** True iff `algo` is a SHA-3 or SHAKE pre-hash (and therefore requires * `init({ sha3: ... })`). slhdsa's own embedded Keccak permutation is * used internally by `slh_sign_internal` / `slh_verify_internal`, but the * HashSLH-DSA prehash dispatcher routes through the `sha3` module to keep * the public surface byte-identical with `src/ts/mldsa/hashvariant.ts` * (which also uses the sha3 module). */ export declare function algoNeedsSha3(algo: PreHashAlgorithm): boolean; /** * Build the HashSLH-DSA M' = 0x01 ‖ |ctx| ‖ ctx ‖ OID ‖ PH_M. * * FIPS 205 §10.2.2 Algorithm 23 lines 18-19 (sign) and §10.3 Algorithm 25 * lines 16-17 (verify). The leading byte is 0x01 (vs 0x00 for pure * SLH-DSA), domain separation across pure / pre-hash modes per FIPS 205 * §10.2 narrative. Caller has already validated ctx.length ≤ 255. * * Byte-identical to FIPS 204 §5.4 Algorithm 4 M' construction; see * src/ts/mldsa/hashvariant.ts and src/ts/mldsa/format.ts:constructMPrimeHash * for the ML-DSA mirror. Q7 resolution: duplicate, do not extract. */ export declare function constructMPrimeHash(digest: Uint8Array, ph: PreHashAlgorithm, ctx: Uint8Array): Uint8Array; /** * Build the pure-mode M' = 0x00 ‖ |ctx| ‖ ctx ‖ M for FIPS 205 §10.2.1 * Algorithm 22 line 8 (sign) and §10.3 Algorithm 24 line 8 (verify). * * Caller has already validated ctx.length ≤ 255. The leading byte is 0x00, * which separates pure SLH-DSA signatures from HashSLH-DSA signatures (the * latter prepends 0x01 via constructMPrimeHash) on the same key per the * §10.2 narrative. */ export declare function constructMPrimePure(M: Uint8Array, ctx: Uint8Array): Uint8Array; /** * Pre-hash dispatcher, applies the FIPS 205 §10.2.2 hash function `algo` * to message `M` and returns PH_M (the bytes that go into M' alongside * the OID). * * `sx` is the sha3-wasm Sha3Exports, required for SHA-3 / SHAKE prehashes. * `sha2x` is the sha2-wasm Sha2Exports, required for SHA-2 prehashes. * Either argument may be `undefined` when the chosen `algo` does not need * that module; the dispatcher throws a clear error if a required module * is missing rather than NPE'ing on a member access. Pure-SLH-DSA users * call neither (slhdsa-wasm has its own embedded Keccak permutation), so * both modules are strictly optional. */ export declare function preHashMessage(sx: Sha3Exports | undefined, sha2x: Sha2Exports | undefined, algo: PreHashAlgorithm, M: Uint8Array): Uint8Array;