nx_ed25519_field.nx
buildroot/runtime/nx_ed25519_field.nx
about
nx_ed25519_field.nx -- Ed25519-specific extensions to the shared
GF(2^255 - 19) field math already in nx_x25519.
Phase 0b §I.1 Piece 1 of the Ed25519 completion arc per
docs/NISHI_TLS13_GAP_AUDIT.md. X25519 and Ed25519 share the
same prime field (Curve25519 is the Montgomery form; Ed25519
uses the birationally equivalent twisted Edwards form), so the
fe_add / fe_sub / fe_mul / fe_sq / fe_invert / fe_from_bytes /
fe_to_bytes operations already in nx_x25519 transfer directly.
This module adds the bits Ed25519 needs that X25519 doesn't:
- fe_neg : h = -f mod p (used in point ops + sign handling)
- fe_pow22523: z^((p-5)/8) (used in sqrt + decompression)
- ED25519_D : the twisted-Edwards curve parameter d
- ED25519_SQRT_M1 : the field element with x^2 = -1 (used in
point decompression to pick the right square root)
Subsequent pieces:
- Piece 2 SHIPPED T8: nx_ed25519_point.nx with GeP3 +
decompress + on-curve check. Add + double + scalar_mul
queued for Piece 3.
- Piece 3: ge_p3_add + ge_p3_double + sc_reduce mod L +
scalar mul primitives.
- Piece 4: nx_ed25519.nx's ed25519_verify replaces its
ERR_PENDING stub with real wiring + ed25519_sign + RFC
8032 §7.1 KATs.
What it does today:
- fe_neg / fe_pow22523 / ED25519_D / ED25519_SQRT_M1
- sealed verdict + validity gate for the small ed25519 verdict
namespace that piece 3 will populate
What it doesn't do yet:
- sqrt extraction (composes pow22523 + sqrt_m1; ships Piece 2)
- any point operations
KAT verified:
- fe_neg(fe_one) + fe_one == fe_zero (round-trip)
- fe_pow22523(fe_one) == fe_one (1^anything = 1)
- ED25519_SQRT_M1^2 == fe_neg(fe_one) (the defining property)
dependencies 2 imports · 9 importers
imports: nx_syscalls.nxnx_x25519.nx
imported by: nx_doc_seal.nxnx_ed25519_arith.nxnx_ed25519_arith_test.nxnx_ed25519_field_test.nxnx_ed25519_point.nxnx_ed25519_point_test.nxnx_ed25519_scalar_test.nxnx_ed25519_signature.nxnx_ed25519_signature_test.nx
structs
| none |
consts
| 61 | const NX_ED25519_FE_LIMBS: i64 = 10 |
| 62 | const NX_ED25519_FE_BYTES: i64 = 32 |
| 63 | const NX_ED25519_VERDICT_OK: i64 = 1 |
| 64 | const NX_ED25519_VERDICT_BAD: i64 = 2 |
| 65 | const NX_ED25519_VERDICT_N: i64 = 3 |
functions
| 71 | func fe_neg(h: *i64, f: *i64) -> i64 |
| 85 | func fe_pow22523(out: *i64, z: *i64) -> i64 |
| 130 | func ed25519_d_bytes(out_32: *u8) -> i64 |
| 143 | func ed25519_d_fe(out_fe: *i64) -> i64 called by 4: ge_p3_addmainge_p3_decompressge_p3_on_curve calls 3: sys_mmaped25519_d_bytesfe_from_bytes |
| 159 | func ed25519_sqrt_m1_bytes(out_32: *u8) -> i64 |
| 171 | func ed25519_sqrt_m1_fe(out_fe: *i64) -> i64 |
| 182 | func fe_canonical_equal(a: *i64, b: *i64) -> i64 |
| 195 | func nx_ed25519_verdict_is_valid(v: i64) -> i64 called by 1: main |