Skip to main content

Module descriptor

Module descriptor 

Source
Expand description

Descriptor → AlignedValue helpers.

The IR’s descriptors table assigns numeric IDs to every type that appears at a runtime boundary. Encoding a JSON literal into an AlignedValue (Compact’s wire-format atom) requires knowing the target descriptor: a Uint<16> literal of 5 is one byte sequence; a Uint<64> literal of 5 is a different one. This module is the mapping from descriptor + JSON value to AlignedValue.

Structs§

CircuitInputPlan
Pre-compiled encoder for a circuit’s full argument tuple (encode_input).
FabPlan
Pre-compiled FAB AlignedValue encoder for a TypeDescriptor.

Functions§

decode_aligned_value
Decode an AlignedValue to a JSON value typed by descriptor — the inverse of encode_literal. Used both to decode circuit arguments back into JSON-shaped local bindings and to surface popeq read results (Cell.read, Map.lookup, etc.) inside the interpreter.
decode_aligned_value_full
Convenience wrapper: decode a complete AlignedValue against a descriptor and verify exact atom count.
encode_bool
Encode a boolean literal.
encode_bytes
Encode a fixed-length Bytes literal. Accepts hex-encoded strings.
encode_default
Produce the wire-format zero AlignedValue for any descriptor — the value {vm: null, type: ...} carries in IR pushdowns. Recurses through compound types so a default Either is (false, default ZswapCoinPublicKey, default ContractAddress), etc.
encode_field
Encode a Field literal as an AlignedValue with AlignmentAtom::Field (matches the upstream Aligned for Fr impl in transient-crypto/src/curve.rs:291).
encode_literal
Convert a JSON literal to an AlignedValue typed by descriptor.
encode_uint
Encode a Uint literal sized by its maxval. Picks the alignment width matching the JS backend’s _descriptor_N-emit convention: ≤ u8::MAX → 1 byte, ≤ u16::MAX → 2 bytes, ≤ u32::MAX → 4 bytes, ≤ u64::MAX → 8 bytes, otherwise 16 bytes.
json_as_u128
Decode a JSON value as u128. Accepts unsigned numbers and decimal strings (matching the IR’s big-int convention).