From dbc8196148e1034e9109f4065583950dcc3eba0a Mon Sep 17 00:00:00 2001 From: Christophe Diederichs Date: Mon, 21 Nov 2022 17:16:13 +0000 Subject: [PATCH] add fe25519_25 constants --- fe25519_25.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/fe25519_25.js b/fe25519_25.js index 00dd1ba..47d1365 100644 --- a/fe25519_25.js +++ b/fe25519_25.js @@ -71,7 +71,13 @@ function fe25519_pow22523 (h, f) { const base = require('./fe25519_25/base.json').map(a => a.map(b => ge2(b))) const printbuf =Buffer.alloc(32) -const ed25519_A_32 = 486662 +const fe25519_sqrtm1 = fe25519([ + -32595792, -7943725, 9377950, 3500415, 12389472, -272473, -25146209, -2005654, 326686, 11406482 +]) + +const ed25519_sqrtam2 = fe25519([ + -12222970, -8312128, -11511410, 9067497, -15300785, -241793, 25456130, 14121551, -12187136, 3972024 +]) const ed25519_d = fe25519([ -10913610, 13857413, -15372611, 6949391, 114729, -8787816, -6275908, -3247719, -18696448, -12055116 @@ -81,16 +87,14 @@ const ed25519_d2 = fe25519([ -21827239, -5839606, -30745221, 13898782, 229458, 15978800, -12551817, -6495438, 29715968, 9444199 ]) +const ed25519_A_32 = 486662 const ed25519_A = fe25519([ ed25519_A_32, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]) -const fe25519_sqrtm1 = fe25519([ - -32595792, -7943725, 9377950, 3500415, 12389472, -272473, -25146209, -2005654, 326686, 11406482 -]) - -const ed25519_sqrtam2 = fe25519([ - -12222970, -8312128, -11511410, 9067497, -15300785, -241793, 25456130, 14121551, -12187136, 3972024 +/* sqrt(ad - 1) with a = -1 (mod p) */ +const ed25519_sqrtadm1 = fe25519([ + 24849947, -153582, -23613485, 6347715, -21072328, -667138, -25271143, -15367704, -870347, 14525639 ]) /* 1 / sqrt(a - d) */ @@ -98,6 +102,16 @@ const ed25519_invsqrtamd = fe25519([ 6111485, 4156064, -27798727, 12243468, -25904040, 120897, 20826367, -7060776, 6093568, -1986012 ]) +/* 1 - d ^ 2 */ +const ed25519_onemsqd = fe25519([ + 6275446, -16617371, -22938544, -3773710, 11667077, 7397348, -27922721, 1766195, -24433858, 672203 +]) + +/* (d - 1) ^ 2 */ +const ed25519_sqdmone = fe25519([ + 15551795, -11097455, -13425098, -10125071, -11896535, 10178284, -26634327, 4729244, -5282110, -10116402 +]) + const one = fe25519() fe25519_1(one) const basepoint = Buffer.alloc(32)