Skip to content

Commit 87c92f0

Browse files
committed
ed448-goldilocks: export LOW_A/LOW_B/LOW_C points
1 parent bcc2f0b commit 87c92f0

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

ed448-goldilocks/src/montgomery.rs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,29 @@ use core::fmt;
1818
use core::ops::Mul;
1919
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq};
2020

21-
// Low order points on Curve448 and it's twist
22-
const LOW_A: MontgomeryPoint = MontgomeryPoint([
23-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27-
]);
28-
const LOW_B: MontgomeryPoint = MontgomeryPoint([
29-
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33-
]);
34-
const LOW_C: MontgomeryPoint = MontgomeryPoint([
35-
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
36-
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff,
37-
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
38-
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
39-
]);
21+
impl MontgomeryPoint {
22+
/// First low order point on Curve448 and it's twist
23+
pub const LOW_A: MontgomeryPoint = MontgomeryPoint([
24+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28+
]);
29+
/// Second low order point on Curve448 and it's twist
30+
pub const LOW_B: MontgomeryPoint = MontgomeryPoint([
31+
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35+
]);
36+
/// Third low order point on Curve448 and it's twist
37+
pub const LOW_C: MontgomeryPoint = MontgomeryPoint([
38+
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
39+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff,
40+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
41+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
42+
]);
43+
}
4044

4145
/// A point in Montgomery form
4246
#[derive(Copy, Clone)]
@@ -131,7 +135,7 @@ impl MontgomeryPoint {
131135

132136
/// Returns true if the point is one of the low order points
133137
pub fn is_low_order(&self) -> bool {
134-
(*self == LOW_A) || (*self == LOW_B) || (*self == LOW_C)
138+
(*self == Self::LOW_A) || (*self == Self::LOW_B) || (*self == Self::LOW_C)
135139
}
136140

137141
/// View the point as a byte slice

0 commit comments

Comments
 (0)