From 18d13961759f5829341f5d667a4333901b41a586 Mon Sep 17 00:00:00 2001 From: "Diego F. Aranha" Date: Thu, 23 Nov 2023 17:08:31 +0100 Subject: [PATCH] Improve support to FM18 curves. --- src/epx/relic_ep3_mul.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/epx/relic_ep3_mul.c b/src/epx/relic_ep3_mul.c index 76f78eed2..899caab90 100644 --- a/src/epx/relic_ep3_mul.c +++ b/src/epx/relic_ep3_mul.c @@ -62,7 +62,7 @@ static void ep3_psi(ep3_t r, const ep3_t p) { ep3_sub(r, r, q); break; case EP_K18: - /* For KSS18, we have that u = p^4 - 3*p mod r. */ + /* For KSS18, we have that u = (p^4 - 3*p) mod r. */ ep3_dbl(q, p); ep3_add(q, q, p); ep3_frb(r, p, 3); @@ -70,7 +70,10 @@ static void ep3_psi(ep3_t r, const ep3_t p) { ep3_frb(r, r, 1); break; case EP_FM18: - ep3_frb(r, p, 1); + /* For FM18, we have that -u = (p-p^4) mod r. */ + ep3_frb(q, p, 3); + ep3_sub(r, p, q); + ep3_frb(r, r, 1); break; } }