From 24792fbb530a8706ef3d099dc6ffea36bb5eb174 Mon Sep 17 00:00:00 2001 From: Galoretka Date: Tue, 30 Sep 2025 19:51:29 +0300 Subject: [PATCH 1/2] fix Barrett reduction doc scalar64 --- p256/src/arithmetic/scalar/scalar64.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p256/src/arithmetic/scalar/scalar64.rs b/p256/src/arithmetic/scalar/scalar64.rs index f29587214..532ffed3a 100644 --- a/p256/src/arithmetic/scalar/scalar64.rs +++ b/p256/src/arithmetic/scalar/scalar64.rs @@ -27,7 +27,7 @@ const MU: [Limb; 5] = [ /// mu := floor(b^{2k} / p) /// q1 := floor(a / b^{k - 1}) /// q2 := q1 * mu -/// q3 := <- floor(a / b^{k - 1}) +/// q3 := floor(q2 / b^{k + 1}) /// r1 := a mod b^{k + 1} /// r2 := q3 * m mod b^{k + 1} /// r := r1 - r2 From fa304b9ecbba92b132542f8ccbe96a22ffe2ed98 Mon Sep 17 00:00:00 2001 From: Galoretka Date: Tue, 30 Sep 2025 19:51:52 +0300 Subject: [PATCH 2/2] fix Barrett reduction docs in scalar32 --- p256/src/arithmetic/scalar/scalar32.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/p256/src/arithmetic/scalar/scalar32.rs b/p256/src/arithmetic/scalar/scalar32.rs index d72367df0..ebc5e874a 100644 --- a/p256/src/arithmetic/scalar/scalar32.rs +++ b/p256/src/arithmetic/scalar/scalar32.rs @@ -25,13 +25,13 @@ const MU: [Limb; 9] = [ /// The general algorithm is: /// ```text /// p = n = order of group -/// b = 2^64 = 64bit machine word -/// k = 4 +/// b = 2^32 = 32bit machine word +/// k = 8 /// a \in [0, 2^512] /// mu := floor(b^{2k} / p) /// q1 := floor(a / b^{k - 1}) /// q2 := q1 * mu -/// q3 := <- floor(a / b^{k - 1}) +/// q3 := floor(q2 / b^{k + 1}) /// r1 := a mod b^{k + 1} /// r2 := q3 * m mod b^{k + 1} /// r := r1 - r2