Reference
Reference

Serialization — @zentra/serialization

The byte-exact public-input codec shared by the circuit, contract, and SDK.

@zentra/serialization is the single place the public-input encoding is defined, so the circuit, contract, and SDK can never disagree.

Field modulus

FR_MODULUS = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;

Public input order

PUBLIC_INPUT_ORDER is the 14 names, in the order shown in the circuit reference.

Functions

modFr(x: bigint): bigint
fieldToBytes32(x: bigint): Uint8Array
bytes32ToField(b: Uint8Array): bigint
amountToField(x: bigint): bigint
addressToField(addr: string): bigint
toHex(b: Uint8Array): string
encodePublicInputs(values): Uint8Array[]
publicInputsToDecimal(values): string[]

Byte layouts

ValueLayout
Fr32 bytes, big-endian, reduced mod r
address32-byte payload reduced mod r
i128right-aligned: 16 zero bytes ‖ 16 value bytes (BE)
u64right-aligned: 24 zero bytes ‖ 8 value bytes (BE)

One source, three consumers

A serialization mismatch is the highest-risk bug in a system like this. Defining the codec once — and asserting cross-language golden vectors against it — is what keeps snarkjs and the Soroban verifier byte-for-byte aligned.