Eliminate extra inversions in MontgomeryPoint.ct_eq().

This commit is contained in:
Isis Lovecruft 2017-10-05 01:32:44 +00:00
parent 7e4fd5677c
commit 5e6e6c3fa8
Failed to extract signature

View file

@ -257,8 +257,9 @@ impl Identity for MontgomeryPoint {
/// `1` if the points are equal, and `0` otherwise.
impl Equal for MontgomeryPoint {
fn ct_eq(&self, that: &MontgomeryPoint) -> u8 {
slices_equal(self.compress().as_bytes(),
that.compress().as_bytes())
// (U_P:W_P) = (U_Q:W_Q) iff U_P * W_Q == U_Q * W_P,
// since U_P/W_P == U_Q/W_Q.
(&self.U * &that.W).ct_eq(&(&self.W * &that.U))
}
}