You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current design of non-native field arithmetics treats non-native field gadgets and their multiplication results separately. This causes code duplication, as the arithmetic operations on multiplication results (as well as reduction to normal form) is identical to that of normal non-native gadgets. I therefore propose to
unify NonNativeFieldGadget and NonNativeFieldMultResultGadget: A unification of these gadgets by a sinlge non-native field gadgets which allows up to the double number of limbs (than that of the modulus) clarifies the architecture of non-native arithmetics, and moreover allows the extend the greedy pre-reduction strategy to multiplication results.
Currently, the parameters are chosen by find_parameters() as the minimum number of constraints for a multiplication and post-reduction of two non-native gadgets, assuming SURFEIT=10. I doubt that this approach is optimal, as the optimum depends on the specific arithmetic "network" to be simulated. For this reason I propose a
different treatment of parameters: Let us introduce separate NonNativeFieldParameters to allow a manual specification, and let us run find_parameters() over the real constraint counts provided by ConstraintSystem. As reference circuit one can use again multiplication with post-reduction, or a custom circuit provided by the user.
A further improvement on the code structure would be to
implement big integer gadgets: The key principle of simulating non-native field arithmetics is its translation of mod p identities to big integer equalities. In particular, the core piece is the grouped normalization procedure group_and_check_equality() , which checks the equality of big integers with oversized limbs. As big integer gadgets might be useful in application circuits anyway, I propose to implement the simulation of non-reduced big integer arithmetics, and build the non-native field arithmetics on top of it.
The current design of non-native field arithmetics treats non-native field gadgets and their multiplication results separately. This causes code duplication, as the arithmetic operations on multiplication results (as well as reduction to normal form) is identical to that of normal non-native gadgets. I therefore propose to
NonNativeFieldGadgetandNonNativeFieldMultResultGadget: A unification of these gadgets by a sinlge non-native field gadgets which allows up to the double number of limbs (than that of the modulus) clarifies the architecture of non-native arithmetics, and moreover allows the extend the greedy pre-reduction strategy to multiplication results.Currently, the parameters are chosen by
find_parameters()as the minimum number of constraints for a multiplication and post-reduction of two non-native gadgets, assumingSURFEIT=10. I doubt that this approach is optimal, as the optimum depends on the specific arithmetic "network" to be simulated. For this reason I propose aNonNativeFieldParametersto allow a manual specification, and let us runfind_parameters()over the real constraint counts provided byConstraintSystem. As reference circuit one can use again multiplication with post-reduction, or a custom circuit provided by the user.A further improvement on the code structure would be to
mod pidentities to big integer equalities. In particular, the core piece is the grouped normalization proceduregroup_and_check_equality(), which checks the equality of big integers with oversized limbs. As big integer gadgets might be useful in application circuits anyway, I propose to implement the simulation of non-reduced big integer arithmetics, and build the non-native field arithmetics on top of it.