Try   HackMD

Proposal to modify chiquito step definition

Current state

Currently a step is defined the following way:

ctx.step_type_def(step1, |ctx| { // define internal signals let c = ctx.internal("c") // ... // define internal constraints ctx.constr(eq(a + b, c)); // ... // define transition constraints ctx.transition(eq(b, a.next())); // ... // witness generation or assignation ctx.wg(move |ctx, (a_value, b_value)| { ctx.assign(a, a_value.field()); // ... }); });

Note that in this example "a" and "b" are forward signals declared outside the step type.

Problem

We have observed that new developers have problems differentiation the assignation from the setup in Chiquito, and some times try to use the setup expressions for the assignation.

Proposed solution

We would make setup inside a new lambda, that is at the same level of witness assignation, so it is clear due to scope that one cannot access the constraints from the assignation. Also, perhaps, rename "wg" to assign, that is more clear.

Example:

ctx.step_type_def(step1, |ctx| { // define internal signals let c = ctx.internal("c") // ... ctx.setup(move |ctx| { // define internal constraints ctx.constr(eq(a + b, c)); // ... // define transition constraints ctx.transition(eq(b, a.next())); // ... }); // witness generation or assignation ctx.assign(move |ctx, (a_value, b_value)| { ctx.assign(a, a_value.field()); // ... }); });

Alternatives

Perhaps there are better keywords than "setup" and "assign"?

Perhaps it is better to separate the setup in internal and transition? Like here:

ctx.step_type_def(step1, |ctx| { // define internal signals let c = ctx.internal("c") // ... ctx.setup_internal(move |ctx| { // define internal constraints ctx.constr(eq(a + b, c)); // ... }); ctx.setup_transition(move |ctx| { // define transition constraints ctx.constr(eq(b, a.next())); // ... }); // witness generation or assignation ctx.assign(move |ctx, (a_value, b_value)| { ctx.assign(a, a_value.field()); // ... }); });