From 38aa0ee2b7fb2c02194a7cd2c301ba9c6ce9b54e Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Fri, 20 Jul 2018 00:47:33 +0000 Subject: [PATCH] Implement Default for remaining point types. * FIXES https://github.com/dalek-cryptography/curve25519-dalek/issues/154 --- src/edwards.rs | 12 ++++++++++++ src/montgomery.rs | 6 ++++++ src/ristretto.rs | 12 ++++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/edwards.rs b/src/edwards.rs index 08eff32..aa22b67 100644 --- a/src/edwards.rs +++ b/src/edwards.rs @@ -257,6 +257,12 @@ impl Identity for CompressedEdwardsY { } } +impl Default for CompressedEdwardsY { + fn default() -> CompressedEdwardsY { + CompressedEdwardsY::identity() + } +} + impl Identity for EdwardsPoint { fn identity() -> EdwardsPoint { EdwardsPoint{ X: FieldElement::zero(), @@ -266,6 +272,12 @@ impl Identity for EdwardsPoint { } } +impl Default for EdwardsPoint { + fn default() -> EdwardsPoint { + EdwardsPoint::identity() + } +} + // ------------------------------------------------------------------------ // Validity checks (for debugging, not CT) // ------------------------------------------------------------------------ diff --git a/src/montgomery.rs b/src/montgomery.rs index 0c21b00..68b871a 100644 --- a/src/montgomery.rs +++ b/src/montgomery.rs @@ -155,6 +155,12 @@ impl Identity for ProjectivePoint { } } +impl Default for ProjectivePoint { + fn default() -> ProjectivePoint { + ProjectivePoint::identity() + } +} + impl ConditionallyAssignable for ProjectivePoint { fn conditional_assign(&mut self, that: &ProjectivePoint, choice: Choice) { self.U.conditional_assign(&that.U, choice); diff --git a/src/ristretto.rs b/src/ristretto.rs index cb4e8e0..978f78c 100644 --- a/src/ristretto.rs +++ b/src/ristretto.rs @@ -279,6 +279,12 @@ impl Identity for CompressedRistretto { } } +impl Default for CompressedRistretto { + fn default() -> CompressedRistretto { + CompressedRistretto::identity() + } +} + // ------------------------------------------------------------------------ // Serde support // ------------------------------------------------------------------------ @@ -661,6 +667,12 @@ impl Identity for RistrettoPoint { } } +impl Default for RistrettoPoint { + fn default() -> RistrettoPoint { + RistrettoPoint::identity() + } +} + // ------------------------------------------------------------------------ // Equality // ------------------------------------------------------------------------