From b4d41b689c6c1710ce083c24860ad54ebd3ba82f Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Fri, 27 Jul 2018 17:36:17 -0600 Subject: [PATCH] Add must_use to operations over Edwards/Montgomery points. --- src/jubjub/edwards.rs | 5 +++++ src/jubjub/montgomery.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/jubjub/edwards.rs b/src/jubjub/edwards.rs index 73f0dfc..e91455c 100644 --- a/src/jubjub/edwards.rs +++ b/src/jubjub/edwards.rs @@ -164,6 +164,7 @@ impl Point { } /// This guarantees the point is in the prime order subgroup + #[must_use] pub fn mul_by_cofactor(&self, params: &E::Params) -> Point { let tmp = self.double(params) @@ -346,6 +347,7 @@ impl Point { (x, y) } + #[must_use] pub fn negate(&self) -> Self { let mut p = self.clone(); @@ -355,6 +357,7 @@ impl Point { p } + #[must_use] pub fn double(&self, _: &E::Params) -> Self { // See "Twisted Edwards Curves Revisited" // Huseyin Hisil, Kenneth Koon-Ho Wong, Gary Carter, and Ed Dawson @@ -423,6 +426,7 @@ impl Point { } } + #[must_use] pub fn add(&self, other: &Self, params: &E::Params) -> Self { // See "Twisted Edwards Curves Revisited" @@ -495,6 +499,7 @@ impl Point { } } + #[must_use] pub fn mul::Repr>>( &self, scalar: S, diff --git a/src/jubjub/montgomery.rs b/src/jubjub/montgomery.rs index 2243877..18d0fcb 100644 --- a/src/jubjub/montgomery.rs +++ b/src/jubjub/montgomery.rs @@ -97,6 +97,7 @@ impl Point { } /// This guarantees the point is in the prime order subgroup + #[must_use] pub fn mul_by_cofactor(&self, params: &E::Params) -> Point { let tmp = self.double(params) @@ -216,6 +217,7 @@ impl Point { } } + #[must_use] pub fn negate(&self) -> Self { let mut p = self.clone(); @@ -224,6 +226,7 @@ impl Point { p } + #[must_use] pub fn double(&self, params: &E::Params) -> Self { if self.infinity { return Point::zero(); @@ -280,6 +283,7 @@ impl Point { } } + #[must_use] pub fn add(&self, other: &Self, params: &E::Params) -> Self { // This is a standard affine point addition formula @@ -330,6 +334,7 @@ impl Point { } } + #[must_use] pub fn mul::Repr>>( &self, scalar: S,