summaryrefslogtreecommitdiffstats
path: root/vendor/elliptic-curve/src/point.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:47:55 +0000
commit2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4 (patch)
tree033cc839730fda84ff08db877037977be94e5e3a /vendor/elliptic-curve/src/point.rs
parentInitial commit. (diff)
downloadcargo-2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4.tar.xz
cargo-2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4.zip
Adding upstream version 0.70.1+ds1.upstream/0.70.1+ds1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/elliptic-curve/src/point.rs')
-rw-r--r--vendor/elliptic-curve/src/point.rs69
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/elliptic-curve/src/point.rs b/vendor/elliptic-curve/src/point.rs
new file mode 100644
index 0000000..25b872a
--- /dev/null
+++ b/vendor/elliptic-curve/src/point.rs
@@ -0,0 +1,69 @@
+//! Traits for elliptic curve points.
+
+#[cfg(feature = "arithmetic")]
+mod non_identity;
+
+#[cfg(feature = "arithmetic")]
+pub use {self::non_identity::NonIdentity, crate::CurveArithmetic};
+
+use crate::{Curve, FieldBytes};
+use subtle::{Choice, CtOption};
+
+/// Affine point type for a given curve with a [`CurveArithmetic`]
+/// implementation.
+#[cfg(feature = "arithmetic")]
+pub type AffinePoint<C> = <C as CurveArithmetic>::AffinePoint;
+
+/// Projective point type for a given curve with a [`CurveArithmetic`]
+/// implementation.
+#[cfg(feature = "arithmetic")]
+pub type ProjectivePoint<C> = <C as CurveArithmetic>::ProjectivePoint;
+
+/// Access to the affine coordinates of an elliptic curve point.
+// TODO: use zkcrypto/group#30 coordinate API when available
+pub trait AffineCoordinates {
+ /// Field element representation.
+ type FieldRepr: AsRef<[u8]>;
+
+ /// Get the affine x-coordinate as a serialized field element.
+ fn x(&self) -> Self::FieldRepr;
+
+ /// Is the affine y-coordinate odd?
+ fn y_is_odd(&self) -> Choice;
+}
+
+/// Double a point (i.e. add it to itself)
+pub trait Double {
+ /// Double this point.
+ fn double(&self) -> Self;
+}
+
+/// Decompress an elliptic curve point.
+///
+/// Point decompression recovers an original curve point from its x-coordinate
+/// and a boolean flag indicating whether or not the y-coordinate is odd.
+pub trait DecompressPoint<C: Curve>: Sized {
+ /// Attempt to decompress an elliptic curve point.
+ fn decompress(x: &FieldBytes<C>, y_is_odd: Choice) -> CtOption<Self>;
+}
+
+/// Decompact an elliptic curve point from an x-coordinate.
+///
+/// Decompaction relies on properties of specially-generated keys but provides
+/// a more compact representation than standard point compression.
+pub trait DecompactPoint<C: Curve>: Sized {
+ /// Attempt to decompact an elliptic curve point
+ fn decompact(x: &FieldBytes<C>) -> CtOption<Self>;
+}
+
+/// Point compression settings.
+pub trait PointCompression {
+ /// Should point compression be applied by default?
+ const COMPRESS_POINTS: bool;
+}
+
+/// Point compaction settings.
+pub trait PointCompaction {
+ /// Should point compaction be applied by default?
+ const COMPACT_POINTS: bool;
+}