From 9fda4739d0635df7772223cf68dc8fe590aab773 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Fri, 17 Nov 2017 15:42:37 -0800 Subject: [PATCH] Hide fns using private types --- src/curve_models/mod.rs | 5 +++++ src/edwards.rs | 12 ++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/curve_models/mod.rs b/src/curve_models/mod.rs index 7364c2a..0fe5609 100644 --- a/src/curve_models/mod.rs +++ b/src/curve_models/mod.rs @@ -280,6 +280,8 @@ impl ProjectivePoint { // Addition and Subtraction // ------------------------------------------------------------------------ +// These are doc(hidden) so they don't appear in the public API docs. +#[doc(hidden)] impl<'a, 'b> Add<&'b ProjectiveNielsPoint> for &'a ExtendedPoint { type Output = CompletedPoint; @@ -301,6 +303,7 @@ impl<'a, 'b> Add<&'b ProjectiveNielsPoint> for &'a ExtendedPoint { } } +#[doc(hidden)] impl<'a, 'b> Sub<&'b ProjectiveNielsPoint> for &'a ExtendedPoint { type Output = CompletedPoint; @@ -322,6 +325,7 @@ impl<'a, 'b> Sub<&'b ProjectiveNielsPoint> for &'a ExtendedPoint { } } +#[doc(hidden)] impl<'a, 'b> Add<&'b AffineNielsPoint> for &'a ExtendedPoint { type Output = CompletedPoint; @@ -342,6 +346,7 @@ impl<'a, 'b> Add<&'b AffineNielsPoint> for &'a ExtendedPoint { } } +#[doc(hidden)] impl<'a, 'b> Sub<&'b AffineNielsPoint> for &'a ExtendedPoint { type Output = CompletedPoint; diff --git a/src/edwards.rs b/src/edwards.rs index 7fff8d8..9fa17b3 100644 --- a/src/edwards.rs +++ b/src/edwards.rs @@ -233,7 +233,7 @@ impl Equal for ExtendedPoint { impl ExtendedPoint { /// Convert to a ProjectiveNielsPoint - pub fn to_projective_niels(&self) -> ProjectiveNielsPoint { + pub(crate) fn to_projective_niels(&self) -> ProjectiveNielsPoint { ProjectiveNielsPoint{ Y_plus_X: &self.Y + &self.X, Y_minus_X: &self.Y - &self.X, @@ -247,7 +247,7 @@ impl ExtendedPoint { /// /// Given a point in Ɛₑ, we can convert to projective coordinates /// cost-free by simply ignoring T. - fn to_projective(&self) -> ProjectivePoint { + pub(crate) fn to_projective(&self) -> ProjectivePoint { ProjectivePoint{ X: self.X, Y: self.Y, @@ -257,7 +257,7 @@ impl ExtendedPoint { /// Dehomogenize to a AffineNielsPoint. /// Mainly for testing. - pub fn to_affine_niels(&self) -> AffineNielsPoint { + pub(crate) fn to_affine_niels(&self) -> AffineNielsPoint { let recip = self.Z.invert(); let x = &self.X * &recip; let y = &self.Y * &recip; @@ -647,17 +647,13 @@ impl EdwardsBasepointTable { impl ExtendedPoint { /// Multiply by the cofactor: compute `8 * self`. - /// - /// Convenience wrapper around `mult_by_pow_2`. - #[inline] pub fn mult_by_cofactor(&self) -> ExtendedPoint { self.mult_by_pow_2(3) } /// Compute `2^k * self` by successive doublings. /// Requires `k > 0`. - #[inline] - pub fn mult_by_pow_2(&self, k: u32) -> ExtendedPoint { + pub(crate) fn mult_by_pow_2(&self, k: u32) -> ExtendedPoint { let mut r: CompletedPoint; let mut s = self.to_projective(); for _ in 0..(k-1) {