From dc9b6853b72b9a492cad230623670e89157525ca Mon Sep 17 00:00:00 2001 From: Elliott Jin Date: Tue, 9 Nov 2021 17:46:24 -0800 Subject: [PATCH] doc: Minor fixes in safegcd_implementation.md --- doc/safegcd_implementation.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/safegcd_implementation.md b/doc/safegcd_implementation.md index 3ae556f..063aa8e 100644 --- a/doc/safegcd_implementation.md +++ b/doc/safegcd_implementation.md @@ -569,8 +569,14 @@ bits efficiently, which is possible on most platforms; it is abstracted here as ```python def count_trailing_zeros(v): - """For a non-zero value v, find z such that v=(d<L = 0*, or *w = -g/f mod 2L*. Since *f* is odd, such a *w* exists for any *L*. *L* cannot be more than *i* steps (as we'd finish the loop before -doing more) or more than *η+1* steps (as we'd run `eta, f, g = -eta, g, f` at that point), but +doing more) or more than *η+1* steps (as we'd run `eta, f, g = -eta, g, -f` at that point), but apart from that, we're only limited by the complexity of computing *w*. This code demonstrates how to cancel up to 4 bits per step: @@ -618,7 +624,7 @@ while True: break # We know g is odd now if eta < 0: - eta, f, g = -eta, g, f + eta, f, g = -eta, g, -f # Compute limit on number of bits to cancel limit = min(min(eta + 1, i), 4) # Compute w = -g/f mod 2**limit, using the table value for -1/f mod 2**4. Note that f is