Add prime constraint to inverse function #100
Labels
core-utilities
good first issue
Good for newcomers
improvement
Addresses fixes or changes to existing specs
The
mp_mod_inv
method inCommon/utils.cry
is used in several places, but its type signature is not correct; it's only a valid function when the modulus is prime. Cryptol has evolved since that function was first written in 2018, so now I see two options to make it correct:prime p
constraint to the function type constraintrecip
and/or/.
cryptol-native operators onZ
types.I did a quick review of all the modules that use this and it looks like they do all use it correctly (e.g. with a prime modulus). If we choose option 1, there will be some cascading work to add the
prime
constraint up the call chain, but that seems worth the precision to me.That said, if the built-in operations do what I think they do (compute the multiplicative inverse and do modulus-respecting division), we should use those. We might consider improving documentation on those as well, to be explicit about any additional constraints they may have (e.g. does the modulus have to be prime for those operations? I don't know).
The text was updated successfully, but these errors were encountered: