import * as Errors from '../../Errors.js'; /** @internal */ export type Hex = `0x${string}`; /** * Encodes a `Uint8Array` into a `0x`-prefixed lowercase hex string. Uses the * native `Uint8Array.prototype.toHex` or Node's `Buffer` when available; * otherwise a tight JS loop. * * @internal */ export declare function bytesToHex(value: Uint8Array): Hex; /** * Encodes via `Uint8Array.prototype.toHex`, where the runtime has it. * `undefined` otherwise, so callers and the conformance suite can both ask * whether this tier exists rather than inferring it. * * @internal */ export declare const bytesToHexNative: ((value: Uint8Array) => Hex) | undefined; /** * Encodes via Node's `Buffer`, where the runtime has it. * * @internal */ export declare const bytesToHexBuffer: ((value: Uint8Array) => Hex) | undefined; /** * Encodes in plain JavaScript, for runtimes with neither the native method nor * `Buffer`: browsers predating `Uint8Array.prototype.toHex`, which is recent * enough that a meaningful share of installed browsers still land here. * * Appending to a string beats collecting substrings and joining them: V8 builds * a rope and flattens it once, where `join` over an `Array.from({ length })` * pays for a holey array as well as the concatenation. Measured at ~6.5x on a * 32-byte input, counting the flatten. * * @internal */ export declare function bytesToHexLoop(value: Uint8Array): Hex; /** * Strictly decodes a `0x`-prefixed even-length hex string into a `Uint8Array`. * Uses a JS loop for short inputs and Node's `Buffer` for longer ones. * * @internal */ export declare function hexToBytes(value: string): Uint8Array; /** * Decodes via Node's `Buffer`, where the runtime has it. * * @internal */ export declare const hexToBytesBuffer: ((value: string, length: number) => Uint8Array) | undefined; /** * Decodes in plain JavaScript, reading nibbles straight out of `value` from * index 2 so no substring is materialized. * * Invalidity is accumulated rather than branched on per nibble: a valid nibble * is at most `0x0f`, so only the `0xff` sentinel can set bit 7, and one check * after the loop covers every character. `nibbleTable` only spans Latin-1, so a * code unit above it reads `undefined` and has to be mapped to the sentinel -- * without that, a non-ASCII character would OR in as zero and decode silently. * * @internal */ export declare function hexToBytesLoop(value: string, length: number): Uint8Array; /** @internal */ export declare function charCodeToBase16(char: number): number | undefined; /** Thrown when a value is not a valid `0x`-prefixed hex string. */ export declare class InvalidHexValueError extends Errors.BaseError { readonly name = "Hex.InvalidHexValueError"; constructor(value: unknown); } /** Thrown when a hex string has an odd nibble count. */ export declare class InvalidLengthError extends Errors.BaseError { readonly name = "Hex.InvalidLengthError"; constructor(value: Hex); } /** @internal */ export declare namespace bytesToHex { type ErrorType = Errors.GlobalErrorType; } /** @internal */ export declare namespace hexToBytes { type ErrorType = InvalidHexValueError | InvalidLengthError | Errors.GlobalErrorType; } //# sourceMappingURL=hex.d.ts.map