Skip to content

Commit

Permalink
Make _set_fe_int( . , 0 ) set magnitude to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
real-or-random committed Apr 27, 2020
1 parent 4949658 commit b17a7df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* - Each field element can be normalized or not.
* - Each field element has a magnitude, which represents how far away
* its representation is away from normalization. Normalized elements
* always have a magnitude of 1, but a magnitude of 1 doesn't imply
* normality.
* always have a magnitude of 0 or 1, but a magnitude of 1 doesn't
* imply normality.
*/

#if defined HAVE_CONFIG_H
Expand Down Expand Up @@ -51,7 +51,8 @@ static int secp256k1_fe_normalizes_to_zero(secp256k1_fe *r);
* implementation may optionally normalize the input, but this should not be relied upon. */
static int secp256k1_fe_normalizes_to_zero_var(secp256k1_fe *r);

/** Set a field element equal to a small integer. Resulting field element is normalized. */
/** Set a field element equal to a small integer. Resulting field element is normalized; it has
* magnitude 0 if a == 0, and magnitude 1 otherwise. */
static void secp256k1_fe_set_int(secp256k1_fe *r, int a);

/** Sets a field element equal to zero, initializing all fields. */
Expand Down
2 changes: 1 addition & 1 deletion src/field_10x26_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ SECP256K1_INLINE static void secp256k1_fe_set_int(secp256k1_fe *r, int a) {
r->n[0] = a;
r->n[1] = r->n[2] = r->n[3] = r->n[4] = r->n[5] = r->n[6] = r->n[7] = r->n[8] = r->n[9] = 0;
#ifdef VERIFY
r->magnitude = 1;
r->magnitude = (a != 0);
r->normalized = 1;
secp256k1_fe_verify(r);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/field_5x52_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ SECP256K1_INLINE static void secp256k1_fe_set_int(secp256k1_fe *r, int a) {
r->n[0] = a;
r->n[1] = r->n[2] = r->n[3] = r->n[4] = 0;
#ifdef VERIFY
r->magnitude = 1;
r->magnitude = (a != 0);
r->normalized = 1;
secp256k1_fe_verify(r);
#endif
Expand Down

0 comments on commit b17a7df

Please sign in to comment.