Skip to content

@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

@circom:field.bits(value count)
NameTypeDescription
valuenumberValue to decompose (must fit in count bits)
countnumberNumber of bits to produce (1-254)
# Turn a Merkle path index into the per-level indices a circuit expects
set $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 (Num2Bits order).