From d41d5ed898f209eb2e7f7580d548b118d681db8d Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Fri, 6 Nov 2026 11:38:10 -0800 Subject: [PATCH] Document point to bytes conversion function. --- src/assembly/ed25519/p.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/assembly/ed25519/p.ts b/src/assembly/ed25519/p.ts index fa190f1..d8459dc 100644 --- a/src/assembly/ed25519/p.ts +++ b/src/assembly/ed25519/p.ts @@ -377,6 +377,18 @@ export function p3_sub_precomp (r: p1p1, p: p3, q: p_precomp): void { fe_addsub(r.T, r.Z, r.Z, r.T) } +/** + * s = h + * + * Encodes `h` as 32 bytes where bits 0 to 254 are `y` little-endian and bit 255 + * is the sign of `x` which is its least significant bit. + * + * ``` + * x = X₁/Z₁ + * y = Y₁/Z₁ + * s = y + 2²⁵⁵(x mod 2) + * ``` + */ export function p3_tobytes (s: StaticArray, h: p3): void { fe_invert(t.Z, h.Z) fe_mul_pair(t.X, h.X, t.Z, t.Y, h.Y, t.Z) -- 2.52.0