Skip to main content

elliptic_curve/
weierstrass.rs

1//! Elliptic curves in short Weierstrass form.
2
3use crate::FieldBytes;
4use subtle::{Choice, CtOption};
5
6/// Marker trait for elliptic curves in short Weierstrass form.
7pub trait Curve: super::Curve {}
8
9/// Point compression settings.
10pub trait PointCompression {
11    /// Should point compression be applied by default?
12    const COMPRESS_POINTS: bool;
13}
14
15/// Point compaction settings
16pub trait PointCompaction {
17    /// Should point compaction be applied by default?
18    const COMPACT_POINTS: bool;
19}
20
21/// Attempt to decompress an elliptic curve point from its x-coordinate and
22/// a boolean flag indicating whether or not the y-coordinate is odd.
23pub trait DecompressPoint<C: Curve>: Sized {
24    /// Attempt to decompress an elliptic curve point.
25    fn decompress(x: &FieldBytes<C>, y_is_odd: Choice) -> CtOption<Self>;
26}
27
28/// Attempt to decompact an elliptic curve point from an x-coordinate
29pub trait DecompactPoint<C: Curve>: Sized {
30    /// Attempt to decompact an elliptic curve point
31    fn decompact(x: &FieldBytes<C>) -> CtOption<Self>;
32}