/** * This file is based on noble-curves (https://github.com/paulmillr/noble-curves). * * noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) * * The original file is located at: * https://github.com/paulmillr/noble-curves/blob/b9d49d2b41d550571a0c5be443ecb62109fa3373/src/utils.ts */ export interface Hash { blockLen: number; outputLen: number; update(buf: Uint8Array): this; digestInto(buf: Uint8Array): void; digest(): Uint8Array; destroy(): void; _cloneInto(to?: T): T; clone(): T; } export interface HashInfo { /** DER encoded OID in bytes */ oid?: Uint8Array; } /** * Hash function interface with callable signature and properties * @template T - The Hash implementation type * @template Opts - Optional parameters type (undefined for simple hashes) * * Note: Default type parameter uses `any` due to TypeScript's limitations with * F-bounded polymorphism in self-referential type constraints. * This is a necessary compromise for the circular type dependency in Hash. */ export interface CHash = Hash, Opts = undefined> extends HashInfo { /** Output length in bytes */ readonly outputLen: number; /** Block length in bytes */ readonly blockLen: number; /** * Hash a message * @param msg - Message to hash * @param opts - Optional parameters (only for hashes that support options) */ (msg: Uint8Array, opts?: Opts): Uint8Array; /** * Create a new hash instance * @param opts - Optional parameters (only for hashes that support options) */ create(opts?: Opts): T; } /** * XOF: streaming API to read digest in chunks. * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name. * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot * destroy state, next call can require more bytes. * @template T - The Hash implementation type */ export interface HashXOF> extends Hash { /** Read 'bytes' bytes from digest stream */ xof(bytes: number): Uint8Array; /** Read buf.length bytes from digest stream into buf */ xofInto(buf: Uint8Array): Uint8Array; } /** * Hash constructor function type * @template T - The Hash implementation type * @template Opts - Optional parameters type (undefined for simple hashes) */ export type HasherCons = Opts extends undefined ? () => T : (opts?: Opts) => T; /** * XOF (eXtendable Output Function) interface * Extended hash function that can produce output of arbitrary length * * Note: Default type parameter uses `any` due to TypeScript's limitations with * F-bounded polymorphism in self-referential type constraints. * This is a necessary compromise for the circular type dependency in HashXOF. */ export interface CHashXOF = HashXOF, Opts = undefined> extends CHash { } /** Asserts something is hash */ export declare function ahash(h: CHash): void; export declare function createHasher, Opts = undefined>(hashCons: HasherCons, info?: HashInfo): CHash; //# sourceMappingURL=hash.d.ts.map