/** * Encode a positive integer as a little-endian Uint8Array. For values exceeding * `Number.MAX_SAFE_INTEGER` (`9007199254740991`), use `bigIntToBinUintLE`. * Negative values will return the same result as `0`. * * @param value - the number to encode */ export declare const numberToBinUintLE: (value: number) => Uint8Array; /** * Fill a new Uint8Array of a specific byte-length with the contents of a given * Uint8Array, truncating or padding the Uint8Array with zeros. * * @param bin - the Uint8Array to resize * @param bytes - the desired byte-length */ export declare const binToFixedLength: (bin: Uint8Array, bytes: number) => Uint8Array; /** * Encode a positive integer as a 2-byte Uint16LE Uint8Array, clamping the * results. (Values exceeding `0xffff` return the same result as `0xffff`, * negative values will return the same result as `0`.) * * @param value - the number to encode */ export declare const numberToBinUint16LEClamped: (value: number) => Uint8Array; /** * Encode a positive integer as a 4-byte Uint32LE Uint8Array, clamping the * results. (Values exceeding `0xffffffff` return the same result as * `0xffffffff`, negative values will return the same result as `0`.) * * @param value - the number to encode */ export declare const numberToBinUint32LEClamped: (value: number) => Uint8Array; /** * Encode a positive integer as a 2-byte Uint16LE Uint8Array. * * This method will return an incorrect result for values outside of the range * `0` to `0xffff`. * * @param value - the number to encode */ export declare const numberToBinUint16LE: (value: number) => Uint8Array; /** * Encode a positive integer as a 2-byte Uint16LE Uint8Array. * * This method will return an incorrect result for values outside of the range * `0` to `0xffff`. * * @param value - the number to encode */ export declare const numberToBinUint16BE: (value: number) => Uint8Array; /** * Encode a positive number as a 4-byte Uint32LE Uint8Array. * * This method will return an incorrect result for values outside of the range * `0` to `0xffffffff`. * * @param value - the number to encode */ export declare const numberToBinUint32LE: (value: number) => Uint8Array; /** * Encode a positive number as a 4-byte Uint32BE Uint8Array. * * This method will return an incorrect result for values outside of the range * `0` to `0xffffffff`. * * @param value - the number to encode */ export declare const numberToBinUint32BE: (value: number) => Uint8Array; /** * Encode a positive BigInt as little-endian Uint8Array. Negative values will * return the same result as `0`. * * @param value - the number to encode */ export declare const bigIntToBinUintLE: (value: bigint) => Uint8Array; /** * Encode a positive BigInt as an 8-byte Uint64LE Uint8Array, clamping the * results. (Values exceeding `0xffff_ffff_ffff_ffff` return the same result as * `0xffff_ffff_ffff_ffff`, negative values return the same result as `0`.) * * @param value - the number to encode */ export declare const bigIntToBinUint64LEClamped: (value: bigint) => Uint8Array; /** * Encode a positive BigInt as an 8-byte Uint64LE Uint8Array. * * This method will return an incorrect result for values outside of the range * `0` to `0xffff_ffff_ffff_ffff`. * * @param value - the number to encode */ export declare const bigIntToBinUint64LE: (value: bigint) => Uint8Array; /** * Encode an integer as a 4-byte, little-endian Uint8Array using the number's * two's compliment representation (the format used by JavaScript's bitwise * operators). * * @remarks * The C++ bitcoin implementations sometimes represent short vectors using * signed 32-bit integers (e.g. `sighashType`). This method can be used to test * compatibility with those implementations. * * @param value - the number to encode */ export declare const numberToBinInt32TwosCompliment: (value: number) => Uint8Array; /** * Decode a little-endian Uint8Array of any length into a number. For numbers * larger than `Number.MAX_SAFE_INTEGER` (`9007199254740991`), use * `binToBigIntUintLE`. * * The `bytes` parameter can be set to constrain the expected length (default: * `bin.length`). This method throws if `bin.length` is not equal to `bytes`. * * @privateRemarks * We avoid a bitwise strategy here because JavaScript uses 32-bit signed * integers for bitwise math, so larger numbers are converted incorrectly. E.g. * `2147483648 << 8` is `0`, while `2147483648n << 8n` is `549755813888n`. * * @param bin - the Uint8Array to decode * @param bytes - the number of bytes to read (default: `bin.length`) */ export declare const binToNumberUintLE: (bin: Uint8Array, bytes?: number) => number; /** * Decode a 2-byte Uint16LE Uint8Array into a number. * * Throws if `bin` is shorter than 2 bytes. * * @param bin - the Uint8Array to decode */ export declare const binToNumberUint16LE: (bin: Uint8Array) => number; /** * Decode a 4-byte Uint32LE Uint8Array into a number. * * Throws if `bin` is shorter than 4 bytes. * * @param bin - the Uint8Array to decode */ export declare const binToNumberUint32LE: (bin: Uint8Array) => number; /** * Decode a big-endian Uint8Array of any length into a BigInt. If starting from * a hex value, consider using the BigInt constructor instead: * ``` * BigInt(`0x${hex}`) * ``` * * The `bytes` parameter can be set to constrain the expected length (default: * `bin.length`). This method throws if `bin.length` is not equal to `bytes`. * * @param bin - the Uint8Array to decode * @param bytes - the number of bytes to read (default: `bin.length`) */ export declare const binToBigIntUintBE: (bin: Uint8Array, bytes?: number) => bigint; /** * Decode an unsigned, 32-byte big-endian Uint8Array into a BigInt. This can be * used to decode Uint8Array-encoded cryptographic primitives like private * keys, public keys, curve parameters, and signature points. * * If starting from a hex value, consider using the BigInt constructor instead: * ``` * BigInt(`0x${hex}`) * ``` * @param bin - the Uint8Array to decode */ export declare const binToBigIntUint256BE: (bin: Uint8Array) => bigint; /** * Encode a positive BigInt into an unsigned 32-byte big-endian Uint8Array. This * can be used to encoded numbers for cryptographic primitives like private * keys, public keys, curve parameters, and signature points. * * Negative values will return the same result as `0`, values higher than * 2^256-1 will return the maximum expressible unsigned 256-bit value * (`0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`). * * @param value - the BigInt to encode */ export declare const bigIntToBinUint256BEClamped: (value: bigint) => Uint8Array; /** * Decode a little-endian Uint8Array of any length into a BigInt. * * The `bytes` parameter can be set to constrain the expected length (default: * `bin.length`). This method throws if `bin.length` is not equal to `bytes`. * * @param bin - the Uint8Array to decode * @param bytes - the number of bytes to read (default: `bin.length`) */ export declare const binToBigIntUintLE: (bin: Uint8Array, bytes?: number) => bigint; /** * Decode an 8-byte Uint64LE Uint8Array into a BigInt. * * Throws if `bin` is shorter than 8 bytes. * * @param bin - the Uint8Array to decode */ export declare const binToBigIntUint64LE: (bin: Uint8Array) => bigint; /** * Get the expected byte length of a Bitcoin VarInt given a first byte. * * @param firstByte - the first byte of the VarInt */ export declare const varIntPrefixToSize: (firstByte: number) => number; /** * Read a Bitcoin VarInt (Variable-length integer) from a Uint8Array, returning * the `nextOffset` after the VarInt and the value as a BigInt. * * @param bin - the Uint8Array from which to read the VarInt * @param offset - the offset at which the VarInt begins */ export declare const readBitcoinVarInt: (bin: Uint8Array, offset?: number) => { nextOffset: number; value: bigint; }; /** * Encode a positive BigInt as a Bitcoin VarInt (Variable-length integer). * * Note: the maximum value of a Bitcoin VarInt is `0xffff_ffff_ffff_ffff`. This * method will return an incorrect result for values outside of the range `0` to * `0xffff_ffff_ffff_ffff`. * * @param value - the BigInt to encode (no larger than `0xffff_ffff_ffff_ffff`) */ export declare const bigIntToBitcoinVarInt: (value: bigint) => Uint8Array; //# sourceMappingURL=numbers.d.ts.map