UNPKG

@axiom-crypto/tools

Version:

Useful data, field, and byte manipulation tools for Axiom.

57 lines (56 loc) 2.06 kB
export declare class ByteStringReader { currentIdx: number; byteString: string; constructor(byteString: string); /** * Sets the current index of the reader * @param idx Index value to set `currentIdx` to */ setIndex(idx: number): void; /** * Gets the number of bytes remaining in the hexString */ getNumBytesRemaining(): number; /** * Reads `numBytes` from the byteString as an integer * @param numBytes Number of bytes to read * @returns An integer */ readInt(numBytes: number | string): number; /** * Reads numBytes bytes from the byteString and returns them as a hex string * @param numBytes Number of bytes to read * @returns Hex string of the bytes read */ readBytes(numBytes: number | string): string; /** * Moves `currentIdx` forward by `numBytes` bytes * @param numBytes Number of bytes to skip */ skipBytes(numBytes: number): void; /** * Reads a variable length amount of bytes, with the first `numLenBytes` bytes representing the * length, and the remaining `len` bytes representing the value. * @param numLenBytes Number of bytes to read for the length * @returns The value from the bytes read */ readVarLenBytes(numLenBytes: number): string; /** * Reads a `len` number of bytes32 values from the byteString * @param len Number of bytes32 values to read * @returns An array of bytes32 values */ readFixedLenBytes32(len: number): string[]; /** * Checks that all bytes in the byteString have been read * @returns true if all bytes in the byteString have been read, false otherwise */ validateAllBytesRead(): boolean; /** * Gets a slice of the current byteString in number of bytes (number of string chars * 2) * @param index Index to start slice * @param numBytes Number of bytes to include in slice * @returns Hexstring of the byte slice */ getByteSlice(index: number, numBytes: number): string; }