elliptic_curve/
point.rs

1//! Traits for elliptic curve points.
2
3use crate::{Curve, FieldBytes};
4use subtle::{Choice, CtOption};
5
6/// Obtain the affine x-coordinate of an elliptic curve point.
7pub trait AffineXCoordinate<C: Curve> {
8    /// Get the affine x-coordinate as a serialized field element.
9    fn x(&self) -> FieldBytes<C>;
10}
11
12/// Decompress an elliptic curve point.
13///
14/// Point decompression recovers an original curve point from its x-coordinate
15/// and a boolean flag indicating whether or not the y-coordinate is odd.
16pub trait DecompressPoint<C: Curve>: Sized {
17    /// Attempt to decompress an elliptic curve point.
18    fn decompress(x: &FieldBytes<C>, y_is_odd: Choice) -> CtOption<Self>;
19}
20
21/// Decompact an elliptic curve point from an x-coordinate.
22///
23/// Decompaction relies on properties of specially-generated keys but provides
24/// a more compact representation than standard point compression.
25pub trait DecompactPoint<C: Curve>: Sized {
26    /// Attempt to decompact an elliptic curve point
27    fn decompact(x: &FieldBytes<C>) -> CtOption<Self>;
28}
29
30/// Point compression settings.
31pub trait PointCompression {
32    /// Should point compression be applied by default?
33    const COMPRESS_POINTS: bool;
34}
35
36/// Point compaction settings.
37pub trait PointCompaction {
38    /// Should point compaction be applied by default?
39    const COMPACT_POINTS: bool;
40}