0
$\begingroup$

For 256 bits "Double-and-add" multiplication uses about 128 addings and 256 doublings, where "Montgomery ladder" uses near 256 addings and 256 doublings. "Double-and-add" in my Intel(R) Core(TM) i3-8130U CPU @ 2.20GHz takes 0.02 s, it is normal or too big?

In adding we compute $\lambda = \frac{y_q - y_p}{x_q - x_p}$. Main cost is computing inverse of $x_q - x_p$ and inverse uses extended_gcd and modulo:

def extended_gcd(aa, bb):
    lastremainder, remainder = abs(aa), abs(bb)
    x, lastx, y, lasty = 0, 1, 1, 0
    while remainder:
        lastremainder, (quotient, remainder) = remainder, divmod(lastremainder, remainder)
        x, lastx = lastx - quotient * x, x
        y, lasty = lasty - quotient * y, y
    return lastremainder, lastx * (-1 if aa < 0 else 1), lasty * (-1 if bb < 0 else 1)

# calculate `modular inverse`
def modinv(a, m):
    g, x, y = extended_gcd(a, m)
    if g != 1:
        raise ValueError
    return x % m

I must many times compute this inverse to obtain $\lambda$ or between [n]P and [n+1]P is the same $\lambda$ (or can be fast comnputed) as is between [n+1] and [n+2]P ?

$\endgroup$
6
  • 3
    $\begingroup$ Note that Montgomery Ladder is side-channel free. To eliminate the inverse use projective coordinates. $\endgroup$
    – kelalaka
    Nov 19, 2020 at 19:11
  • $\begingroup$ Indeed, usually implementations will use projective coordinates to reduce the number of inversions to 1 (at the very end) and will use a generalization of double and add to reduce the number of additions (though those require constant-time table lookups). $\endgroup$
    – SEJPM
    Nov 19, 2020 at 19:17
  • $\begingroup$ In Wikibooks in "Standard Projective Coordinates" are forrmulas. but it generates very large numbers because don't have modulo. Where can I place modulo and how move from projective to affine coordinates? $\endgroup$
    – Andrzej
    Nov 19, 2020 at 19:51
  • $\begingroup$ Handbook of Elliptic Curve Cryptography. Group laws on projective coordinates $\endgroup$
    – kelalaka
    Nov 19, 2020 at 19:53
  • $\begingroup$ I test example from nayuki site. This speedup is only 2.5 times, Is many multiplications with modulo. $\endgroup$
    – Andrzej
    Nov 19, 2020 at 20:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.