Remove unneeded check for negativity in edwards point decompression

The function `FieldElement::sqrt_ratio_i` always returns a positive root
by definition. Therefore the test for negativity in the edwards point
decompression function always returns false and we only need to flip its
sign if `compressed_sign_bit` is set.
This commit is contained in:
Fabian Drinck 2019-06-07 18:41:26 +02:00
parent a659b92305
commit 53da2aaaf4

View file

@ -192,9 +192,7 @@ impl CompressedEdwardsY {
// Flip the sign of X if it's not correct
let compressed_sign_bit = Choice::from(self.as_bytes()[31] >> 7);
let current_sign_bit = X.is_negative();
X.conditional_negate(current_sign_bit ^ compressed_sign_bit);
X.conditional_negate(compressed_sign_bit);
Some(EdwardsPoint{ X: X, Y: Y, Z: Z, T: &X * &Y })
}