Module kimchi::snarky::snarky_type

source ·
Expand description

The SnarkyType trait is a useful trait that allows us to define our own snarky variables on top of FieldVar. Without it, we’d be limited to using the FieldVar type directly, handling and returning arrays of FieldVars all the time. So this is useful for the same reason that programming languages allow users to define their own types, instead of relying only on usize.

To define your own snarky type, implement the SnarkyType trait. A good example is the Boolean type.

Traits

  • A trait to convert between a snarky type and its out-of-circuit equivalent.
  • A snarky type is a type that can be used in a circuit. It references an equivalent “out-of-circuit” type that one can use outside of the circuit. (For example, to construct private or public inputs, or a public output, to the circuit.)