From bd1cc6c990d0603d15ab39811d3948ba094532d2 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Wed, 2 Sep 2020 09:13:51 -0700 Subject: [PATCH] elliptic-curve: extract point::Compression trait Move point compression defaults onto their own trait --- elliptic-curve/src/point.rs | 6 ++++++ elliptic-curve/src/sec1.rs | 4 +--- elliptic-curve/src/weierstrass.rs | 5 +---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/elliptic-curve/src/point.rs b/elliptic-curve/src/point.rs index 67a810a93..5a0ae58ae 100644 --- a/elliptic-curve/src/point.rs +++ b/elliptic-curve/src/point.rs @@ -1,5 +1,11 @@ //! Traits for elliptic curve points +/// Point compression settings +pub trait Compression { + /// Should point compression be applied by default? + const COMPRESS_POINTS: bool; +} + /// Obtain the generator point. pub trait Generator { /// Get the generator point for this elliptic curve diff --git a/elliptic-curve/src/sec1.rs b/elliptic-curve/src/sec1.rs index d59ab95a3..5445b0872 100644 --- a/elliptic-curve/src/sec1.rs +++ b/elliptic-curve/src/sec1.rs @@ -380,9 +380,7 @@ mod tests { type FieldSize = U32; } - impl weierstrass::Curve for ExampleCurve { - const COMPRESS_POINTS: bool = false; - } + impl weierstrass::Curve for ExampleCurve {} type EncodedPoint = super::EncodedPoint; diff --git a/elliptic-curve/src/weierstrass.rs b/elliptic-curve/src/weierstrass.rs index c87a54ed2..ba05927ba 100644 --- a/elliptic-curve/src/weierstrass.rs +++ b/elliptic-curve/src/weierstrass.rs @@ -3,7 +3,4 @@ pub mod point; /// Marker trait for elliptic curves in short Weierstrass form -pub trait Curve: super::Curve { - /// Should point compression be applied by default? - const COMPRESS_POINTS: bool; -} +pub trait Curve: super::Curve {}