diff --git a/src/curve.rs b/src/curve.rs index 529f396..200dd19 100644 --- a/src/curve.rs +++ b/src/curve.rs @@ -159,7 +159,7 @@ impl CompressedEdwardsY { X *= &constants::SQRT_M1; } - if X.is_negative() != (self[31] >> 7) as i32 { + if X.is_negative_ed25519() != (self[31] >> 7) as i32 { X = X.neg(); } T = &X * &Y; @@ -391,7 +391,7 @@ impl ProjectivePoint { let mut s: [u8; 32]; s = y.to_bytes(); - s[31] ^= (x.is_negative() << 7) as u8; + s[31] ^= (x.is_negative_ed25519() << 7) as u8; CompressedEdwardsY(s) } } diff --git a/src/field.rs b/src/field.rs index f26108d..572b39f 100644 --- a/src/field.rs +++ b/src/field.rs @@ -510,13 +510,14 @@ impl FieldElement { (!equal_so_far & 1 & greater) as u8 } - /// Determine if this `FieldElement` is negative. + /// Determine if this `FieldElement` is negative, in the + /// sense used in the ed25519 paper. /// /// # Return /// /// If negative, return `1i32`. Otherwise, return `0i32`. // XXX should return u8 - pub fn is_negative(&self) -> i32 { //FeIsNegative + pub fn is_negative_ed25519(&self) -> i32 { //FeIsNegative let bytes = self.to_bytes(); (bytes[0] & 1) as i32 }