import { Fq, Fr } from '../fields/fields'; /** * The FieldReader class provides a utility for reading various data types from a field array. * * Usage: * Create a new instance of FieldReader with an array of fields and an optional offset. * Use the provided methods to read desired data types from the field array. * The reading methods automatically advance the internal index. */ export declare class FieldReader { private fields; private index; private readonly length; constructor(fields: Fr[], offset?: number); /** * Creates a FieldReader instance from either a field array or an existing FieldReader. * * @param fields - A field array or FieldReader to initialize the FieldReader. * @returns An instance of FieldReader. */ static asReader(fields: Fr[] | FieldReader): FieldReader; /** * Returns the current cursor position. * * @returns The current cursor position. */ get cursor(): number; remainingFields(): number; /** * Skips the next n fields. * * @param n - The number of fields to skip. */ skip(n: number): void; /** * Reads a single field from the array. * * @returns A field. */ readField(): Fr; /** * Peeks at the next field without advancing the cursor. * * @returns A field. */ peekField(): Fr; /** * Reads a Fq from the array. * * @returns An Fq. */ readFq(): Fq; /** * Reads and returns the next boolean value from the field array. * Advances the internal index by 1, treating the field at the current index as a boolean value. * Returns true if the field is non-zero, false otherwise. * Throw if the value is not 0 or 1. * * @returns A boolean value representing the field at the current index. */ readBoolean(): boolean; /** * Reads a 32-bit unsigned integer from the field array at the current index position. * Updates the index position by 1 after reading the number. * Throw if the value is greater than 2 ** 32. * * @returns The read 32-bit unsigned integer value. */ readU32(): number; /** * Reads a serialized object from a field array and returns the deserialized object using the given deserializer. * * @typeparam T - The type of the deserialized object. * @param deserializer - An object with a 'fromFields' method that takes a FieldReader instance and returns an instance of the deserialized object. * @returns The deserialized object of type T. */ readObject(deserializer: { /** * A method that takes a FieldReader instance and returns an instance of the deserialized data type. */ fromFields: (reader: FieldReader) => T; }): T; /** * Returns whether the reader has finished reading all fields. * @returns A bool. */ isFinished(): boolean; }