]> git.codecow.com Git - nano25519.git/commitdiff
Update doc comments.
authorChris Duncan <chris@codecow.com>
Fri, 23 Oct 2026 17:47:31 +0000 (10:47 -0700)
committerChris Duncan <chris@codecow.com>
Fri, 23 Oct 2026 17:47:31 +0000 (10:47 -0700)
src/assembly/ed25519/p.ts

index 7117652ca353f07fb43a6a782596f6f99c9ea99f..57cf1266512c1c70b6f4b9ba0d47643f0a28ce44 100644 (file)
@@ -12,25 +12,41 @@ const ed25519_d2: FieldElement = StaticArray.fromArray<i32>([
        -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()
@@ -38,6 +54,10 @@ export class ge_cached {
        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()
@@ -72,10 +92,11 @@ export function ge_precomp_0 (h: ge_precomp): void {
 
 /**
  * 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 {
@@ -85,11 +106,12 @@ 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 {
@@ -108,12 +130,13 @@ export function ge_p3_to_cached (r: ge_cached, p: ge_p3): 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 {
@@ -127,12 +150,13 @@ 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 {
@@ -146,7 +170,14 @@ 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)