Distance for modulus and support for Zq
Description
This PR implements the distance function for Modulus. It also implements the distance function for Z with support for Zq, since we have currently only implemented it for Zq with support for Z and not the other way around.
Testing
- [x] I added basic working examples (possibly in doc-comment)
- [x] I added tests for large (pointer representation) values
- [x] I triggered all possible errors in my test in every possible way
- [x] I included tests for all reasonable edge cases
Checklist:
- [x] I have performed a self-review of my own code
- [x] The code provides good readability and maintainability s.t. it fulfills best practices like talking code, modularity, ...
- [x] The chosen implementation is not more complex than it has to be
- [x] My code should work as intended and no side effects occur (e.g. memory leaks)
- [x] The doc comments fit our style guide
- [x] I have credited related sources if needed
- [x] The code provides good readability and maintainability s.t. it fulfills best practices like talking code, modularity, ...
There is a good reason, why I have not / we have decided not to implement distance for any mixes of Z and Zq values.
The distance for Z values is clearly defined: |x-y|.
The distance for Zq values is clearly defined: min{|x-y mod q|, |y-x mod q|}.
But for the mix, there no clear definition. Therefore, we decided not to provide the function and I would leave it at that.
The same question arises for any mix of Modulus, Z, and Zq values. How is it defined properly?
Nevertheless, I would question whether this function is ever going to be used / useful.