mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-08 21:00:40 +00:00
Merge pull request #352 from isislovecruft/feature/montgomery-identity
Implement Identity for MontgomeryPoint.
This commit is contained in:
commit
b61831b7cf
1 changed files with 20 additions and 0 deletions
|
|
@ -94,6 +94,13 @@ impl PartialEq for MontgomeryPoint {
|
||||||
|
|
||||||
impl Eq 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 {
|
impl Zeroize for MontgomeryPoint {
|
||||||
fn zeroize(&mut self) {
|
fn zeroize(&mut self) {
|
||||||
self.0.zeroize();
|
self.0.zeroize();
|
||||||
|
|
@ -351,6 +358,19 @@ mod test {
|
||||||
|
|
||||||
use rand_core::OsRng;
|
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]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde_bincode_basepoint_roundtrip() {
|
fn serde_bincode_basepoint_roundtrip() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue