|
LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
|
llzk-witgen --output-wtns <file> writes the version 2 binary witness format consumed by snarkjs. The implementation follows the snarkjs WTNS writer.
All integers and field elements are little-endian.
| Field | Encoding |
|---|---|
| Magic | Four bytes: wtns |
| Version | u32, currently 2 |
| Section count | u32, currently 2 |
Each section begins with a u32 section type and a u64 payload size.
Section 1 is the witness header:
| Field | Encoding |
|---|---|
| Field element width | u32 bytes, rounded up to a 64-bit limb |
| Prime modulus | Exactly the field element width in bytes |
| Witness length | u32 |
Section 2 contains witness length field elements, each encoded using the width declared by section 1.
The witness order must match LLZK's R1CS binary exporter:
Input visibility comes from the corresponding arguments of @constrain, as it does in the R1CS lowering pass. The first @constrain argument is self and is not an R1CS input.
The current WTNS writer supports scalar felt inputs and main members. It also cross-checks its witness length against an R1CS-lowered clone of the module. Circuits that require synthesized R1CS auxiliary wires are rejected until witgen can materialize those auxiliary values. Unsupported aggregates and wire count mismatches are therefore diagnosed rather than silently serialized.