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
Some software optimization for special primes uses unnormalized representations. For example, when two numbers are added together, the number does not always be smaller than the modulus. The same can hold for multiplication. In such situations, 1 and p+1 may both be valid results.
FpConfig allows certain level of flexibility.
We can make sure serialization always handles the normalized representation, by implementing the into_bigint in some special way.
But the problem rests on PartialEq and Eq.
Currently, PartialEq and Eq are auto-derived in Fp, which is auto-derived in BigInt as well. It examines the u64 limbs and require each limb to be the same. If we have 1 and p+1, PartialEq and Eq will return negative for them.
To solve this problem, it is advisable to add a method in FpConfig, likely called normalize, which supposedly modify p+1 into 1. Instead of auto-deriving the PartialEq and Eq, we implement them manually with normalize.
The text was updated successfully, but these errors were encountered:
Some software optimization for special primes uses unnormalized representations. For example, when two numbers are added together, the number does not always be smaller than the modulus. The same can hold for multiplication. In such situations, 1 and p+1 may both be valid results.
FpConfig
allows certain level of flexibility.We can make sure serialization always handles the normalized representation, by implementing the
into_bigint
in some special way.But the problem rests on
PartialEq
andEq
.Currently,
PartialEq
andEq
are auto-derived inFp
, which is auto-derived inBigInt
as well. It examines the u64 limbs and require each limb to be the same. If we have 1 and p+1,PartialEq
andEq
will return negative for them.To solve this problem, it is advisable to add a method in
FpConfig
, likely callednormalize
, which supposedly modifyp+1
into1
. Instead of auto-deriving thePartialEq
andEq
, we implement them manually withnormalize
.The text was updated successfully, but these errors were encountered: