Skip to content

Commit c9da1ba

Browse files
Move secp256k1_fe_one to field.h
This makes secp256k1_fe_one part of field.h's interface, and allows other modules to appropriately access the constant.
1 parent a1102b1 commit c9da1ba

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

src/field.h

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#error "Please select wide multiplication implementation"
3333
#endif
3434

35+
static const secp256k1_fe secp256k1_fe_one = SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 1);
36+
3537
/** Normalize a field element. This brings the field element to a canonical representation, reduces
3638
* its magnitude to 1, and reduces it modulo field size `p`.
3739
*/

src/field_impl.h

-2
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,4 @@ static int secp256k1_fe_sqrt(secp256k1_fe *r, const secp256k1_fe *a) {
135135
return secp256k1_fe_equal(&t1, a);
136136
}
137137

138-
static const secp256k1_fe secp256k1_fe_one = SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 1);
139-
140138
#endif /* SECP256K1_FIELD_IMPL_H */

src/group_impl.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ static void secp256k1_gej_add_zinv_var(secp256k1_gej *r, const secp256k1_gej *a,
494494

495495
static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b) {
496496
/* Operations: 7 mul, 5 sqr, 4 normalize, 21 mul_int/add/negate/cmov */
497-
static const secp256k1_fe fe_1 = SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 1);
498497
secp256k1_fe zz, u1, u2, s1, s2, t, tt, m, n, q, rr;
499498
secp256k1_fe m_alt, rr_alt;
500499
int infinity, degenerate;
@@ -610,7 +609,7 @@ static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const
610609
/** In case a->infinity == 1, replace r with (b->x, b->y, 1). */
611610
secp256k1_fe_cmov(&r->x, &b->x, a->infinity);
612611
secp256k1_fe_cmov(&r->y, &b->y, a->infinity);
613-
secp256k1_fe_cmov(&r->z, &fe_1, a->infinity);
612+
secp256k1_fe_cmov(&r->z, &secp256k1_fe_one, a->infinity);
614613
r->infinity = infinity;
615614
}
616615

0 commit comments

Comments
 (0)