From aa997933a34c32931d5e53ee56e846974cdae447 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Mon, 5 Aug 2013 02:52:41 +0100 Subject: [PATCH 1/1] math/mp-jacobi.c: Improve the presentation. Make the commentary a bit more useful, and move the code about to fit in. --- math/mp-jacobi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/math/mp-jacobi.c b/math/mp-jacobi.c index b1b0216..e318ce3 100644 --- a/math/mp-jacobi.c +++ b/math/mp-jacobi.c @@ -130,7 +130,7 @@ int mp_jacobi(mp *a, mp *n) goto done; } - /* --- Main case with powers of two --- */ + /* --- Strip out powers of two from %$a$% --- */ a = mp_odd(a, a, &e); nn = n->v[0] & 7; @@ -138,11 +138,11 @@ int mp_jacobi(mp *a, mp *n) s = -s; if (MP_LEN(a) == 1 && a->v[0] == 1) goto done; - if ((nn & 3) == 3 && (a->v[0] & 3) == 3) - s = -s; - /* --- Reduce and swap --- */ + /* --- Reduce and swap, applying quadratic residuosity --- */ + if ((nn & 3) == 3 && (a->v[0] & 3) == 3) + s = -s; mp_div(0, &n, n, a); { mp *t = n; n = a; a = t; } } -- 2.11.0