Currently, the divMod operation performs bitwise division. Under deterministic computational model, this is the only approach; with the new MonadCircuit interface, we can access the full power of circuit computational model to reduce the number of constraints dramatically.
The idea is: instead of "computing" divMod x y, we can "guess" the result d and m s.t. x = d * y + m and m < y. Outline of the algorithm:
compute witnesses for d and m;
range-constrain them so that values inside fit registers;
Currently, the
divMod
operation performs bitwise division. Under deterministic computational model, this is the only approach; with the newMonadCircuit
interface, we can access the full power of circuit computational model to reduce the number of constraints dramatically. The idea is: instead of "computing"divMod x y
, we can "guess" the resultd
andm
s.t.x = d * y + m
andm < y
. Outline of the algorithm:d
andm
;m
s.t.m < y
;x = d * y + m
.