mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-04 20:24:10 +00:00
Only compress ExtendedPoints
This commit is contained in:
parent
7f52745770
commit
8337a895d4
2 changed files with 8 additions and 13 deletions
|
|
@ -232,18 +232,6 @@ impl ProjectivePoint {
|
|||
}
|
||||
}
|
||||
|
||||
/// Convert this point to a `CompressedEdwardsY`
|
||||
pub fn compress(&self) -> CompressedEdwardsY {
|
||||
let recip = self.Z.invert();
|
||||
let x = &self.X * &recip;
|
||||
let y = &self.Y * &recip;
|
||||
let mut s: [u8; 32];
|
||||
|
||||
s = y.to_bytes();
|
||||
s[31] ^= (x.is_negative() << 7) as u8;
|
||||
CompressedEdwardsY(s)
|
||||
}
|
||||
|
||||
/// Convert this projective point in the Edwards model to its equivalent
|
||||
/// projective point on the Montgomery form of the curve.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -277,7 +277,14 @@ impl ExtendedPoint {
|
|||
|
||||
/// Compress this point to `CompressedEdwardsY` format.
|
||||
pub fn compress(&self) -> CompressedEdwardsY {
|
||||
self.to_projective().compress()
|
||||
let recip = self.Z.invert();
|
||||
let x = &self.X * &recip;
|
||||
let y = &self.Y * &recip;
|
||||
let mut s: [u8; 32];
|
||||
|
||||
s = y.to_bytes();
|
||||
s[31] ^= (x.is_negative() << 7) as u8;
|
||||
CompressedEdwardsY(s)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue