@circom:field.bits
Decompose a value into its bits, least-significant first, e.g. a Merkle path index into the per-level indices a circuit expects.
⚗️ Experimental — available at next.evmcrispr.com.
Returns: array
Syntax
Section titled “Syntax”@circom:field.bits(value count)Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
value | number | Value to decompose (must fit in count bits) |
count | number | Number of bits to produce (1-254) |
Examples
Section titled “Examples”# Turn a Merkle path index into the per-level indices a circuit expectsset $leaves [1234 5678 9012]set [$index $siblings $len] @circom:tree.proof($leaves 1 pad:10)print "Indices:" @circom:field.bits($index 10)- Bits come out least-significant first, matching how circuits fold Merkle path indices (
Num2Bitsorder).
See Also
Section titled “See Also”- @circom:tree.proof — the path index this typically decomposes