From acff03b3c76fe966f5f8a4aff7ab0190fd8301f4 Mon Sep 17 00:00:00 2001 From: Michael Hamburg Date: Mon, 22 May 2017 17:54:58 -0700 Subject: [PATCH] eddsa_to_decaf_opt working --- aux/decaffeinate_ed25519_too.sage | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aux/decaffeinate_ed25519_too.sage b/aux/decaffeinate_ed25519_too.sage index d6b5095..81d533f 100644 --- a/aux/decaffeinate_ed25519_too.sage +++ b/aux/decaffeinate_ed25519_too.sage @@ -98,7 +98,11 @@ def decaf_to_eddsa_opt(s): if hibit(s): raise Exception("invalid: s has high bit") if not is_square(s^4 + (2-4*dM)*s^2 + 1): raise Exception("invalid: not on curve") - t = sqrt(s^4 + (2-4*dM)*s^2 + 1)/s + curve_eqn = s^4 + (2-4*dM)*s^2 + 1 + isr,inv = isqrt_trick(curve_eqn,s) + + t = isr * curve_eqn * inv + if hibit(t): t = -t y = (1-s^2)/(1+s^2) x = 2*magic/t