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.
This commit is contained in:
parent
a1102b1219
commit
c9da1baad1
@ -32,6 +32,8 @@
|
|||||||
#error "Please select wide multiplication implementation"
|
#error "Please select wide multiplication implementation"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const secp256k1_fe secp256k1_fe_one = SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 1);
|
||||||
|
|
||||||
/** Normalize a field element. This brings the field element to a canonical representation, reduces
|
/** Normalize a field element. This brings the field element to a canonical representation, reduces
|
||||||
* its magnitude to 1, and reduces it modulo field size `p`.
|
* its magnitude to 1, and reduces it modulo field size `p`.
|
||||||
*/
|
*/
|
||||||
|
@ -135,6 +135,4 @@ static int secp256k1_fe_sqrt(secp256k1_fe *r, const secp256k1_fe *a) {
|
|||||||
return secp256k1_fe_equal(&t1, a);
|
return secp256k1_fe_equal(&t1, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const secp256k1_fe secp256k1_fe_one = SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 1);
|
|
||||||
|
|
||||||
#endif /* SECP256K1_FIELD_IMPL_H */
|
#endif /* SECP256K1_FIELD_IMPL_H */
|
||||||
|
@ -494,7 +494,6 @@ static void secp256k1_gej_add_zinv_var(secp256k1_gej *r, const secp256k1_gej *a,
|
|||||||
|
|
||||||
static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b) {
|
static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b) {
|
||||||
/* Operations: 7 mul, 5 sqr, 4 normalize, 21 mul_int/add/negate/cmov */
|
/* Operations: 7 mul, 5 sqr, 4 normalize, 21 mul_int/add/negate/cmov */
|
||||||
static const secp256k1_fe fe_1 = SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 1);
|
|
||||||
secp256k1_fe zz, u1, u2, s1, s2, t, tt, m, n, q, rr;
|
secp256k1_fe zz, u1, u2, s1, s2, t, tt, m, n, q, rr;
|
||||||
secp256k1_fe m_alt, rr_alt;
|
secp256k1_fe m_alt, rr_alt;
|
||||||
int infinity, degenerate;
|
int infinity, degenerate;
|
||||||
@ -610,7 +609,7 @@ static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const
|
|||||||
/** In case a->infinity == 1, replace r with (b->x, b->y, 1). */
|
/** In case a->infinity == 1, replace r with (b->x, b->y, 1). */
|
||||||
secp256k1_fe_cmov(&r->x, &b->x, a->infinity);
|
secp256k1_fe_cmov(&r->x, &b->x, a->infinity);
|
||||||
secp256k1_fe_cmov(&r->y, &b->y, a->infinity);
|
secp256k1_fe_cmov(&r->y, &b->y, a->infinity);
|
||||||
secp256k1_fe_cmov(&r->z, &fe_1, a->infinity);
|
secp256k1_fe_cmov(&r->z, &secp256k1_fe_one, a->infinity);
|
||||||
r->infinity = infinity;
|
r->infinity = infinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user