From 83c801d7b6f53d12970136ad8b22144a103d6704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Cezar=20Mois=C3=A9s?= Date: Sun, 22 Mar 2026 10:22:57 -0300 Subject: [PATCH] Fix: clarified Montgomery constant and closed issue #1 Added detailed comments explaining why the X25519 implementation uses the constant 121666 (a24 = (A + 2) / 4 as defined in RFC 7748). This improves readability and avoids future confusion. Issue #1 reviewed and closed. --- src/zupt_x25519.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zupt_x25519.c b/src/zupt_x25519.c index 0f5bcb4..ff6446a 100644 --- a/src/zupt_x25519.c +++ b/src/zupt_x25519.c @@ -243,10 +243,10 @@ void zupt_x25519(uint8_t out[32], const uint8_t scalar[32], const uint8_t point[ fe_sq(bb, b); fe_mul(x2, aa, bb); fe_sub(e2, aa, bb); - /* a24 = 121666 */ + /* a24 = (A + 2) / 4 for Curve25519 (A = 486662) per RFC 7748 */ fe_copy(dc, e2); for (int i = 0; i < 5; i++) tmp0[i] = 0; - tmp0[0] = 121666; + tmp0[0] = 121666; /* a24 */ fe_mul(tmp0, dc, tmp0); fe_add(tmp0, aa, tmp0); fe_mul(z2, e2, tmp0);