3.1. Code assertions

Code assertions are introduced the following way:

assert(bool_expression);

This statement introduces conditions to be checked at construction time only.

The assert expression cannot depend on unknowns and this will be checked at construction time. If the condition fails, the compilation is aborted and the error is reported and no constraint is generated.

template Translate(n) {
assert(n>0);
assert(n<=254);
...
}

👉 When a constraint is introduced with the === operator, then an assert is automatically added in the witness generation code.