Skip to content

Commit

Permalink
Merge pull request #352 from isislovecruft/feature/montgomery-identity
Browse files Browse the repository at this point in the history
Implement Identity for MontgomeryPoint.
  • Loading branch information
isislovecruft authored Apr 21, 2021
2 parents 032a14c + d7c2a13 commit b61831b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/montgomery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ impl PartialEq for MontgomeryPoint {

impl Eq for MontgomeryPoint {}

impl Identity for MontgomeryPoint {
/// Return the group identity element, which has order 4.
fn identity() -> MontgomeryPoint {
MontgomeryPoint([0u8; 32])
}
}

impl Zeroize for MontgomeryPoint {
fn zeroize(&mut self) {
self.0.zeroize();
Expand Down Expand Up @@ -351,6 +358,19 @@ mod test {

use rand_core::OsRng;

#[test]
fn identity_in_different_coordinates() {
let id_projective = ProjectivePoint::identity();
let id_montgomery = id_projective.to_affine();

assert!(id_montgomery == MontgomeryPoint::identity());
}

#[test]
fn identity_in_different_models() {
assert!(EdwardsPoint::identity().to_montgomery() == MontgomeryPoint::identity());
}

#[test]
#[cfg(feature = "serde")]
fn serde_bincode_basepoint_roundtrip() {
Expand Down

0 comments on commit b61831b

Please sign in to comment.