/** * Internal Merkle-Damgard hash utils. * @module */ import { type Hash, type TArg, type TRet } from './utils.ts'; /** * Shared 32-bit conditional boolean primitive reused by SHA-256, SHA-1, and MD5 `F`. * Returns bits from `b` when `a` is set, otherwise from `c`. * The XOR form is equivalent to MD5's `F(X,Y,Z) = XY v not(X)Z` because the masked terms never * set the same bit. * @param a - selector word * @param b - word chosen when selector bit is set * @param c - word chosen when selector bit is clear * @returns Mixed 32-bit word. * @example * Combine three words with the shared 32-bit choice primitive. * ```ts * Chi(0xffffffff, 0x12345678, 0x87654321); * ``` */ export declare function Chi(a: number, b: number, c: number): number; /** * Shared 32-bit majority primitive reused by SHA-256 and SHA-1. * Returns bits shared by at least two inputs. * @param a - first input word * @param b - second input word * @param c - third input word * @returns Mixed 32-bit word. * @example * Combine three words with the shared 32-bit majority primitive. * ```ts * Maj(0xffffffff, 0x12345678, 0x87654321); * ``` */ export declare function Maj(a: number, b: number, c: number): number; /** * Merkle-Damgard hash construction base class. * Could be used to create MD5, RIPEMD, SHA1, SHA2. * Accepts only byte-aligned `Uint8Array` input, even when the underlying spec describes bit * strings with partial-byte tails. * @param blockLen - internal block size in bytes * @param outputLen - digest size in bytes * @param padOffset - trailing length field size in bytes * @param isLE - whether length and state words are encoded in little-endian * @example * Use a concrete subclass to get the shared Merkle-Damgard update/digest flow. * ```ts * import { _SHA1 } from '@noble/hashes/legacy.js'; * const hash = new _SHA1(); * hash.update(new Uint8Array([97, 98, 99])); * hash.digest(); * ``` */ export declare abstract class HashMD> implements Hash { protected abstract process(buf: DataView, offset: number): void; protected abstract get(): number[]; protected abstract set(...args: number[]): void; abstract destroy(): void; protected abstract roundClean(): void; readonly blockLen: number; readonly outputLen: number; readonly canXOF = false; readonly padOffset: number; readonly isLE: boolean; protected buffer: Uint8Array; protected view: DataView; protected finished: boolean; protected length: number; protected pos: number; protected destroyed: boolean; constructor(blockLen: number, outputLen: number, padOffset: number, isLE: boolean); update(data: TArg): this; digestInto(out: TArg): void; digest(): TRet; _cloneInto(to?: T): T; clone(): T; } /** * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53. * Check out `test/misc/sha2-gen-iv.js` for recomputation guide. */ /** Initial SHA256 state from RFC 6234 §6.1: the first 32 bits of the fractional parts of the * square roots of the first eight prime numbers. Exported as a shared table; callers must treat * it as read-only because constructors copy words from it by index. */ export declare const SHA256_IV: TRet; /** Initial SHA224 state `H(0)` from RFC 6234 §6.1. Exported as a shared table; callers must * treat it as read-only because constructors copy words from it by index. */ export declare const SHA224_IV: TRet; /** Initial SHA384 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen * big-endian 32-bit halves. Derived from the fractional parts of the square roots of the ninth * through sixteenth prime numbers. Exported as a shared table; callers must treat it as read-only * because constructors copy halves from it by index. */ export declare const SHA384_IV: TRet; /** Initial SHA512 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen * big-endian 32-bit halves. Derived from the fractional parts of the square roots of the first * eight prime numbers. Exported as a shared table; callers must treat it as read-only because * constructors copy halves from it by index. */ export declare const SHA512_IV: TRet; //# sourceMappingURL=_md.d.ts.map