import { Fr } from '@aztec/foundation/curves/bn254'; import { bufferSchemaFor } from '@aztec/foundation/schemas'; import { BufferReader, bigintToUInt64BE, serializeToBuffer } from '@aztec/foundation/serialize'; import { AztecAddress } from '../aztec-address/index.js'; import { PrivateTxConstantData } from '../tx/private_tx_constant_data.js'; import type { UInt64 } from '../types/shared.js'; import { PrivateAccumulatedData } from './private_accumulated_data.js'; import { PrivateValidationRequests } from './private_validation_requests.js'; import { PublicCallRequest } from './public_call_request.js'; /** * Public inputs to the inner private kernel circuit */ export class PrivateKernelCircuitPublicInputs { constructor( /** * Data which is not modified by the circuits. */ public constants: PrivateTxConstantData, /** * The side effect counter that non-revertible side effects are all beneath. */ public minRevertibleSideEffectCounter: Fr, /** * Validation requests accumulated from public functions. */ public validationRequests: PrivateValidationRequests, /** * Data accumulated from both public and private circuits. */ public end: PrivateAccumulatedData, /** * The call request for the public teardown function */ public publicTeardownCallRequest: PublicCallRequest, /** * The address of the fee payer for the transaction */ public feePayer: AztecAddress, /** * The timestamp by which the transaction must be included in a block. */ public expirationTimestamp: UInt64, /** * Wether this is a private only tx or not */ public isPrivateOnly: boolean, /** * The nullifier that will be used for nonce generation */ public claimedFirstNullifier: Fr, /** * A claim to the final min revertible side effect counter of a tx. */ public claimedRevertibleCounter: number, ) {} static get schema() { return bufferSchemaFor(PrivateKernelCircuitPublicInputs); } toJSON() { return this.toBuffer(); } toBuffer() { return serializeToBuffer( this.constants, this.minRevertibleSideEffectCounter, this.validationRequests, this.end, this.publicTeardownCallRequest, this.feePayer, bigintToUInt64BE(this.expirationTimestamp), this.isPrivateOnly, this.claimedFirstNullifier, this.claimedRevertibleCounter, ); } /** * Deserializes from a buffer or reader, corresponding to a write in cpp. * @param buffer - Buffer or reader to read from. * @returns A new instance of PrivateKernelInnerCircuitPublicInputs. */ static fromBuffer(buffer: Buffer | BufferReader): PrivateKernelCircuitPublicInputs { const reader = BufferReader.asReader(buffer); return new PrivateKernelCircuitPublicInputs( reader.readObject(PrivateTxConstantData), reader.readObject(Fr), reader.readObject(PrivateValidationRequests), reader.readObject(PrivateAccumulatedData), reader.readObject(PublicCallRequest), reader.readObject(AztecAddress), reader.readUInt64(), reader.readBoolean(), reader.readObject(Fr), reader.readNumber(), ); } static empty() { return new PrivateKernelCircuitPublicInputs( PrivateTxConstantData.empty(), Fr.zero(), PrivateValidationRequests.empty(), PrivateAccumulatedData.empty(), PublicCallRequest.empty(), AztecAddress.ZERO, 0n, false, Fr.zero(), 0, ); } }