aboutsummaryrefslogtreecommitdiff
path: root/src/Arithmetic
diff options
context:
space:
mode:
authorGravatar Jason Gross <jgross@mit.edu>2017-04-30 13:55:21 -0400
committerGravatar Jason Gross <jasongross9@gmail.com>2017-05-01 15:02:58 -0400
commit54b4a7737b37fe641ba1f16dc2909551166d71c6 (patch)
tree2221dbdebe6bd226df3638a9639c2cffe3a2cdf2 /src/Arithmetic
parentcb9f74654f2cf377277e0368bed935ef85b7be6e (diff)
Use mod (weight (S i) / weight i), not mod (weight i)
Diffstat (limited to 'src/Arithmetic')
-rw-r--r--src/Arithmetic/MontgomeryReduction/WordByWord/Definition.v10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Arithmetic/MontgomeryReduction/WordByWord/Definition.v b/src/Arithmetic/MontgomeryReduction/WordByWord/Definition.v
index 5d10cbe74..79b45531b 100644
--- a/src/Arithmetic/MontgomeryReduction/WordByWord/Definition.v
+++ b/src/Arithmetic/MontgomeryReduction/WordByWord/Definition.v
@@ -46,10 +46,11 @@ Section positional.
Section body.
Context (T : tuple Z k)
(i : nat).
- Let k0 := p' mod (weight i).
+ Let N := weight (S i) / weight i.
+ Let k0 := p' mod N.
- Let T1 := T{{i}} mod (weight i).
- Let Y := (T1 * k0) mod (weight i).
+ Let T1 := T{{i}} mod N.
+ Let Y := (T1 * k0) mod N.
Let T2 := mul p (encode Y).
Let T3 := add T T2.
Definition redc_body := T3.
@@ -60,4 +61,7 @@ Section positional.
| O => T
| S count' => redc_from (redc_body T (k - count)) count'
end.
+
+ Definition redc (T : tuple Z k) : tuple Z k
+ := redc_from T k.
End positional.