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
{{ message }}
Repository navigation
unexpected behaviour of get_representative_least_absolute_residue() #68
According to the documentation, get_representative_least_absolute_residue should do the following:
Returns the Z value of the Zq element with the representatives close to 0.
The output value is in the range of [-modulus/2, modulus/2]. For even moduli, the positive representative is chosen for the element modulus / 2. Use Zq::get_representative_least_nonnegative_residue if they should be in the range [0, modulus).
So for a value >= modulus / 2 it should output value - modulus. In reality it outputs modulus - value.
To Reproduce
use qfall_math::{integer::Z, integer_mod_q::Zq};let x = Zq::from((256,257));let actual = x.get_representative_least_absolute_residue();// 256 ≡ -1 (mod 257).assert_eq!(actual,Z::from(-1));
Fortunately, I encountered this issue myself whilst implementing qfall/schemes#10 (ML-DSA / Dilithium) and fixed it in qfall/math#531 (as it was an issue of qfall-math).
I took this issue as reason to specify the doc-comments further and include additional tests for this edge case in qfall/math#538.
The new release of qfall-math and qfall-tools (and qfall-schemes) in version 0.2 resolves the described issue.
Cheers!
Activity
jnsiemer commentedon Oct 20, 2026
Dear Jonas,
Thanks for making us aware of this issue.
Fortunately, I encountered this issue myself whilst implementing qfall/schemes#10 (ML-DSA / Dilithium) and fixed it in qfall/math#531 (as it was an issue of
qfall-math).I took this issue as reason to specify the doc-comments further and include additional tests for this edge case in qfall/math#538.
The new release of
qfall-mathandqfall-tools(andqfall-schemes) in version0.2resolves the described issue.Cheers!