Add impl Default, Identity for ExtendedPoint, CachedPoint.

This commit is contained in:
Henry de Valence 2019-01-18 01:47:23 -08:00
parent da62569355
commit f825426ff4

View file

@ -56,6 +56,18 @@ impl From<ExtendedPoint> for CachedPoint {
} }
} }
impl Default for ExtendedPoint {
fn default() -> ExtendedPoint {
ExtendedPoint::identity()
}
}
impl Identity for ExtendedPoint {
fn identity() -> ExtendedPoint {
constants::EXTENDEDPOINT_IDENTITY
}
}
impl ExtendedPoint { impl ExtendedPoint {
pub fn double(&self) -> ExtendedPoint { pub fn double(&self) -> ExtendedPoint {
// Set tmp0 = (X1 Y1 X1 Y1) // Set tmp0 = (X1 Y1 X1 Y1)
@ -136,6 +148,18 @@ impl<'a, 'b> Add<&'b CachedPoint> for &'a ExtendedPoint {
} }
} }
impl Default for CachedPoint {
fn default() -> CachedPoint {
CachedPoint::identity()
}
}
impl Identity for CachedPoint {
fn identity() -> CachedPoint {
constants::CACHEDPOINT_IDENTITY
}
}
impl ConditionallySelectable for CachedPoint { impl ConditionallySelectable for CachedPoint {
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self { fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self {
CachedPoint(F51x4Reduced::conditional_select(&a.0, &b.0, choice)) CachedPoint(F51x4Reduced::conditional_select(&a.0, &b.0, choice))