Right now, it is not exactly clear where the definition of magnitude/normalization rules belongs:
- On the one hand, both implementations individually track these values separately (and have their own rules)
- On the other hand, callers of the field code are expected to simultaneously satisfy all of them.
With #967 things may become even more complicated as it adds a “precomputed” dimension (=reduced to 4 64-bit limbs instead of 5), but lacks the need for magnitudes as a concern.
So I think that we should make these rules part of the generic field interface, rather than part of the implementations. To avoid duplication, there could be a field_debug.h that implements these by “wrapping” the underlying field. It could be done by giving all field types/functions a suffix, and if debug is in use, have the real field functions forward to those, and if not, just #define fn fn_suffix
for all.
One reason for not doing this would be if we want to make group logic dependent on what the used field is (e.g. a field with laxer magnitude requirements could result in the group code emitting fewer normalization calls).