fe25519_25 fix imports and exports

This commit is contained in:
Christophe Diederichs 2022-11-18 12:20:21 +00:00
parent 7cad891d0e
commit 919353ba53

View File

@ -1,5 +1,4 @@
const assert = require('nanoassert') const assert = require('nanoassert')
const sodium = require('./')
const memory = new WebAssembly.Memory({ initial: 1 }) const memory = new WebAssembly.Memory({ initial: 1 })
const mem = Buffer.from(memory.buffer) const mem = Buffer.from(memory.buffer)
@ -72,6 +71,8 @@ function fe25519_pow22523 (h, f) {
const base = require('./fe25519_25/base.json').map(a => a.map(b => ge2(b))) const base = require('./fe25519_25/base.json').map(a => a.map(b => ge2(b)))
const printbuf =Buffer.alloc(32) const printbuf =Buffer.alloc(32)
const ed25519_A_32 = 486662
const ed25519_d = fe25519([ const ed25519_d = fe25519([
-10913610, 13857413, -15372611, 6949391, 114729, -8787816, -6275908, -3247719, -18696448, -12055116 -10913610, 13857413, -15372611, 6949391, 114729, -8787816, -6275908, -3247719, -18696448, -12055116
]) ])
@ -80,6 +81,10 @@ const ed25519_d2 = fe25519([
-21827239, -5839606, -30745221, 13898782, 229458, 15978800, -12551817, -6495438, 29715968, 9444199 -21827239, -5839606, -30745221, 13898782, 229458, 15978800, -12551817, -6495438, 29715968, 9444199
]) ])
const ed25519_A = fe25519([
ed25519_A_32, 0, 0, 0, 0, 0, 0, 0, 0, 0
])
const fe25519_sqrtm1 = fe25519([ const fe25519_sqrtm1 = fe25519([
-32595792, -7943725, 9377950, 3500415, 12389472, -272473, -25146209, -2005654, 326686, 11406482 -32595792, -7943725, 9377950, 3500415, 12389472, -272473, -25146209, -2005654, 326686, 11406482
]) ])
@ -102,6 +107,11 @@ module.exports = {
fe25519, fe25519,
ge2, ge2,
ge3, ge3,
ge25519_p2: ge2,
ge25519_p3: ge3,
ge25519_p1p1: ge3,
ge25519_precomp: ge3,
ge25519_cached: ge3,
print_ge, print_ge,
basepoint, basepoint,
fe25519_0, fe25519_0,
@ -128,6 +138,9 @@ module.exports = {
fe25519_pow22523, fe25519_pow22523,
fe25519_pow22523_1, fe25519_pow22523_1,
fe25519_sqrt, fe25519_sqrt,
ge25519_is_canonical,
ge25519_is_on_curve,
ge25519_is_on_main_subgroup,
ge25519_has_small_order, ge25519_has_small_order,
ge25519_frombytes, ge25519_frombytes,
ge25519_add_cached, ge25519_add_cached,
@ -2000,7 +2013,7 @@ function ge25519_is_on_curve (p) {
return fe25519_iszero(t0) return fe25519_iszero(t0)
} }
module.exports.ge25519_is_on_main_subgroup = ge25519_is_on_main_subgroup = function (p) { function ge25519_is_on_main_subgroup (p) {
var pl = ge3() var pl = ge3()
ge25519_mul_l(pl, p) ge25519_mul_l(pl, p)