I was attempting to figure out a way to implement the modulo operation as a set of gates in an Rank-1 Constraint System, detailed by Vitalik Buterin here
However, it occurred to me that maybe we don't actually need to break down each step of the calculation into an R1CS gate, as long we sufficiently implement gates which verify the prover performed the calculation correctly.
So instead of a complicated series of gates, the following calculations can be performed "behind the scenes" (assuming unsigned ints):
m = x % y d = x // y
And the gates in our R1CS only need to consist of:
x = d*y + m m < y
(I am aware that m < y is a tad complicated, but not nearly as complicated as actually performing the modulo operation itself)
Am I correct that we should only include the bare minimum constraints? Or are there some sort of security flaws when doing this and it is better to have a more complicated system of gates to validate every step of the calculation?