use wasm implementations

This commit is contained in:
Christophe Diederichs 2023-05-23 16:44:24 +01:00
parent facf602fdc
commit 081ca46654
4 changed files with 16 additions and 5 deletions

View File

@ -54,8 +54,8 @@ function _crypto_scalarmult_ed25519 (q, n, p, clamp) {
var t = q.slice()
var i
// if (ec.ge25519_is_canonical(p) == 0 || ec.ge25519_has_small_order(p) != 0 ||
if (ec.ge25519_frombytes(P, p) != 0 || ec.ge25519_is_on_main_subgroup(P) == 0) {
if (ec.ge25519_is_canonical(p) == 0 || ec.ge25519_has_small_order(p) != 0 ||
ec.ge25519_frombytes(P, p) != 0 || ec.ge25519_is_on_main_subgroup(P) == 0) {
throw new Error('Invalid base point')
}

View File

@ -70,6 +70,12 @@ function fe25519_pow22523 (h, f) {
const base = require('./fe25519_25/base.json').map(a => a.map(b => ge2(b)))
const curve25519_h = Buffer.from([
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
])
const fe25519_sqrtm1 = fe25519([
-32595792, -7943725, 9377950, 3500415, 12389472, -272473, -25146209, -2005654, 326686, 11406482
])
@ -190,7 +196,8 @@ module.exports = {
ristretto255_frombytes,
ristretto255_p3_tobytes,
ristretto255_elligator,
ristretto255_from_hash
ristretto255_from_hash,
curve25519_h
}
function print_ge (g, n = 4) {

View File

@ -14,6 +14,7 @@ var sodium = module.exports
forward(require('./crypto_box'))
forward(require('./crypto_core'))
forward(require('./crypto_core_ristretto255'))
forward(require('./crypto_generichash'))
forward(require('./crypto_hash'))
forward(require('./crypto_hash_sha256'))
@ -21,16 +22,18 @@ forward(require('./crypto_kdf'))
forward(require('./crypto_kx'))
forward(require('./crypto_aead'))
forward(require('./crypto_onetimeauth'))
// forward(require('./crypto_scalarmult_ed25519'))
forward(require('./crypto_scalarmult'))
forward(require('./crypto_scalarmult_ed25519'))
// forward(require('./crypto_scalarmult'))
forward(require('./crypto_secretbox'))
forward(require('./crypto_shorthash'))
// forward(require('./crypto_sign'))
forward(require('./crypto_sign_ed25519'))
forward(require('./crypto_stream'))
forward(require('./crypto_stream_chacha20'))
forward(require('./crypto_tweak'))
forward(require('./crypto_verify'))
forward(require('./randombytes'))
forward(require('./utils'))
function forward (submodule) {
Object.keys(submodule).forEach(function (prop) {

View File

@ -15,6 +15,7 @@
"devDependencies": {
"browser-run": "^4.0.2",
"browserify": "^14.1.0",
"sodium-native": "^3.4.1",
"sodium-test": "^0.7.0"
},
"browser": {