Skip to content

Commit 3814df2

Browse files
ranweilerbriansmith
authored andcommitted
Add new_at_infinity constructor to ExtPoint.
I agree to license my contributions to each file under the terms given at the top of each file I changed.
1 parent 33fa6de commit 3814df2

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/ec/eddsa.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,7 @@ fn public_from_private(seed: &Seed, out: &mut PublicKey) {
162162
unsafe {
163163
GFp_ed25519_scalar_mask(&mut a_bytes);
164164
}
165-
let mut a = ExtPoint {
166-
x: [0; ELEM_LIMBS],
167-
y: [0; ELEM_LIMBS],
168-
z: [0; ELEM_LIMBS],
169-
t: [0; ELEM_LIMBS],
170-
};
165+
let mut a = ExtPoint::new_at_infinity();
171166
unsafe {
172167
GFp_x25519_ge_scalarmult_base(&mut a, &a_bytes);
173168
GFp_ge_p3_tobytes(out, &a);
@@ -198,6 +193,17 @@ struct ExtPoint {
198193
t: Elem,
199194
}
200195

196+
impl ExtPoint {
197+
fn new_at_infinity() -> Self {
198+
ExtPoint {
199+
x: [0; ELEM_LIMBS],
200+
y: [0; ELEM_LIMBS],
201+
z: [0; ELEM_LIMBS],
202+
t: [0; ELEM_LIMBS],
203+
}
204+
}
205+
}
206+
201207
// Keep this in sync with `fe` in curve25519/internal.h.
202208
type Elem = [i32; ELEM_LIMBS];
203209
const ELEM_LIMBS: usize = 10;

0 commit comments

Comments
 (0)