Skip to content

Commit deff5ed

Browse files
Correct math typos in field_*.h
1 parent 4efb3f8 commit deff5ed

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

src/field_10x26.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#include <stdint.h>
1111

1212
typedef struct {
13-
/* X = sum(i=0..9, elem[i]*2^26) mod n */
13+
/* X = sum(i=0..9, n[i]*2^(i*26)) mod p
14+
* where p = 2^256 - 0x1000003D1
15+
*/
1416
uint32_t n[10];
1517
#ifdef VERIFY
1618
int magnitude;

src/field_10x26_impl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,8 @@ SECP256K1_INLINE static void secp256k1_fe_mul_inner(uint32_t *r, const uint32_t
486486
VERIFY_BITS(b[9], 26);
487487

488488
/** [... a b c] is a shorthand for ... + a<<52 + b<<26 + c<<0 mod n.
489-
* px is a shorthand for sum(a[i]*b[x-i], i=0..x).
489+
* for 0 <= x <= 9, px is a shorthand for sum(a[i]*b[x-i], i=0..x).
490+
* for 9 <= x <= 18, px is a shorthand for sum(a[i]*b[x-i], i=(x-9)..9)
490491
* Note that [x 0 0 0 0 0 0 0 0 0 0] = [x*R1 x*R0].
491492
*/
492493

src/field_5x52.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#include <stdint.h>
1111

1212
typedef struct {
13-
/* X = sum(i=0..4, elem[i]*2^52) mod n */
13+
/* X = sum(i=0..4, n[i]*2^(i*52)) mod p
14+
* where p = 2^256 - 0x1000003D1
15+
*/
1416
uint64_t n[5];
1517
#ifdef VERIFY
1618
int magnitude;

src/field_5x52_int128_impl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ SECP256K1_INLINE static void secp256k1_fe_mul_inner(uint64_t *r, const uint64_t
3535
VERIFY_CHECK(a != b);
3636

3737
/* [... a b c] is a shorthand for ... + a<<104 + b<<52 + c<<0 mod n.
38-
* px is a shorthand for sum(a[i]*b[x-i], i=0..x).
38+
* for 0 <= x <= 4, px is a shorthand for sum(a[i]*b[x-i], i=0..x).
39+
* for 4 <= x <= 8, px is a shorthand for sum(a[i]*b[x-i], i=(x-4)..4)
3940
* Note that [x 0 0 0 0 0] = [x*R].
4041
*/
4142

0 commit comments

Comments
 (0)