Documentation

Cryptlib.Primitives.Sign.Ed25519_codec

decodePoint ∘ encodePoint = some #

Ed25519's 32-byte point compression (y in the low 255 bits, the parity of x in the top bit) round-trips on every curve point. Decoding recovers x from y by the p ≡ 5 (mod 8) square-root recipe of RFC 8032, x₀ = xx^((p+3)/8) corrected by √-1, then fixes the sign by parity; sqrt_step shows the recipe always lands on ±x, and parity_fix that the parity rule picks x.

theorem Cryptlib.Primitives.Sign.Ed25519Codec.ofDigits_range (k n : ℕ) :
Nat.ofDigits 256 (List.map (fun (i : ℕ) => n >>> (8 * i) % 256) (List.range k)) = n % 256 ^ k
theorem Cryptlib.Primitives.Sign.Ed25519Codec.ofFn_range (k : ℕ) (g : ℕ → ℕ) :
(List.ofFn fun (i : Fin k) => g ↑i) = List.map g (List.range k)
theorem Cryptlib.Primitives.Sign.Ed25519Codec.parity_fix {x xc : Ed25519Facts.F} (h : xc = x ∨ xc = -x) :
(if ZMod.val xc % 2 = ZMod.val x % 2 then xc else -xc) = x