Skip to Content
⚠️ This documentation is AI-generated, for personal use only, and is not supported or endorsed by Google.

Unary<Logic>

Header: circuits/logic/unary.h

Naive decoders that turn a small wire-borne index into a per-position bit vector.

template <class Logic> class Unary { public: using BitW = typename Logic::BitW; explicit Unary(const Logic& l); template <size_t W> void eq(size_t n, BitW A[/*n*/], const typename Logic::template bitvec<W>& j) const; template <size_t W> void lt(size_t n, BitW A[/*n*/], const typename Logic::template bitvec<W>& j) const; };

Semantics

MethodPostcondition
eq(n, A, j)A[i] == 1 iff i == j, for 0 ≤ i < n
lt(n, A, j)A[i] == 1 iff i < j, for 0 ≤ i < n

Both methods iterate once per output index and delegate to Logic::veq / Logic::vlt.

When to use this vs. a plucker

  • If you already have j as a bit vector and just need the unary indicator, use Unary.
  • If you control how j enters the circuit and want to save input wires, encode it as a UnaryPlucker point instead — one field-element input rather than W bit-wire inputs.

Cost

The header notes that the eq circuit uses roughly N wires and N terms, and the lt circuit roughly N wires and 2N terms — so there is little room for optimization past the naive form.

Last updated on