mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-04 20:24:10 +00:00
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:
commit
b01888a929
1 changed files with 3 additions and 4 deletions
|
|
@ -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 })
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue