Skip to content

Commit ad7186f

Browse files
committed
Add ProjectiveMontgomeryXpoint::GENERATOR
1 parent e1c0a2a commit ad7186f

File tree

1 file changed

+10
-4
lines changed
  • ed448-goldilocks/src/montgomery

1 file changed

+10
-4
lines changed

ed448-goldilocks/src/montgomery/x.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// use crate::constants::A_PLUS_TWO_OVER_FOUR;
22
use crate::EdwardsScalar;
33
use crate::edwards::extended::EdwardsPoint;
4+
use crate::field::ConstMontyType;
45
use crate::field::FieldElement;
56
use core::fmt;
67
use core::ops::Mul;
8+
use elliptic_curve::bigint::U448;
79
use subtle::{Choice, ConditionallyNegatable, ConditionallySelectable, ConstantTimeEq};
810

911
// Low order points on Curve448 and it's twist
@@ -227,6 +229,12 @@ impl ProjectiveMontgomeryXpoint {
227229
W: FieldElement::ZERO,
228230
};
229231

232+
/// The generator point
233+
pub const GENERATOR: Self = Self {
234+
U: FieldElement(ConstMontyType::new(&U448::from_u64(5))),
235+
W: FieldElement::ONE,
236+
};
237+
230238
/// Compute the Y-coordinate
231239
// See https://www.rfc-editor.org/rfc/rfc7748#section-1.
232240
pub fn y(&self, sign: Choice) -> FieldElement {
@@ -254,14 +262,12 @@ mod tests {
254262
#[test]
255263
fn test_montgomery_edwards() {
256264
let scalar = EdwardsScalar::from(200u32);
257-
use crate::GOLDILOCKS_BASE_POINT as bp;
258265

259266
// Montgomery scalar mul
260-
let montgomery_bp = bp.to_montgomery_x();
261-
let montgomery_res = &(&montgomery_bp * &scalar) * &scalar;
267+
let montgomery_res = &(&ProjectiveMontgomeryXpoint::GENERATOR * &scalar) * &scalar;
262268

263269
// Goldilocks scalar mul
264-
let goldilocks_point = bp.scalar_mul(&scalar).scalar_mul(&scalar);
270+
let goldilocks_point = EdwardsPoint::GENERATOR * scalar * scalar;
265271
assert_eq!(
266272
goldilocks_point.to_montgomery_x(),
267273
montgomery_res.to_affine()

0 commit comments

Comments
 (0)