-21827239, -5839606, -30745221, 13898782, 229458, 15978800, -12551817, -6495438, 29715968, 9444199, 0, 0
])
+/**
+ * Base class for building branded subclasses of coordinate systems.
+ */
class ge_coord {
X: FieldElement = fe()
Y: FieldElement = fe()
Z: FieldElement = fe()
}
+/**
+ * Projective coordinates.
+ */
export class ge_p2 extends ge_coord {
__brand: 'ge_p2' = 'ge_p2'
}
+/**
+ * Completed `(x, y)` where`x = X/Z`, `y = Y/T`
+ */
export class ge_p1p1 extends ge_coord {
T: FieldElement = fe()
__brand: 'ge_p1p1' = 'ge_p1p1'
}
+/**
+ * Extended projective coordinates.
+ */
export class ge_p3 extends ge_coord {
T: FieldElement = fe()
__brand: 'ge_p3' = 'ge_p3'
}
+
+/**
+ * Computed at runtime.
+ */
export class ge_cached {
YplusX: FieldElement = fe()
YminusX: FieldElement = fe()
T2d: FieldElement = fe()
}
+/**
+ * Precomputed from base point and compiled into the module.
+ * Requires an expensive `fe_invert` up front but saves one `fe_mul` at runtime.
+ */
export class ge_precomp {
yplusx: FieldElement = fe()
yminusx: FieldElement = fe()
/**
* r = p
+ *
* ```
- * X' = X * T
- * Y' = Y * Z
- * Z' = Z * T
+ * X = X₁ * T₁
+ * Y = Y₁ * Z₁
+ * Z = Z₁ * T₁
* ```
*/
export function ge_p1p1_to_p2 (r: ge_p2, p: ge_p1p1): void {
/**
* r = p
+ *
* ```
- * X' = X * T
- * Y' = Y * Z
- * Z' = Z * T
- * T' = X * Y
+ * X = X₁ * T₁
+ * Y = Y₁ * Z₁
+ * Z = Z₁ * T₁
+ * T = X₁ * Y₁
* ```
*/
export function ge_p1p1_to_p3 (r: ge_p3, p: ge_p1p1): void {
}
/**
- * r = 2 * p
+ * `r = 2p`
+ *
* ```
- * X' = (X + Y)² - (Y² + X²)
- * Y' = Y² + X²
- * Z' = Y² - X²
- * T' = 2Z² - (Y² - X²)
+ * X = (X₁ + Y₁)² - (Y₁² + X₁²)
+ * Y = Y₁² + X₁²
+ * Z = Y₁² - X₁²
+ * T = 2Z₁² - (Y₁² - X₁²)
* ```
*/
export function ge_p2_dbl (r: ge_p1p1, p: ge_p2, t: FieldElement): void {
}
/**
- * r = 2 * p
+ * `r = 2p`
+ *
* ```
- * X' = (X + Y)² - (Y² + X²)
- * Y' = Y² + X²
- * Z' = Y² - X²
- * T' = 2Z² - (Y² - X²)
+ * X = (X₁ + Y₁)² - (Y₁² + X₁²)
+ * Y = Y₁² + X₁²
+ * Z = Y₁² - X₁²
+ * T = 2Z₁² - (Y₁² - X₁²)
* ```
*/
export function ge_p3_dbl (r: ge_p1p1, p: ge_p3, t: FieldElement): void {
}
/**
- * r = p + q
+ * `r = p + q`
+ *
+ * ```
+ * X = (Y₁ + X₁)(Y₂ + X₂) - (Y₁ - X₁)(Y₂ - X₂)
+ * Y = (Y₁ + X₁)(Y₂ + X₂) + (Y₁ - X₁)(Y₂ - X₂)
+ * Z = 2Z₁Z₂ + 2dT₁T₂
+ * T = 2Z₁Z₂ - 2dT₁T₂
+ * ```
*/
export function ge_add_cached (r: ge_p1p1, p: ge_p3, q: ge_cached, t: FieldElement): void {
fe_add(r.X, p.Y, p.X)