aboutsummaryrefslogtreecommitdiff
path: root/src/group.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/group.h')
-rw-r--r--src/group.h36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/group.h b/src/group.h
index b9cd334dae..bb7dae1cf7 100644
--- a/src/group.h
+++ b/src/group.h
@@ -9,7 +9,10 @@
#include "field.h"
-/** A group element of the secp256k1 curve, in affine coordinates. */
+/** A group element in affine coordinates on the secp256k1 curve,
+ * or occasionally on an isomorphic curve of the form y^2 = x^3 + 7*t^6.
+ * Note: For exhaustive test mode, secp256k1 is replaced by a small subgroup of a different curve.
+ */
typedef struct {
secp256k1_fe x;
secp256k1_fe y;
@@ -19,7 +22,9 @@ typedef struct {
#define SECP256K1_GE_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {SECP256K1_FE_CONST((a),(b),(c),(d),(e),(f),(g),(h)), SECP256K1_FE_CONST((i),(j),(k),(l),(m),(n),(o),(p)), 0}
#define SECP256K1_GE_CONST_INFINITY {SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), 1}
-/** A group element of the secp256k1 curve, in jacobian coordinates. */
+/** A group element of the secp256k1 curve, in jacobian coordinates.
+ * Note: For exhastive test mode, sepc256k1 is replaced by a small subgroup of a different curve.
+ */
typedef struct {
secp256k1_fe x; /* actual X: x/z^2 */
secp256k1_fe y; /* actual Y: y/z^3 */
@@ -64,12 +69,24 @@ static void secp256k1_ge_set_gej_var(secp256k1_ge *r, secp256k1_gej *a);
/** Set a batch of group elements equal to the inputs given in jacobian coordinates */
static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a, size_t len);
-/** Bring a batch inputs given in jacobian coordinates (with known z-ratios) to
- * the same global z "denominator". zr must contain the known z-ratios such
- * that mul(a[i].z, zr[i+1]) == a[i+1].z. zr[0] is ignored. The x and y
- * coordinates of the result are stored in r, the common z coordinate is
- * stored in globalz. */
-static void secp256k1_ge_globalz_set_table_gej(size_t len, secp256k1_ge *r, secp256k1_fe *globalz, const secp256k1_gej *a, const secp256k1_fe *zr);
+/** Bring a batch of inputs to the same global z "denominator", based on ratios between
+ * (omitted) z coordinates of adjacent elements.
+ *
+ * Although the elements a[i] are _ge rather than _gej, they actually represent elements
+ * in Jacobian coordinates with their z coordinates omitted.
+ *
+ * Using the notation z(b) to represent the omitted z coordinate of b, the array zr of
+ * z coordinate ratios must satisfy zr[i] == z(a[i]) / z(a[i-1]) for 0 < 'i' < len.
+ * The zr[0] value is unused.
+ *
+ * This function adjusts the coordinates of 'a' in place so that for all 'i', z(a[i]) == z(a[len-1]).
+ * In other words, the initial value of z(a[len-1]) becomes the global z "denominator". Only the
+ * a[i].x and a[i].y coordinates are explicitly modified; the adjustment of the omitted z coordinate is
+ * implicit.
+ *
+ * The coordinates of the final element a[len-1] are not changed.
+ */
+static void secp256k1_ge_table_set_globalz(size_t len, secp256k1_ge *a, const secp256k1_fe *zr);
/** Set a group element (affine) equal to the point at infinity. */
static void secp256k1_ge_set_infinity(secp256k1_ge *r);
@@ -125,6 +142,9 @@ static void secp256k1_ge_to_storage(secp256k1_ge_storage *r, const secp256k1_ge
static void secp256k1_ge_from_storage(secp256k1_ge *r, const secp256k1_ge_storage *a);
/** If flag is true, set *r equal to *a; otherwise leave it. Constant-time. Both *r and *a must be initialized.*/
+static void secp256k1_gej_cmov(secp256k1_gej *r, const secp256k1_gej *a, int flag);
+
+/** If flag is true, set *r equal to *a; otherwise leave it. Constant-time. Both *r and *a must be initialized.*/
static void secp256k1_ge_storage_cmov(secp256k1_ge_storage *r, const secp256k1_ge_storage *a, int flag);
/** Rescale a jacobian point by b which must be non-zero. Constant-time. */