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
| Method | Postcondition |
|---|---|
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
jas a bit vector and just need the unary indicator, useUnary. - If you control how
jenters the circuit and want to save input wires, encode it as aUnaryPluckerpoint instead — one field-element input rather thanWbit-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