Merge pull request #260 from fabric-and-ink/ed-decompress-simplify

Remove unneeded check for negativity in edwards point decompression
This commit is contained in:
Henry de Valence 2019-08-07 12:57:24 -07:00 committed by GitHub
commit b01888a929
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -190,11 +190,10 @@ impl CompressedEdwardsY {
if is_valid_y_coord.unwrap_u8() != 1u8 { return None; }
// Flip the sign of X if it's not correct
// FieldElement::sqrt_ratio_i always returns the nonnegative square root,
// so we negate according to the supplied sign bit.
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 })
}