Skip to content

Commit a6258ef

Browse files
committed
Add DecafAffinePoint::GENERATOR
1 parent ab9a3d1 commit a6258ef

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

ed448-goldilocks/src/curve/twedwards/affine.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![allow(dead_code)]
2+
use crate::TWISTED_EDWARDS_BASE_POINT;
23
use crate::curve::twedwards::{extended::ExtendedPoint, extensible::ExtensiblePoint};
34
use crate::field::FieldElement;
45
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq};
@@ -30,6 +31,12 @@ impl AffinePoint {
3031
y: FieldElement::ONE,
3132
};
3233

34+
/// Identity element
35+
pub(crate) const GENERATOR: AffinePoint = AffinePoint {
36+
x: TWISTED_EDWARDS_BASE_POINT.X,
37+
y: TWISTED_EDWARDS_BASE_POINT.Y,
38+
};
39+
3340
/// Checks if the AffinePoint is on the TwistedEdwards curve
3441
pub(crate) fn is_on_curve(&self) -> Choice {
3542
let xx = self.x.square();
@@ -140,7 +147,6 @@ mod tests {
140147

141148
#[test]
142149
fn test_negation() {
143-
use crate::TWISTED_EDWARDS_BASE_POINT;
144150
let a = TWISTED_EDWARDS_BASE_POINT.to_extensible().to_affine();
145151
assert_eq!(a.is_on_curve().unwrap_u8(), 1);
146152

ed448-goldilocks/src/decaf/affine.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ impl DefaultIsZeroes for AffinePoint {}
7373
impl AffinePoint {
7474
/// The identity point
7575
pub const IDENTITY: Self = Self(InnerAffinePoint::IDENTITY);
76+
/// The generator point
77+
pub const GENERATOR: Self = Self(InnerAffinePoint::GENERATOR);
7678

7779
/// Convert to DecafPoint
7880
pub fn to_decaf(&self) -> DecafPoint {
@@ -115,3 +117,15 @@ impl Mul<&DecafScalar> for &AffinePoint {
115117
}
116118

117119
define_mul_variants!(LHS = AffinePoint, RHS = DecafScalar, Output = DecafPoint);
120+
121+
#[cfg(test)]
122+
mod test {
123+
use super::*;
124+
use elliptic_curve::CurveGroup;
125+
126+
#[test]
127+
fn generator() {
128+
assert_eq!(AffinePoint::GENERATOR.to_decaf(), DecafPoint::GENERATOR);
129+
assert_eq!(DecafPoint::GENERATOR.to_affine(), AffinePoint::GENERATOR);
130+
}
131+
}

0 commit comments

Comments
 (0)