From bafe8f8fac039d92db824ecf0bd97fa6be1e0947 Mon Sep 17 00:00:00 2001 From: Christophe Diederichs Date: Fri, 16 Oct 2020 01:10:52 +0200 Subject: [PATCH] first attempt at wassm scalarmult --- crypto_scalarmult_ed25519.js | 39 + ed-wasm.js | 13 +- fe-test.js | 4 +- fe25519_25.js | 123 +- fe25519_25/fe25519_invert.js | 2 +- fe25519_25/fe25519_invert.wat | 30 +- fe25519_25/fe25519_mul.js | 3 +- fe25519_25/fe25519_pow22523.js | 2 +- fe25519_25/fe25519_pow22523.wat | 30 +- fe25519_25/sc25519_mul.js | 1 + fe25519_25/scalarmult_curve25519.js | 2 +- fe25519_25/scalarmult_curve25519.wat | 2377 +++++++++++++------------- 12 files changed, 1339 insertions(+), 1287 deletions(-) diff --git a/crypto_scalarmult_ed25519.js b/crypto_scalarmult_ed25519.js index 3c17654..58d835d 100644 --- a/crypto_scalarmult_ed25519.js +++ b/crypto_scalarmult_ed25519.js @@ -6,6 +6,7 @@ module.exports = { crypto_scalarmult_ed25519, crypto_scalarmult_ed25519_base, crypto_scalarmult_curve25519, + crypto_scalarmult_curve25519_1, crypto_scalarmult_curve25519_base } @@ -294,6 +295,44 @@ function crypto_scalarmult_curve25519 (q, n, p) { return 0 } +function crypto_scalarmult_curve25519_1 (q, n, p) { + var t = q.slice() + var i + var x1 = ec.fe25519() + var x2 = ec.fe25519() + var z2 = ec.fe25519() + var x3 = ec.fe25519() + var z3 = ec.fe25519() + var pos + var swap + var b + + if (has_small_order(p)) { + return -1; + } + for (i = 0; i < 32; i++) { + t[i] = n[i] + } + t[0] &= 248 + t[31] &= 127 + t[31] |= 64 + ec.fe25519_frombytes(x1, p) + ec.fe25519_1(x2) + ec.fe25519_0(z2) + ec.fe25519_copy(x3, x1) + ec.fe25519_1(z3) + + swap = ec.scalarmult_curve25519_inner_loop(x1, x2, x3, z2, z3, t) + ec.fe25519_cswap(x2, x3, swap) + ec.fe25519_cswap(z2, z3, swap) + + ec.fe25519_invert(z2, z2) + ec.fe25519_mul(x2, x2, z2) + ec.fe25519_tobytes(q, x2) + + return 0 +} + function edwards_to_montgomery(montgomeryX, edwardsY, edwardsZ) { var tempX = ec.fe25519() var tempZ = ec.fe25519() diff --git a/ed-wasm.js b/ed-wasm.js index 26ef73f..02e5d31 100644 --- a/ed-wasm.js +++ b/ed-wasm.js @@ -1,5 +1,5 @@ const sodium = require('./') -const { crypto_scalarmult_ed25519, crypto_scalarmult_ed25519_base, crypto_scalarmult_curve25519, crypto_scalarmult_curve25519_base } = require('./crypto_scalarmult_ed25519') +const { crypto_scalarmult_ed25519, crypto_scalarmult_ed25519_base, crypto_scalarmult_curve25519, crypto_scalarmult_curve25519_1, crypto_scalarmult_curve25519_base } = require('./crypto_scalarmult_ed25519') const { crypto_sign, crypto_sign_open } = require('./crypto_sign_ed25519') console.log(crypto_scalarmult_ed25519) @@ -102,13 +102,24 @@ for (let test of fixtures) { sodium.crypto_scalarmult(res, test.sk, test.pk) } console.timeEnd('hello') +console.log(res.toString('hex')) +const res1 = Buffer.from(res) console.time('ed') for (let test of fixtures) { crypto_scalarmult_curve25519(res, test.sk, test.pk) } console.timeEnd('ed') +console.time('wasm') +for (let test of fixtures) { + crypto_scalarmult_curve25519_1(res1, test.sk, test.pk) +} +console.timeEnd('wasm') + +console.log(res.toString('hex')) +console.log(res1.toString('hex')) + // console.log(sm.toString('hex')) // pass &= smlen === sodium.crypto_sign_BYTES + test.m.byteLength diff --git a/fe-test.js b/fe-test.js index 5230f5c..29b4085 100644 --- a/fe-test.js +++ b/fe-test.js @@ -165,14 +165,14 @@ console.log('tess :', res.toString('hex')) console.time('standard') -for (let i = 0; i < 10000; i++) ec.fe25519_pow22523(b, a) +for (let i = 0; i < 10000; i++) ec.fe25519_invert(b, a) console.timeEnd('standard') ec.fe25519_tobytes(res, b) console.log('tess :', res.toString('hex')) console.time('pure invert') -for (let i = 0; i < 10000; i++) wasm_pow(b, a) +for (let i = 0; i < 10000; i++) ec.fe25519_invert_1(b, a) console.timeEnd('pure invert') ec.fe25519_tobytes(res, b) console.log('tess :', res.toString('hex')) diff --git a/fe25519_25.js b/fe25519_25.js index 0e167d9..fe05ef3 100644 --- a/fe25519_25.js +++ b/fe25519_25.js @@ -11,50 +11,26 @@ const debug = { } } -const wasm_mul = require('./fe25519_25/fe25519_mul')({ - imports: { debug } -}) -const wasm_sq = require('./fe25519_25/fe25519_sq')({ - imports: { debug } -}) -const wasm_invert = require('./fe25519_25/fe25519_invert')({ - imports: { debug } -}) -const wasm_pow = require('./fe25519_25/fe25519_pow22523')({ - imports: { debug } -}) - -const tbl = new WebAssembly.Table({ initial: 2, element: "anyfunc" }) - -const wasm_sc_red = require('./fe25519_25/sc_reduce')({ - imports: { - debug, +const importObject = { + imports: { js: { - table: tbl - } + table: new WebAssembly.Table({ initial: 3, element: "anyfunc" }) + }, + debug } -}) +} -const wasm_sc_mul = require('./fe25519_25/sc25519_mul')({ - imports: { - debug, - js: { - table: tbl - } - } -}) - -const wasm_sc_muladd = require('./fe25519_25/sc25519_muladd')({ - imports: { - debug, - js: { - table: tbl - } - } -}) +const wasm_mul = require('./fe25519_25/fe25519_mul')(importObject) +const wasm_sq = require('./fe25519_25/fe25519_sq')(importObject) +const wasm_invert = require('./fe25519_25/fe25519_invert')() +const wasm_pow = require('./fe25519_25/fe25519_pow22523')() +const wasm_sc_red = require('./fe25519_25/sc_reduce')(importObject) +const wasm_sc_mul = require('./fe25519_25/sc25519_mul')(importObject) +const wasm_sc_muladd = require('./fe25519_25/sc25519_muladd')(importObject) +const wasm_scalaramult_internal = require('./fe25519_25/scalarmult_curve25519')(importObject) function fe25519_invert (h, f) { - var buf = Buffer.from(f.buffer) + var buf = new Uint8Array(f.buffer) wasm_invert.memory.set(buf) wasm_invert.exports.fe25519_invert(40, 0) @@ -63,10 +39,13 @@ function fe25519_invert (h, f) { for (let i = 0; i < 10; i++) { h[i] = buf.readUInt32LE(4 * i) } + for (let i = 0; i < 10; i++) { + h[i] = buf.readUInt32LE(4 * i) + } } function fe25519_pow22523 (h, f) { - var buf = Buffer.from(f.buffer) + var buf = new Uint8Array(f.buffer) wasm_pow.memory.set(buf) wasm_pow.exports.fe25519_pow22523(40, 0) @@ -75,6 +54,9 @@ function fe25519_pow22523 (h, f) { for (let i = 0; i < 10; i++) { h[i] = buf.readUInt32LE(4 * i) } + for (let i = 0; i < 10; i++) { + h[i] = buf.readUInt32LE(4 * i) + } } const base = require('./fe25519_25/base.json').map(a => a.map(b => ge2(b))) @@ -104,9 +86,10 @@ module.exports = { fe25519_sq, fe25519_sqmul, fe25519_sq2, - fe25519_invert: fe25519_invert, - fe25519_pow22523: fe25519_pow22523, - fe25519_unchecked_sqrt, + fe25519_invert, + fe25519_invert_1, + fe25519_pow22523, + fe25519_pow22523_1, fe25519_sqrt, ge25519_has_small_order, ge25519_frombytes, @@ -132,6 +115,7 @@ module.exports = { ge25519_elligator2, ge25519_from_uniform, ge25519_from_hash, + scalarmult_curve25519_inner_loop, ristretto255_sqrt_ratio_m1, ristretto255_is_canonical, ristretto255_frombytes, @@ -778,8 +762,8 @@ function fe25519_mul (h, f, g) { // printFe(f, 'f') // printFe(g, 'g') - var fbuf = Buffer.from(f.buffer) - var gbuf = Buffer.from(g.buffer) + var fbuf = new Uint8Array(f.buffer) + var gbuf = new Uint8Array(g.buffer) wasm_mul.memory.set(fbuf) wasm_mul.memory.set(gbuf, 40) @@ -806,7 +790,7 @@ function fe25519_sq (h, f, log) { check_fe(h) check_fe(f) - var buf = Buffer.from(f.buffer) + var buf = new Uint8Array(f.buffer) wasm_sq.memory.set(buf) wasm_sq.exports.sq(40, 0, 0) @@ -832,7 +816,7 @@ function fe25519_sq2 (h, f) { check_fe(h) check_fe(f) - var buf = Buffer.from(f.buffer) + var buf = new Uint8Array(f.buffer) wasm_sq.memory.set(buf) wasm_sq.exports.sq(40, 0, 1) @@ -998,7 +982,6 @@ function fe25519_sqrt (x, x2) { fe25519_copy(x2_copy, x2) fe25519_unchecked_sqrt(x, x2) - console.log(x, 'sqrt') fe25519_sq(check, x) fe25519_sub(check, check, x2_copy) @@ -2309,7 +2292,7 @@ function sc25519_reduce (s) { _s[22] = 2097151 & (load_4(s, 57) >>> 6) _s[23] = load_4(s, 60) >>> 3 - var sbuf = Buffer.from(_s.buffer) + var sbuf = new Uint8Array(_s.buffer) wasm_sc_red.memory.set(sbuf, 0) wasm_sc_red.exports.sc25519_reduce(0) @@ -2835,6 +2818,48 @@ function ristretto255_from_hash (s, h) { ristretto255_p3_tobytes(s, p) } +function scalarmult_curve25519_inner_loop (x1, x2, x3, z2, z3, t) { + check_fe(x1) + check_fe(x2) + check_fe(x3) + check_fe(z2) + check_fe(z3) + assert(t instanceof Uint8Array && t.byteLength === 32) + + // printFe(f, 'f') + // printFe(g, 'g') + const x1buf = new Uint8Array(x1.buffer) + const x2buf = new Uint8Array(x2.buffer) + const x3buf = new Uint8Array(x3.buffer) + const z2buf = new Uint8Array(z2.buffer) + const z3buf = new Uint8Array(z3.buffer) + const tbuf = new Uint8Array(t.buffer) + + wasm_scalaramult_internal.memory.set(x1buf, 0) + wasm_scalaramult_internal.memory.set(x2buf, 40) + wasm_scalaramult_internal.memory.set(x3buf, 80) + wasm_scalaramult_internal.memory.set(z2buf, 120) + wasm_scalaramult_internal.memory.set(z3buf, 160) + wasm_scalaramult_internal.memory.set(tbuf, 200) + const swap = wasm_scalaramult_internal.exports.scalarmult(0, 40, 80, 120, 160, 200, 240, 280, 320, 360) + + buf = Buffer.from(wasm_scalaramult_internal.memory.slice(240, 400)) + for (let i = 0; i < 10; i++) { + x2[i] = buf.readInt32LE(4 * i) + } + for (let i = 10; i < 20; i++) { + x3[i % 10] = buf.readInt32LE(4 * i) + } + for (let i = 20; i < 30; i++) { + z2[i % 10] = buf.readInt32LE(4 * i) + } + for (let i = 30; i < 40; i++) { + z3[i % 10] = buf.readInt32LE(4 * i) + } + + return swap +} + function check_fe (h) { assert(h instanceof Int32Array) assert(h.length === 10) diff --git a/fe25519_25/fe25519_invert.js b/fe25519_25/fe25519_invert.js index 7da55b9..2d027e6 100644 --- a/fe25519_25/fe25519_invert.js +++ b/fe25519_25/fe25519_invert.js @@ -7,7 +7,7 @@ function loadWebAssembly (opts) { if (!loadWebAssembly.supported) return null var imp = opts && opts.imports - var wasm = toUint8Array('AGFzbQEAAAABQQpgAX8AYAF/AX9gAn9/AGABfQBgAX0BfWABfABgAXwBfGABfgBgAX4BfmAUfn5+fn5+fn5+fn5+fn5+fn5+fn4AAmEHBWRlYnVnA2xvZwAABWRlYnVnB2xvZ190ZWUAAQVkZWJ1ZwNsb2cAAgVkZWJ1ZwNsb2cAAwVkZWJ1Zwdsb2dfdGVlAAQFZGVidWcDbG9nAAUFZGVidWcHbG9nX3RlZQAGAwUEBwgJAgUDAQABBjMKfgFCAAt+AUIAC34BQgALfgFCAAt+AUIAC34BQgALfgFCAAt+AUIAC34BQgALfgFCAAsHGwIGbWVtb3J5AgAOZmUyNTUxOV9pbnZlcnQACgrDHQQNACAAQiCHpyAApxACCwkAIAAQByAADwuzDwF8fiAAp6whACABp6whASACp6whAiADp6whAyAEp6whBCAFp6whBSAGp6whBiAHp6whByAIp6whCCAJp6whCSAKp6whCiALp6whCyAMp6whDCANp6whDSAOp6whDiAPp6whDyAQp6whECARp6whESASp6whEiATp6whE0ITIAt+IAtCgICAgAiDQgGGQhN+fSEeQhMgDH4gDEKAgICACINCAYZCE359IR9CEyANfiANQoCAgIAIg0IBhkITfn0hIEITIA5+IA5CgICAgAiDQgGGQhN+fSEhQhMgD34gD0KAgICACINCAYZCE359ISJCEyAQfiAQQoCAgIAIg0IBhkITfn0hI0ITIBF+IBFCgICAgAiDQgGGQhN+fSEkQhMgEn4gEkKAgICACINCAYZCE359ISVCEyATfiATQoCAgIAIg0IBhkITfn0hJkICIAF+IAFCgICAgAiDQgGGQgJ+fSEnQgIgA34gA0KAgICACINCAYZCAn59IShCAiAFfiAFQoCAgIAIg0IBhkICfn0hKUICIAd+IAdCgICAgAiDQgGGQgJ+fSEqQgIgCX4gCUKAgICACINCAYZCAn59ISsgHqesIR4gH6esIR8gIKesISAgIaesISEgIqesISIgI6esISMgJKesISQgJaesISUgJqesISYgJ6esIScgKKesISggKaesISkgKqesISogK6esISsgACAKfiEsIAAgC34hLSAAIAx+IS4gACANfiEvIAAgDn4hMCAAIA9+ITEgACAQfiEyIAAgEX4hMyAAIBJ+ITQgACATfiE1IAEgCn4hNiAnIAt+ITcgASAMfiE4ICcgDX4hOSABIA5+ITogJyAPfiE7IAEgEH4hPCAnIBF+IT0gASASfiE+ICcgJn4hPyACIAp+IUAgAiALfiFBIAIgDH4hQiACIA1+IUMgAiAOfiFEIAIgD34hRSACIBB+IUYgAiARfiFHIAIgJX4hSCACICZ+IUkgAyAKfiFKICggC34hSyADIAx+IUwgKCANfiFNIAMgDn4hTiAoIA9+IU8gAyAQfiFQICggJH4hUSADICV+IVIgKCAmfiFTIAQgCn4hVCAEIAt+IVUgBCAMfiFWIAQgDX4hVyAEIA5+IVggBCAPfiFZIAQgI34hWiAEICR+IVsgBCAlfiFcIAQgJn4hXSAFIAp+IV4gKSALfiFfIAUgDH4hYCApIA1+IWEgBSAOfiFiICkgIn4hYyAFICN+IWQgKSAkfiFlIAUgJX4hZiApICZ+IWcgBiAKfiFoIAYgC34haSAGIAx+IWogBiANfiFrIAYgIX4hbCAGICJ+IW0gBiAjfiFuIAYgJH4hbyAGICV+IXAgBiAmfiFxIAcgCn4hciAqIAt+IXMgByAMfiF0ICogIH4hdSAHICF+IXYgKiAifiF3IAcgI34heCAqICR+IXkgByAlfiF6ICogJn4heyAIIAp+IXwgCCALfiF9IAggH34hfiAIICB+IX8gCCAhfiGAASAIICJ+IYEBIAggI34hggEgCCAkfiGDASAIICV+IYQBIAggJn4hhQEgCSAKfiGGASArIB5+IYcBIAkgH34hiAEgKyAgfiGJASAJICF+IYoBICsgIn4hiwEgCSAjfiGMASArICR+IY0BIAkgJX4hjgEgKyAmfiGPASAsID8gSCBRIFogYyBsIHUgfiCHAXx8fHx8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CCAAIwM+AgwgACMEPgIQIAAjBT4CFCAAIwY+AhggACMHPgIcIAAjCD4CICAAIwk+AiQL') + var wasm = toUint8Array('AGFzbQEAAAABHQJgFH5+fn5+fn5+fn5+fn5+fn5+fn5+AGACf38AAwMCAAEFAwEAAQYzCn4BQgALfgFCAAt+AUIAC34BQgALfgFCAAt+AUIAC34BQgALfgFCAAt+AUIAC34BQgALBxsCBm1lbW9yeQIADmZlMjU1MTlfaW52ZXJ0AAEKqx0Csw8BfH4gAKesIQAgAaesIQEgAqesIQIgA6esIQMgBKesIQQgBaesIQUgBqesIQYgB6esIQcgCKesIQggCaesIQkgCqesIQogC6esIQsgDKesIQwgDaesIQ0gDqesIQ4gD6esIQ8gEKesIRAgEaesIREgEqesIRIgE6esIRNCEyALfiALQoCAgIAIg0IBhkITfn0hHkITIAx+IAxCgICAgAiDQgGGQhN+fSEfQhMgDX4gDUKAgICACINCAYZCE359ISBCEyAOfiAOQoCAgIAIg0IBhkITfn0hIUITIA9+IA9CgICAgAiDQgGGQhN+fSEiQhMgEH4gEEKAgICACINCAYZCE359ISNCEyARfiARQoCAgIAIg0IBhkITfn0hJEITIBJ+IBJCgICAgAiDQgGGQhN+fSElQhMgE34gE0KAgICACINCAYZCE359ISZCAiABfiABQoCAgIAIg0IBhkICfn0hJ0ICIAN+IANCgICAgAiDQgGGQgJ+fSEoQgIgBX4gBUKAgICACINCAYZCAn59ISlCAiAHfiAHQoCAgIAIg0IBhkICfn0hKkICIAl+IAlCgICAgAiDQgGGQgJ+fSErIB6nrCEeIB+nrCEfICCnrCEgICGnrCEhICKnrCEiICOnrCEjICSnrCEkICWnrCElICanrCEmICenrCEnICinrCEoICmnrCEpICqnrCEqICunrCErIAAgCn4hLCAAIAt+IS0gACAMfiEuIAAgDX4hLyAAIA5+ITAgACAPfiExIAAgEH4hMiAAIBF+ITMgACASfiE0IAAgE34hNSABIAp+ITYgJyALfiE3IAEgDH4hOCAnIA1+ITkgASAOfiE6ICcgD34hOyABIBB+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UjBiMHIwgjCSMAIwEjAiMDIwQjBSMGIwcjCCMJEAAMAAsLQQAhDCAOIBEgFCAXIBogHSAgICMgJiApIwAjASMCIwMjBCMFIwYjByMIIwkQACMAIQ4jASERIwIhFCMDIRcjBCEaIwUhHSMGISAjByEjIwghJiMJISkCQANAQTIgDEYNASAMQQFqIQwjACMBIwIjAyMEIwUjBiMHIwgjCSMAIwEjAiMDIwQjBSMGIwcjCCMJEAAMAAsLQQAhDCAOIBEgFCAXIBogHSAgICMgJiApIwAjASMCIwMjBCMFIwYjByMIIwkQACMAIQ8jASESIwIhFSMDIRgjBCEbIwUhHiMGISEjByEkIwghJyMJISoCQANAQeQAIAxGDQEgDEEBaiEMIwAjASMCIwMjBCMFIwYjByMIIwkjACMBIwIjAyMEIwUjBiMHIwgjCRAADAALC0EAIQwgDyASIBUgGCAbIB4gISAkICcgKiMAIwEjAiMDIwQjBSMGIwcjCCMJEAACQANAQTIgDEYNASAMQQFqIQwjACMBIwIjAyMEIwUjBiMHIwgjCSMAIwEjAiMDIwQjBSMGIwcjCCMJEAAMAAsLQQAhDCAOIBEgFCAXIBogHSAgICMgJiApIwAjASMCIwMjBCMFIwYjByMIIwkQAAJAA0BBBSAMRg0BIAxBAWohDCMAIwEjAiMDIwQjBSMGIwcjCCMJIwAjASMCIwMjBCMFIwYjByMIIwkQAAwACwsgDSAQIBMgFiAZIBwgHyAiICUgKCMAIwEjAiMDIwQjBSMGIwcjCCMJEAAgACMAPgIAIAAjAT4CBCAAIwI+AgggACMDPgIMIAAjBD4CECAAIwU+AhQgACMGPgIYIAAjBz4CHCAAIwg+AiAgACMJPgIkCw==') var ready = null var mod = { diff --git a/fe25519_25/fe25519_invert.wat b/fe25519_25/fe25519_invert.wat index 5bfff9c..5bb7223 100644 --- a/fe25519_25/fe25519_invert.wat +++ b/fe25519_25/fe25519_invert.wat @@ -1,34 +1,6 @@ -(module - (func $i32.log (import "debug" "log") (param i32)) - (func $i32.log_tee (import "debug" "log_tee") (param i32) (result i32)) - ;; No i64 interop with JS yet - but maybe coming with WebAssembly BigInt - ;; So we can instead fake this by splitting the i64 into two i32 limbs, - ;; however these are WASM functions using i32x2.log: - (func $i32x2.log (import "debug" "log") (param i32) (param i32)) - (func $f32.log (import "debug" "log") (param f32)) - (func $f32.log_tee (import "debug" "log_tee") (param f32) (result f32)) - (func $f64.log (import "debug" "log") (param f64)) - (func $f64.log_tee (import "debug" "log_tee") (param f64) (result f64)) - +(module (memory $0 1) (export "memory" (memory $0)) - - ;; i64 logging by splitting into two i32 limbs - (func $i64.log - (param $0 i64) - (call $i32x2.log - ;; Upper limb - (i32.wrap/i64 - (i64.shr_s (get_local $0) - (i64.const 32))) - ;; Lower limb - (i32.wrap/i64 (get_local $0)))) - - (func $i64.log_tee - (param $0 i64) - (result i64) - (call $i64.log (get_local $0)) - (return (get_local $0))) (global $tmp0 (mut i64) (i64.const 0)) (global $tmp1 (mut i64) (i64.const 0)) diff --git a/fe25519_25/fe25519_mul.js b/fe25519_25/fe25519_mul.js index fd1852f..826c4c6 100644 --- a/fe25519_25/fe25519_mul.js +++ b/fe25519_25/fe25519_mul.js @@ -6,7 +6,7 @@ loadWebAssembly.supported = typeof WebAssembly !== 'undefined' function loadWebAssembly (opts) { if (!loadWebAssembly.supported) return null - var imp = opts && opts.imports + var imp = opts && opts.imports || { imports: {} } var wasm = toUint8Array('AGFzbQEAAAABHwJgFX5+fn5+fn5+fn5+fn5+fn5+fn5+fwBgA39/fwACDgECanMFdGFibGUBcAABAwMCAAEFAwEAAQcYAgZtZW1vcnkCAAtmZTI1NTE5X211bAABCQcBAEEBCwEACv4QApAQAYYBfiAAp6whACABp6whASACp6whAiADp6whAyAEp6whBCAFp6whBSAGp6whBiAHp6whByAIp6whCCAJp6whCSAKp6whCiALp6whCyAMp6whDCANp6whDSAOp6whDiAPp6whDyAQp6whECARp6whESASp6whEiATp6whE0ITIAt+IAtCgICAgAiDQgGGQhN+fSEpQhMgDH4gDEKAgICACINCAYZCE359ISpCEy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gGSAifCEZIBggIkIBQhmGfn0hGCAcQgFCGIZ8QhmHISYgHSAmfCEdIBwgJkIBQhmGfn0hHCAZQgFCGYZ8QhqHISMgGiAjfCEaIBkgI0IBQhqGfn0hGSAdQgFCGYZ8QhqHIScgHiAnfCEeIB0gJ0IBQhqGfn0hHSAeQgFCGIZ8QhmHISggFSAoQhN+fCEVIB4gKEIBQhmGfn0hHiAVQgFCGYZ8QhqHIR8gFiAffCEWIBUgH0IBQhqGfn0hFSAUIBU+AgAgFCAWPgIEIBQgFz4CCCAUIBg+AgwgFCAZPgIQIBQgGj4CFCAUIBs+AhggFCAcPgIcIBQgHT4CICAUIB4+AiQLagAgATUCACABNQIEIAE1AgggATUCDCABNQIQIAE1AhQgATUCGCABNQIcIAE1AiAgATUCJCACNQIAIAI1AgQgAjUCCCACNQIMIAI1AhAgAjUCFCACNQIYIAI1AhwgAjUCICACNQIkIAAQAAs=') var ready = null @@ -39,6 +39,7 @@ function loadWebAssembly (opts) { if (opts && opts.async) throw new Error('async') setup({instance: new WebAssembly.Instance(new WebAssembly.Module(wasm), imp)}) } catch (err) { + console.log(err) ready = WebAssembly.instantiate(wasm, imp).then(setup) } diff --git a/fe25519_25/fe25519_pow22523.js b/fe25519_25/fe25519_pow22523.js index 17a08cd..3656289 100644 --- a/fe25519_25/fe25519_pow22523.js +++ b/fe25519_25/fe25519_pow22523.js @@ -7,7 +7,7 @@ function loadWebAssembly (opts) { if (!loadWebAssembly.supported) return null var imp = opts && opts.imports - var wasm = toUint8Array('AGFzbQEAAAABQQpgAX8AYAF/AX9gAn9/AGABfQBgAX0BfWABfABgAXwBfGABfgBgAX4BfmAUfn5+fn5+fn5+fn5+fn5+fn5+fn4AAmEHBWRlYnVnA2xvZwAABWRlYnVnB2xvZ190ZWUAAQVkZWJ1ZwNsb2cAAgVkZWJ1ZwNsb2cAAwVkZWJ1Zwdsb2dfdGVlAAQFZGVidWcDbG9nAAUFZGVidWcHbG9nX3RlZQAGAwUEBwgJAgUDAQ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ACINCAYZCE359IR9CEyANfiANQoCAgIAIg0IBhkITfn0hIEITIA5+IA5CgICAgAiDQgGGQhN+fSEhQhMgD34gD0KAgICACINCAYZCE359ISJCEyAQfiAQQoCAgIAIg0IBhkITfn0hI0ITIBF+IBFCgICAgAiDQgGGQhN+fSEkQhMgEn4gEkKAgICACINCAYZCE359ISVCEyATfiATQoCAgIAIg0IBhkITfn0hJkICIAF+IAFCgICAgAiDQgGGQgJ+fSEnQgIgA34gA0KAgICACINCAYZCAn59IShCAiAFfiAFQoCAgIAIg0IBhkICfn0hKUICIAd+IAdCgICAgAiDQgGGQgJ+fSEqQgIgCX4gCUKAgICACINCAYZCAn59ISsgHqesIR4gH6esIR8gIKesISAgIaesISEgIqesISIgI6esISMgJKesISQgJaesISUgJqesISYgJ6esIScgKKesISggKaesISkgKqesISogK6esISsgACAKfiEsIAAgC34hLSAAIAx+IS4gACANfiEvIAAgDn4hMCAAIA9+ITEgACAQfiEyIAAgEX4hMyAAIBJ+ITQgACATfiE1IAEgCn4hNiAnIAt+ITcgASAMfiE4ICcgDX4hOSABIA5+ITogJyAPfiE7IAEgEH4hPCAnIBF+IT0gASASfiE+ICcgJn4hPyACIAp+IUAgAiALfiFBIAIgDH4hQiACIA1+IUMgAiAOfiFEIAIgD34hRSACIBB+IUYgAiARfiFHIAIgJX4hSCACICZ+IUkgAyAKfiFKICggC34hSyADIAx+IUwgKCANfiFNIAMgDn4hTiAoIA9+IU8gAyAQfiFQICggJH4hUSADICV+IVIgKCAmfiFTIAQgCn4hVCAEIAt+IVUgBCAMfiFWIAQgDX4hVyAEIA5+IVggBCAPfiFZIAQgI34hWiAEICR+IVsgBCAlfiFcIAQgJn4hXSAFIAp+IV4gKSALfiFfIAUgDH4hYCApIA1+IWEgBSAOfiFiICkgIn4hYyAFICN+IWQgKSAkfiFlIAUgJX4hZiApICZ+IWcgBiAKfiFoIAYgC34haSAGIAx+IWogBiANfiFrIAYgIX4hbCAGICJ+IW0gBiAjfiFuIAYgJH4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wcjCCMJEAAMAAsLQQAhDCANIA8gESATIBUgFyAZIBsgHSAfIwAjASMCIwMjBCMFIwYjByMIIwkQACMAIwEjAiMDIwQjBSMGIwcjCCMJIwAjASMCIwMjBCMFIwYjByMIIwkQACMAIwEjAiMDIwQjBSMGIwcjCCMJIwAjASMCIwMjBCMFIwYjByMIIwkQACACIAMgBCAFIAYgByAIIAkgCiALIwAjASMCIwMjBCMFIwYjByMIIwkQACAAIwA+AgAgACMBPgIEIAAjAj4CCCAAIwM+AgwgACMEPgIQIAAjBT4CFCAAIwY+AhggACMHPgIcIAAjCD4CICAAIwk+AiQL') var ready = null var mod = { diff --git a/fe25519_25/fe25519_pow22523.wat b/fe25519_25/fe25519_pow22523.wat index 4afad0b..958935c 100644 --- a/fe25519_25/fe25519_pow22523.wat +++ b/fe25519_25/fe25519_pow22523.wat @@ -1,34 +1,6 @@ -(module - (func $i32.log (import "debug" "log") (param i32)) - (func $i32.log_tee (import "debug" "log_tee") (param i32) (result i32)) - ;; No i64 interop with JS yet - but maybe coming with WebAssembly BigInt - ;; So we can instead fake this by splitting the i64 into two i32 limbs, - ;; however these are WASM functions using i32x2.log: - (func $i32x2.log (import "debug" "log") (param i32) (param i32)) - (func $f32.log (import "debug" "log") (param f32)) - (func $f32.log_tee (import "debug" "log_tee") (param f32) (result f32)) - (func $f64.log (import "debug" "log") (param f64)) - (func $f64.log_tee (import "debug" "log_tee") (param f64) (result f64)) - +(module (memory $0 1) (export "memory" (memory $0)) - - ;; i64 logging by splitting into two i32 limbs - (func $i64.log - (param $0 i64) - (call $i32x2.log - ;; Upper limb - (i32.wrap/i64 - (i64.shr_s (get_local $0) - (i64.const 32))) - ;; Lower limb - (i32.wrap/i64 (get_local $0)))) - - (func $i64.log_tee - (param $0 i64) - (result i64) - (call $i64.log (get_local $0)) - (return (get_local $0))) (global $tmp0 (mut i64) (i64.const 0)) (global $tmp1 (mut i64) (i64.const 0)) diff --git a/fe25519_25/sc25519_mul.js b/fe25519_25/sc25519_mul.js index 81a0206..327b0dc 100644 --- a/fe25519_25/sc25519_mul.js +++ b/fe25519_25/sc25519_mul.js @@ -39,6 +39,7 @@ function loadWebAssembly (opts) { if (opts && opts.async) throw new Error('async') setup({instance: new WebAssembly.Instance(new WebAssembly.Module(wasm), imp)}) } catch (err) { + console.log(err) ready = WebAssembly.instantiate(wasm, imp).then(setup) } diff --git a/fe25519_25/scalarmult_curve25519.js b/fe25519_25/scalarmult_curve25519.js index c05f7ec..66eefbb 100644 --- a/fe25519_25/scalarmult_curve25519.js +++ b/fe25519_25/scalarmult_curve25519.js @@ -7,7 +7,7 @@ function loadWebAssembly (opts) { if (!loadWebAssembly.supported) return null var imp = opts && opts.imports - var wasm = toUint8Array('AGFzbQEAAAABNwNgFX5+fn5+fn5+fn5+fn5+fn5+fn5+fwBgDX5+fn5+fn5+fn5/f38AYAp/f39/f39/f39/AX8CDgECanMFdGFibGUBcAABAwIBAgUDAQABBxcCBm1lbW9yeQIACnNjYWxhcm11bHQAAArWFgHTFgIHf0x+IAUpAwAhEyAFKQMIIRQgBSkDECEVIAUpAxghFiAANQIAIRcgADUCBCEYIAA1AgghGSAANQIMIRogADUCECEbIAA1AhQhHCAANQIYIR0gADUCHCEeIAA1AiAhHyAANQIkISAgATUCACEhIAE1AgQhIiABNQIIISMgATUCDCEkIAE1AhAhJSABNQIUISYgATUCGCEnIAE1AhwhKCABNQIgISkgATUCJCEqIAI1AgAhNSACNQIEITYgAjUCCCE3IAI1AgwhOCACNQIQITkgAjUCFCE6IAI1AhghOyACNQIcITwgAjUCICE9IAI1AiQhPiADNQIAISsgAzUCBCEsIAM1AgghLSADNQIMIS4gAzUCECEvIAM1AhQhMCADNQIYITEgAzUCHCEyIAM1AiAhMyADNQIkITQgBDUCACE/IAQ1AgQhQCAENQIIIUEgBDUCDCFCIAQ1AhAhQyAENQIUIUQgBDUCGCFFIAQ1AhwhRiAENQIgIUcgBDUCJCFIQf4BIQwDQEEAIAxIDQACQAJAAkACQAJAAkAgDE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CDCEuIA01AhAhLyANNQIUITAgDTUCGCExIA01AhwhMiANNQIgITMgDTUCJCE0IA41AgAhPyAONQIEIUAgDjUCCCFBIA41AgwhQiAONQIQIUMgDjUCFCFEIA41AhghRSAONQIcIUYgDjUCICFHIA41AiQhSCAPNQIAITUgDzUCBCE2IA81AgghNyAPNQIMITggDzUCECE5IA81AhQhOiAPNQIYITsgDzUCHCE8IA81AiAhPSAPNQIkIT4gSSA/fCFJIEogQHwhSiBLIEF8IUsgTCBCfCFMIE0gQ3whTSBOIER8IU4gTyBFfCFPIFAgRnwhUCBRIEd8IVEgUiBIfCFSIBcgGCAZIBogGyAcIB0gHiAfICAgKyAsIC0gLiAvIDAgMSAyIDMgNCAOQQERAAAgSSBKIEsgTCBNIE4gTyBQIFEgUiBTIFQgVSBWIFcgWCBZIFogWyBcIA1BAREAACANNQIAISsgDTUCBCEsIA01AgghLSANNQIMIS4gDTUCECEvIA01AhQhMCANNQIYITEgDTUCHCEyIA01AiAhMyANNQIkITQgDjUCACE/IA41AgQhQCAONQIIIUEgDjUCDCFCIA41AhAhQyAONQIUIUQgDjUCGCFFIA41AhwhRiAONQIgIUcgDjUCJCFIIAxBAWshDAwACwsgBiAhPgIAIAYgIj4CBCAGICM+AgggBiAkPgIMIAYgJT4CECAGICY+AhQgBiAnPgIYIAYgKD4CHCAGICk+AiAgBiAqPgIkIAcgNT4CACAHIDY+AgQgByA3PgIIIAcgOD4CDCAHIDk+AhAgByA6PgIUIAcgOz4CGCAHIDw+AhwgByA9PgIgIAcgPj4CJCAIICs+AgAgCCAsPgIEIAggLT4CCCAIIC4+AgwgCCAvPgIQIAggMD4CFCAIIDE+AhggCCAyPgIcIAggMz4CICAIIDQ+AiQgCSA/PgIAIAkgQD4CBCAJIEE+AgggCSBCPgIMIAkgQz4CECAJIEQ+AhQgCSBFPgIYIAkgRj4CHCAJIEc+AiAgCSBIPgIkIAoL') var ready = null var mod = { diff --git a/fe25519_25/scalarmult_curve25519.wat b/fe25519_25/scalarmult_curve25519.wat index 2799750..ee17683 100644 --- a/fe25519_25/scalarmult_curve25519.wat +++ b/fe25519_25/scalarmult_curve25519.wat @@ -1,5 +1,5 @@ (module - (import "js" "table" (table 1 anyfunc)) + (import "js" "table" (table 3 anyfunc)) (type $fe_mul (func (param $f_0 i64) (param $f_1 i64) @@ -38,6 +38,34 @@ (param $repeat i32) (param $res i32))) + (func $i32.log (import "debug" "log") (param i32)) + (func $i32.log_tee (import "debug" "log_tee") (param i32) (result i32)) + ;; No i64 interop with JS yet - but maybe coming with WebAssembly BigInt + ;; So we can instead fake this by splitting the i64 into two i32 limbs, + ;; however these are WASM functions using i32x2.log: + (func $i32x2.log (import "debug" "log") (param i32) (param i32)) + (func $f32.log (import "debug" "log") (param f32)) + (func $f32.log_tee (import "debug" "log_tee") (param f32) (result f32)) + (func $f64.log (import "debug" "log") (param f64)) + (func $f64.log_tee (import "debug" "log_tee") (param f64) (result f64)) + + ;; i64 logging by splitting into two i32 limbs + (func $i64.log + (param $0 i64) + (call $i32x2.log + ;; Upper limb + (i32.wrap/i64 + (i64.shr_s (get_local $0) + (i64.const 32))) + ;; Lower limb + (i32.wrap/i64 (get_local $0)))) + + (func $i64.log_tee + (param $0 i64) + (result i64) + (call $i64.log (get_local $0)) + (return (get_local $0))) + (memory $0 1) (export "memory" (memory $0)) @@ -214,1178 +242,1181 @@ (i32.const 254) (set_local $pos) - (loop $start - (i32.const 0) - (get_local $pos) - (i32.lt_s) - (br_if $start) - - ;; choose which limb of t - (block $break - (block $0 - (block $1 - (block $2 - (block $3 - (block $switch - (get_local $pos) - (i32.const 64) - (i32.div_u) - (br_table $3 $2 $1 $0)) - - (get_local $t_3) - (set_local $t) - (br $break)) - - (get_local $t_3) - (set_local $t) - (br $break)) - - (get_local $t_3) - (set_local $t) - (br $break)) - - (get_local $t_3) - (set_local $t) - (br $break))) - ;; end of switch statement - - (get_local $t) - (get_local $pos) - (i32.const 8) - (i32.div_u) - (i32.const 64) - (i32.rem_u) - (i64.extend_u/i32) - (i64.shr_u) - (i64.const 0xff) - (i64.and) - (get_local $pos) - (i32.const 7) - (i32.and) - (i64.extend_u/i32) - (i64.shr_u) - (i64.const 1) - (i64.and) - (i32.wrap/i64) - (set_local $b) - - (get_local $swap) - (get_local $b) - (i32.xor) - (set_local $swap) - - (i32.const 0) - (get_local $swap) - (i32.sub) - (i64.extend_u/i32) - (set_local $mask) - - (get_local $x2_0) - (get_local $x3_0) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_0) - - (get_local $x2_1) - (get_local $x3_1) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_1) - - (get_local $x2_2) - (get_local $x3_2) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_2) - - (get_local $x2_3) - (get_local $x3_3) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_3) - - (get_local $x2_4) - (get_local $x3_4) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_4) - - (get_local $x2_5) - (get_local $x3_5) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_5) - - (get_local $x2_6) - (get_local $x3_6) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_6) - - (get_local $x2_7) - (get_local $x3_7) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_7) - - (get_local $x2_8) - (get_local $x3_8) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_8) - - (get_local $x2_9) - (get_local $x3_9) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_9) - - - (get_local $x2_0) - (get_local $tmp0_0) - (i64.xor) - (set_local $x2_0) - - (get_local $x2_0) - (get_local $tmp0_0) - (i64.xor) - (set_local $x2_0) - - (get_local $x2_1) - (get_local $tmp0_1) - (i64.xor) - (set_local $x2_1) - - (get_local $x2_2) - (get_local $tmp0_2) - (i64.xor) - (set_local $x2_2) - - (get_local $x2_3) - (get_local $tmp0_3) - (i64.xor) - (set_local $x2_3) - - (get_local $x2_4) - (get_local $tmp0_4) - (i64.xor) - (set_local $x2_4) - - (get_local $x2_5) - (get_local $tmp0_5) - (i64.xor) - (set_local $x2_5) - - (get_local $x2_6) - (get_local $tmp0_6) - (i64.xor) - (set_local $x2_6) - - (get_local $x2_7) - (get_local $tmp0_7) - (i64.xor) - (set_local $x2_7) - - (get_local $x2_8) - (get_local $tmp0_8) - (i64.xor) - (set_local $x2_8) - - (get_local $x2_9) - (get_local $tmp0_9) - (i64.xor) - (set_local $x2_9) - - - (get_local $x3_0) - (get_local $tmp0_0) - (i64.xor) - (set_local $x3_0) - - (get_local $x3_0) - (get_local $tmp0_0) - (i64.xor) - (set_local $x3_0) - - (get_local $x3_1) - (get_local $tmp0_1) - (i64.xor) - (set_local $x3_1) - - (get_local $x3_2) - (get_local $tmp0_2) - (i64.xor) - (set_local $x3_2) - - (get_local $x3_3) - (get_local $tmp0_3) - (i64.xor) - (set_local $x3_3) - - (get_local $x3_4) - (get_local $tmp0_4) - (i64.xor) - (set_local $x3_4) - - (get_local $x3_5) - (get_local $tmp0_5) - (i64.xor) - (set_local $x3_5) - - (get_local $x3_6) - (get_local $tmp0_6) - (i64.xor) - (set_local $x3_6) - - (get_local $x3_7) - (get_local $tmp0_7) - (i64.xor) - (set_local $x3_7) - - (get_local $x3_8) - (get_local $tmp0_8) - (i64.xor) - (set_local $x3_8) - - (get_local $x3_9) - (get_local $tmp0_9) - (i64.xor) - (set_local $x3_9) - - - (get_local $z3_0) - (get_local $z2_0) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_0) - - (get_local $z3_1) - (get_local $z2_1) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_1) - - (get_local $z3_2) - (get_local $z2_2) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_2) - - (get_local $z3_3) - (get_local $z2_3) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_3) - - (get_local $z3_4) - (get_local $z2_4) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_4) - - (get_local $z3_5) - (get_local $z2_5) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_5) - - (get_local $z3_6) - (get_local $z2_6) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_6) - - (get_local $z3_7) - (get_local $z2_7) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_7) - - (get_local $z3_8) - (get_local $z2_8) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_8) - - (get_local $z3_9) - (get_local $z2_9) - (i64.xor) - (get_local $mask) - (i64.and) - (set_local $tmp0_9) - - - (get_local $z2_0) - (get_local $tmp0_0) - (i64.xor) - (set_local $z2_0) - - (get_local $z2_0) - (get_local $tmp0_0) - (i64.xor) - (set_local $z2_0) - - (get_local $z2_1) - (get_local $tmp0_1) - (i64.xor) - (set_local $z2_1) - - (get_local $z2_2) - (get_local $tmp0_2) - (i64.xor) - (set_local $z2_2) - - (get_local $z2_3) - (get_local $tmp0_3) - (i64.xor) - (set_local $z2_3) - - (get_local $z2_4) - (get_local $tmp0_4) - (i64.xor) - (set_local $z2_4) - - (get_local $z2_5) - (get_local $tmp0_5) - (i64.xor) - (set_local $z2_5) - - (get_local $z2_6) - (get_local $tmp0_6) - (i64.xor) - (set_local $z2_6) - - (get_local $z2_7) - (get_local $tmp0_7) - (i64.xor) - (set_local $z2_7) - - (get_local $z2_8) - (get_local $tmp0_8) - (i64.xor) - (set_local $z2_8) - - (get_local $z2_9) - (get_local $tmp0_9) - (i64.xor) - (set_local $z2_9) - - - (get_local $z3_0) - (get_local $tmp0_0) - (i64.xor) - (set_local $z3_0) - - (get_local $z3_0) - (get_local $tmp0_0) - (i64.xor) - (set_local $z3_0) - - (get_local $z3_1) - (get_local $tmp0_1) - (i64.xor) - (set_local $z3_1) - - (get_local $z3_2) - (get_local $tmp0_2) - (i64.xor) - (set_local $z3_2) - - (get_local $z3_3) - (get_local $tmp0_3) - (i64.xor) - (set_local $z3_3) - - (get_local $z3_4) - (get_local $tmp0_4) - (i64.xor) - (set_local $z3_4) - - (get_local $z3_5) - (get_local $tmp0_5) - (i64.xor) - (set_local $z3_5) - - (get_local $z3_6) - (get_local $tmp0_6) - (i64.xor) - (set_local $z3_6) - - (get_local $z3_7) - (get_local $tmp0_7) - (i64.xor) - (set_local $z3_7) - - (get_local $z3_8) - (get_local $tmp0_8) - (i64.xor) - (set_local $z3_8) - - (get_local $z3_9) - (get_local $tmp0_9) - (i64.xor) - (set_local $z3_9) - - (get_local $b) - (set_local $swap) - - ;; fe25519_sub(tmp0, x3, z3) - (get_local $x3_0) - (get_local $z3_0) - (i64.sub) - (set_local $tmp0_0) - - (get_local $x3_1) - (get_local $z3_1) - (i64.sub) - (set_local $tmp0_1) - - (get_local $x3_2) - (get_local $z3_2) - (i64.sub) - (set_local $tmp0_2) - - (get_local $x3_3) - (get_local $z3_3) - (i64.sub) - (set_local $tmp0_3) - - (get_local $x3_4) - (get_local $z3_4) - (i64.sub) - (set_local $tmp0_4) - - (get_local $x3_5) - (get_local $z3_5) - (i64.sub) - (set_local $tmp0_5) - - (get_local $x3_6) - (get_local $z3_6) - (i64.sub) - (set_local $tmp0_6) - - (get_local $x3_7) - (get_local $z3_7) - (i64.sub) - (set_local $tmp0_7) - - (get_local $x3_8) - (get_local $z3_8) - (i64.sub) - (set_local $tmp0_8) - - (get_local $x3_9) - (get_local $z3_9) - (i64.sub) - (set_local $tmp0_9) - - ;; fe25519_sub(tmp0, x3, z3) - (get_local $x2_0) - (get_local $z2_0) - (i64.sub) - (set_local $tmp1_0) - - (get_local $x2_1) - (get_local $z2_1) - (i64.sub) - (set_local $tmp1_1) - - (get_local $x2_2) - (get_local $z2_2) - (i64.sub) - (set_local $tmp1_2) - - (get_local $x2_3) - (get_local $z2_3) - (i64.sub) - (set_local $tmp1_3) - - (get_local $x2_4) - (get_local $z2_4) - (i64.sub) - (set_local $tmp1_4) - - (get_local $x2_5) - (get_local $z2_5) - (i64.sub) - (set_local $tmp1_5) - - (get_local $x2_6) - (get_local $z2_6) - (i64.sub) - (set_local $tmp1_6) - - (get_local $x2_7) - (get_local $z2_7) - (i64.sub) - (set_local $tmp1_7) - - (get_local $x2_8) - (get_local $z2_8) - (i64.sub) - (set_local $tmp1_8) - - (get_local $x2_9) - (get_local $z2_9) - (i64.sub) - (set_local $tmp1_9) - - ;; fe25519_add(x2, x2, z2) - (get_local $x2_0) - (get_local $z2_0) - (i64.add) - (set_local $x2_0) - - (get_local $x2_1) - (get_local $z2_1) - (i64.add) - (set_local $x2_1) - - (get_local $x2_2) - (get_local $z2_2) - (i64.add) - (set_local $x2_2) - - (get_local $x2_3) - (get_local $z2_3) - (i64.add) - (set_local $x2_3) - - (get_local $x2_4) - (get_local $z2_4) - (i64.add) - (set_local $x2_4) - - (get_local $x2_5) - (get_local $z2_5) - (i64.add) - (set_local $x2_5) - - (get_local $x2_6) - (get_local $z2_6) - (i64.add) - (set_local $x2_6) - - (get_local $x2_7) - (get_local $z2_7) - (i64.add) - (set_local $x2_7) - - (get_local $x2_8) - (get_local $z2_8) - (i64.add) - (set_local $x2_8) - - (get_local $x2_9) - (get_local $z2_9) - (i64.add) - (set_local $x2_9) - - ;; fe25519_add(z2, x3, z3) - (get_local $x3_0) - (get_local $z3_0) - (i64.add) - (set_local $z2_0) - - (get_local $x3_1) - (get_local $z3_1) - (i64.add) - (set_local $z2_1) - - (get_local $x3_2) - (get_local $z3_2) - (i64.add) - (set_local $z2_2) - - (get_local $x3_3) - (get_local $z3_3) - (i64.add) - (set_local $z2_3) - - (get_local $x3_4) - (get_local $z3_4) - (i64.add) - (set_local $z2_4) - - (get_local $x3_5) - (get_local $z3_5) - (i64.add) - (set_local $z2_5) - - (get_local $x3_6) - (get_local $z3_6) - (i64.add) - (set_local $z2_6) - - (get_local $x3_7) - (get_local $z3_7) - (i64.add) - (set_local $z2_7) - - (get_local $x3_8) - (get_local $z3_8) - (i64.add) - (set_local $z2_8) - - (get_local $x3_9) - (get_local $z3_9) - (i64.add) - (set_local $z2_9) - - ;; ptr0 <- z3 = x2 * tmp0 - (get_local $x2_0) - (get_local $x2_1) - (get_local $x2_2) - (get_local $x2_3) - (get_local $x2_4) - (get_local $x2_5) - (get_local $x2_6) - (get_local $x2_7) - (get_local $x2_8) - (get_local $x2_9) - (get_local $tmp0_0) - (get_local $tmp0_1) - (get_local $tmp0_2) - (get_local $tmp0_3) - (get_local $tmp0_4) - (get_local $tmp0_5) - (get_local $tmp0_6) - (get_local $tmp0_7) - (get_local $tmp0_8) - (get_local $tmp0_9) - (get_local $ptr0) - (i32.const 1) - (call_indirect (type $fe_mul)) - - ;; ptr1 <- z2 = z2 * tmp1 - (get_local $tmp1_0) - (get_local $tmp1_1) - (get_local $tmp1_2) - (get_local $tmp1_3) - (get_local $tmp1_4) - (get_local $tmp1_5) - (get_local $tmp1_6) - (get_local $tmp1_7) - (get_local $tmp1_8) - (get_local $tmp1_9) - (get_local $z2_0) - (get_local $z2_1) - (get_local $z2_2) - (get_local $z2_3) - (get_local $z2_4) - (get_local $z2_5) - (get_local $z2_6) - (get_local $z2_7) - (get_local $z2_8) - (get_local $z2_9) - (get_local $ptr1) - (i32.const 1) - (call_indirect (type $fe_mul)) - - ;; ptr2 <- tmp0 = tmp1 ^ 2 - (get_local $tmp1_0) - (get_local $tmp1_1) - (get_local $tmp1_2) - (get_local $tmp1_3) - (get_local $tmp1_4) - (get_local $tmp1_5) - (get_local $tmp1_6) - (get_local $tmp1_7) - (get_local $tmp1_8) - (get_local $tmp1_9) - (get_local $ptr2) - (i32.const 0) - (i32.const 0) - (i32.const 2) - (call_indirect (type $fe_sq)) - - ;; ptr3 <- tmp1 = x2 ^ 2 - (get_local $x2_0) - (get_local $x2_1) - (get_local $x2_2) - (get_local $x2_3) - (get_local $x2_4) - (get_local $x2_5) - (get_local $x2_6) - (get_local $x2_7) - (get_local $x2_8) - (get_local $x2_9) - (get_local $ptr3) - (i32.const 0) - (i32.const 0) - (i32.const 2) - (call_indirect (type $fe_sq)) - - ;; z3 <- load(ptr0) - (set_local $z3_0 (i64.load32_u offset=0 (get_local $ptr0))) - (set_local $z3_1 (i64.load32_u offset=4 (get_local $ptr0))) - (set_local $z3_2 (i64.load32_u offset=8 (get_local $ptr0))) - (set_local $z3_3 (i64.load32_u offset=12 (get_local $ptr0))) - (set_local $z3_4 (i64.load32_u offset=16 (get_local $ptr0))) - (set_local $z3_5 (i64.load32_u offset=20 (get_local $ptr0))) - (set_local $z3_6 (i64.load32_u offset=24 (get_local $ptr0))) - (set_local $z3_7 (i64.load32_u offset=28 (get_local $ptr0))) - (set_local $z3_8 (i64.load32_u offset=32 (get_local $ptr0))) - (set_local $z3_9 (i64.load32_u offset=36 (get_local $ptr0))) - - ;; z2 <- load(ptr1) - (set_local $z2_0 (i64.load32_u offset=0 (get_local $ptr1))) - (set_local $z2_1 (i64.load32_u offset=4 (get_local $ptr1))) - (set_local $z2_2 (i64.load32_u offset=8 (get_local $ptr1))) - (set_local $z2_3 (i64.load32_u offset=12 (get_local $ptr1))) - (set_local $z2_4 (i64.load32_u offset=16 (get_local $ptr1))) - (set_local $z2_5 (i64.load32_u offset=20 (get_local $ptr1))) - (set_local $z2_6 (i64.load32_u offset=24 (get_local $ptr1))) - (set_local $z2_7 (i64.load32_u offset=28 (get_local $ptr1))) - (set_local $z2_8 (i64.load32_u offset=32 (get_local $ptr1))) - (set_local $z2_9 (i64.load32_u offset=36 (get_local $ptr1))) - - ;; tmp0 <- load(ptr2) - (set_local $tmp0_0 (i64.load32_u offset=0 (get_local $ptr2))) - (set_local $tmp0_1 (i64.load32_u offset=4 (get_local $ptr2))) - (set_local $tmp0_2 (i64.load32_u offset=8 (get_local $ptr2))) - (set_local $tmp0_3 (i64.load32_u offset=12 (get_local $ptr2))) - (set_local $tmp0_4 (i64.load32_u offset=16 (get_local $ptr2))) - (set_local $tmp0_5 (i64.load32_u offset=20 (get_local $ptr2))) - (set_local $tmp0_6 (i64.load32_u offset=24 (get_local $ptr2))) - (set_local $tmp0_7 (i64.load32_u offset=28 (get_local $ptr2))) - (set_local $tmp0_8 (i64.load32_u offset=32 (get_local $ptr2))) - (set_local $tmp0_9 (i64.load32_u offset=36 (get_local $ptr2))) - - ;; tmp1 <- load(ptr3) - (set_local $tmp1_0 (i64.load32_u offset=0 (get_local $ptr3))) - (set_local $tmp1_1 (i64.load32_u offset=4 (get_local $ptr3))) - (set_local $tmp1_2 (i64.load32_u offset=8 (get_local $ptr3))) - (set_local $tmp1_3 (i64.load32_u offset=12 (get_local $ptr3))) - (set_local $tmp1_4 (i64.load32_u offset=16 (get_local $ptr3))) - (set_local $tmp1_5 (i64.load32_u offset=20 (get_local $ptr3))) - (set_local $tmp1_6 (i64.load32_u offset=24 (get_local $ptr3))) - (set_local $tmp1_7 (i64.load32_u offset=28 (get_local $ptr3))) - (set_local $tmp1_8 (i64.load32_u offset=32 (get_local $ptr3))) - (set_local $tmp1_9 (i64.load32_u offset=36 (get_local $ptr3))) - - ;; fe25519_add(x3, z3, z2) - (get_local $z3_0) - (get_local $z2_0) - (i64.add) - (set_local $x3_0) - - (get_local $z3_1) - (get_local $z2_1) - (i64.add) - (set_local $x3_1) - - (get_local $z3_2) - (get_local $z2_2) - (i64.add) - (set_local $x3_2) - - (get_local $z3_3) - (get_local $z2_3) - (i64.add) - (set_local $x3_3) - - (get_local $z3_4) - (get_local $z2_4) - (i64.add) - (set_local $x3_4) - - (get_local $z3_5) - (get_local $z2_5) - (i64.add) - (set_local $x3_5) - - (get_local $z3_6) - (get_local $z2_6) - (i64.add) - (set_local $x3_6) - - (get_local $z3_7) - (get_local $z2_7) - (i64.add) - (set_local $x3_7) - - (get_local $z3_8) - (get_local $z2_8) - (i64.add) - (set_local $x3_8) - - (get_local $z3_9) - (get_local $z2_9) - (i64.add) - (set_local $x3_9) - - ;; fe25519_sub(z2, z3, z2) - (get_local $z3_0) - (get_local $z2_0) - (i64.sub) - (set_local $z2_0) - - (get_local $z3_1) - (get_local $z2_1) - (i64.sub) - (set_local $z2_1) - - (get_local $z3_2) - (get_local $z2_2) - (i64.sub) - (set_local $z2_2) - - (get_local $z3_3) - (get_local $z2_3) - (i64.sub) - (set_local $z2_3) - - (get_local $z3_4) - (get_local $z2_4) - (i64.sub) - (set_local $z2_4) - - (get_local $z3_5) - (get_local $z2_5) - (i64.sub) - (set_local $z2_5) - - (get_local $z3_6) - (get_local $z2_6) - (i64.sub) - (set_local $z2_6) - - (get_local $z3_7) - (get_local $z2_7) - (i64.sub) - (set_local $z2_7) - - (get_local $z3_8) - (get_local $z2_8) - (i64.sub) - (set_local $z2_8) - - (get_local $z3_9) - (get_local $z2_9) - (i64.sub) - (set_local $z2_9) - - ;; ptr1 <- x2 = tmp0 * tmp1 - (get_local $tmp1_0) - (get_local $tmp1_1) - (get_local $tmp1_2) - (get_local $tmp1_3) - (get_local $tmp1_4) - (get_local $tmp1_5) - (get_local $tmp1_6) - (get_local $tmp1_7) - (get_local $tmp1_8) - (get_local $tmp1_9) - (get_local $tmp0_0) - (get_local $tmp0_1) - (get_local $tmp0_2) - (get_local $tmp0_3) - (get_local $tmp0_4) - (get_local $tmp0_5) - (get_local $tmp0_6) - (get_local $tmp0_7) - (get_local $tmp0_8) - (get_local $tmp0_9) - (get_local $ptr1) - (i32.const 3) - (call_indirect (type $fe_mul)) - - ;; tmp1 = tmp1 - tmp0 - (get_local $tmp1_0) - (get_local $tmp0_0) - (i64.sub) - (set_local $tmp1_0) - - (get_local $tmp1_1) - (get_local $tmp0_1) - (i64.sub) - (set_local $tmp1_1) - - (get_local $tmp1_2) - (get_local $tmp0_2) - (i64.sub) - (set_local $tmp1_2) - - (get_local $tmp1_3) - (get_local $tmp0_3) - (i64.sub) - (set_local $tmp1_3) - - (get_local $tmp1_4) - (get_local $tmp0_4) - (i64.sub) - (set_local $tmp1_4) - - (get_local $tmp1_5) - (get_local $tmp0_5) - (i64.sub) - (set_local $tmp1_5) - - (get_local $tmp1_6) - (get_local $tmp0_6) - (i64.sub) - (set_local $tmp1_6) - - (get_local $tmp1_7) - (get_local $tmp0_7) - (i64.sub) - (set_local $tmp1_7) - - (get_local $tmp1_8) - (get_local $tmp0_8) - (i64.sub) - (set_local $tmp1_8) - - (get_local $tmp1_9) - (get_local $tmp0_9) - (i64.sub) - (set_local $tmp1_9) - - ;; ptr0 <- z2 = z2 ^ 2 - (get_local $z2_0) - (get_local $z2_1) - (get_local $z2_2) - (get_local $z2_3) - (get_local $z2_4) - (get_local $z2_5) - (get_local $z2_6) - (get_local $z2_7) - (get_local $z2_8) - (get_local $z2_9) - (get_local $ptr0) - (i32.const 0) - (i32.const 0) - (i32.const 2) - (call_indirect (type $fe_sq)) - - ;; ptr1 <- z3 = tmp1 * _121666 - (i64.const 121666) - (i64.const 0) - (i64.const 0) - (i64.const 0) - (i64.const 0) - (i64.const 0) - (i64.const 0) - (i64.const 0) - (i64.const 0) - (i64.const 0) - (get_local $tmp1_0) - (get_local $tmp1_1) - (get_local $tmp1_2) - (get_local $tmp1_3) - (get_local $tmp1_4) - (get_local $tmp1_5) - (get_local $tmp1_6) - (get_local $tmp1_7) - (get_local $tmp1_8) - (get_local $tmp1_9) - (get_local $ptr1) - (i32.const 1) - (call_indirect (type $fe_mul)) - - ;; ptr2 <- x3 = x3 ^ 2 - (get_local $x3_0) - (get_local $x3_1) - (get_local $x3_2) - (get_local $x3_3) - (get_local $x3_4) - (get_local $x3_5) - (get_local $x3_6) - (get_local $x3_7) - (get_local $x3_8) - (get_local $x3_9) - (get_local $ptr2) - (i32.const 0) - (i32.const 0) - (i32.const 2) - (call_indirect (type $fe_sq)) - - ;; tmp0 <- load(ptr2) - (set_local $z2_0 (i64.load32_u offset=0 (get_local $ptr0))) - (set_local $z2_1 (i64.load32_u offset=4 (get_local $ptr0))) - (set_local $z2_2 (i64.load32_u offset=8 (get_local $ptr0))) - (set_local $z2_3 (i64.load32_u offset=12 (get_local $ptr0))) - (set_local $z2_4 (i64.load32_u offset=16 (get_local $ptr0))) - (set_local $z2_5 (i64.load32_u offset=20 (get_local $ptr0))) - (set_local $z2_6 (i64.load32_u offset=24 (get_local $ptr0))) - (set_local $z2_7 (i64.load32_u offset=28 (get_local $ptr0))) - (set_local $z2_8 (i64.load32_u offset=32 (get_local $ptr0))) - (set_local $z2_9 (i64.load32_u offset=36 (get_local $ptr0))) - - ;; tmp0 <- load(ptr2) - (set_local $z3_0 (i64.load32_u offset=0 (get_local $ptr1))) - (set_local $z3_1 (i64.load32_u offset=4 (get_local $ptr1))) - (set_local $z3_2 (i64.load32_u offset=8 (get_local $ptr1))) - (set_local $z3_3 (i64.load32_u offset=12 (get_local $ptr1))) - (set_local $z3_4 (i64.load32_u offset=16 (get_local $ptr1))) - (set_local $z3_5 (i64.load32_u offset=20 (get_local $ptr1))) - (set_local $z3_6 (i64.load32_u offset=24 (get_local $ptr1))) - (set_local $z3_7 (i64.load32_u offset=28 (get_local $ptr1))) - (set_local $z3_8 (i64.load32_u offset=32 (get_local $ptr1))) - (set_local $z3_9 (i64.load32_u offset=36 (get_local $ptr1))) - - ;; tmp0 <- load(ptr2) - (set_local $x3_0 (i64.load32_u offset=0 (get_local $ptr2))) - (set_local $x3_1 (i64.load32_u offset=4 (get_local $ptr2))) - (set_local $x3_2 (i64.load32_u offset=8 (get_local $ptr2))) - (set_local $x3_3 (i64.load32_u offset=12 (get_local $ptr2))) - (set_local $x3_4 (i64.load32_u offset=16 (get_local $ptr2))) - (set_local $x3_5 (i64.load32_u offset=20 (get_local $ptr2))) - (set_local $x3_6 (i64.load32_u offset=24 (get_local $ptr2))) - (set_local $x3_7 (i64.load32_u offset=28 (get_local $ptr2))) - (set_local $x3_8 (i64.load32_u offset=32 (get_local $ptr2))) - (set_local $x3_9 (i64.load32_u offset=36 (get_local $ptr2))) - - (get_local $tmp0_0) - (get_local $z3_0) - (i64.add) - (set_local $tmp0_0) - - (get_local $tmp0_1) - (get_local $z3_1) - (i64.add) - (set_local $tmp0_1) - - (get_local $tmp0_2) - (get_local $z3_2) - (i64.add) - (set_local $tmp0_2) - - (get_local $tmp0_3) - (get_local $z3_3) - (i64.add) - (set_local $tmp0_3) - - (get_local $tmp0_4) - (get_local $z3_4) - (i64.add) - (set_local $tmp0_4) - - (get_local $tmp0_5) - (get_local $z3_5) - (i64.add) - (set_local $tmp0_5) - - (get_local $tmp0_6) - (get_local $z3_6) - (i64.add) - (set_local $tmp0_6) - - (get_local $tmp0_7) - (get_local $z3_7) - (i64.add) - (set_local $tmp0_7) - - (get_local $tmp0_8) - (get_local $z3_8) - (i64.add) - (set_local $tmp0_8) - - (get_local $tmp0_9) - (get_local $z3_9) - (i64.add) - (set_local $tmp0_9) - - ;; ptr1 <- z3 = x1 * z2 - (get_local $x1_0) - (get_local $x1_1) - (get_local $x1_2) - (get_local $x1_3) - (get_local $x1_4) - (get_local $x1_5) - (get_local $x1_6) - (get_local $x1_7) - (get_local $x1_8) - (get_local $x1_9) - (get_local $z2_0) - (get_local $z2_1) - (get_local $z2_2) - (get_local $z2_3) - (get_local $z2_4) - (get_local $z2_5) - (get_local $z2_6) - (get_local $z2_7) - (get_local $z2_8) - (get_local $z2_9) - (get_local $ptr1) - (i32.const 1) - (call_indirect (type $fe_mul)) - - ;; ptr0 <- z2 = tmp1 * tmp0 - (get_local $tmp0_0) - (get_local $tmp0_1) - (get_local $tmp0_2) - (get_local $tmp0_3) - (get_local $tmp0_4) - (get_local $tmp0_5) - (get_local $tmp0_6) - (get_local $tmp0_7) - (get_local $tmp0_8) - (get_local $tmp0_9) - (get_local $tmp1_0) - (get_local $tmp1_1) - (get_local $tmp1_2) - (get_local $tmp1_3) - (get_local $tmp1_4) - (get_local $tmp1_5) - (get_local $tmp1_6) - (get_local $tmp1_7) - (get_local $tmp1_8) - (get_local $tmp1_9) - (get_local $ptr0) - (i32.const 1) - (call_indirect (type $fe_mul)) - - ;; tmp0 <- load(ptr2) - (set_local $z2_0 (i64.load32_u offset=0 (get_local $ptr0))) - (set_local $z2_1 (i64.load32_u offset=4 (get_local $ptr0))) - (set_local $z2_2 (i64.load32_u offset=8 (get_local $ptr0))) - (set_local $z2_3 (i64.load32_u offset=12 (get_local $ptr0))) - (set_local $z2_4 (i64.load32_u offset=16 (get_local $ptr0))) - (set_local $z2_5 (i64.load32_u offset=20 (get_local $ptr0))) - (set_local $z2_6 (i64.load32_u offset=24 (get_local $ptr0))) - (set_local $z2_7 (i64.load32_u offset=28 (get_local $ptr0))) - (set_local $z2_8 (i64.load32_u offset=32 (get_local $ptr0))) - (set_local $z2_9 (i64.load32_u offset=36 (get_local $ptr0))) - - ;; tmp0 <- load(ptr2) - (set_local $z3_0 (i64.load32_u offset=0 (get_local $ptr1))) - (set_local $z3_1 (i64.load32_u offset=4 (get_local $ptr1))) - (set_local $z3_2 (i64.load32_u offset=8 (get_local $ptr1))) - (set_local $z3_3 (i64.load32_u offset=12 (get_local $ptr1))) - (set_local $z3_4 (i64.load32_u offset=16 (get_local $ptr1))) - (set_local $z3_5 (i64.load32_u offset=20 (get_local $ptr1))) - (set_local $z3_6 (i64.load32_u offset=24 (get_local $ptr1))) - (set_local $z3_7 (i64.load32_u offset=28 (get_local $ptr1))) - (set_local $z3_8 (i64.load32_u offset=32 (get_local $ptr1))) - (set_local $z3_9 (i64.load32_u offset=36 (get_local $ptr1))) - - (get_local $pos) - (i32.const 1) - (i32.sub) - (set_local $pos) - (br $start)) + (block $end + (loop $start + (get_local $pos) + (i32.const 0) + (i32.lt_s) + (br_if $end) + + ;; choose which limb of t + (block $break + (block $0 + (block $1 + (block $2 + (block $3 + (block $switch + (get_local $pos) + (i32.const 64) + (i32.div_u) + (br_table $3 $2 $1 $0)) + + (get_local $t_3) + (set_local $t) + (br $break)) + + (get_local $t_3) + (set_local $t) + (br $break)) + + (get_local $t_3) + (set_local $t) + (br $break)) + + (get_local $t_3) + (set_local $t) + (br $break))) + ;; end of switch statement + + (get_local $t) + (get_local $pos) + (i32.const 8) + (i32.div_u) + (i32.const 64) + (i32.rem_u) + (i64.extend_u/i32) + (i64.shr_u) + (i64.const 0xff) + (i64.and) + (get_local $pos) + (i32.const 7) + (i32.and) + (i64.extend_u/i32) + (i64.shr_u) + (i64.const 1) + (i64.and) + (i32.wrap/i64) + (set_local $b) + + (get_local $swap) + (get_local $b) + (i32.xor) + (set_local $swap) + + (i32.const 0) + (get_local $swap) + (i32.sub) + (i64.extend_u/i32) + (set_local $mask) + + (get_local $x2_0) + (get_local $x3_0) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_0) + + (get_local $x2_1) + (get_local $x3_1) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_1) + + (get_local $x2_2) + (get_local $x3_2) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_2) + + (get_local $x2_3) + (get_local $x3_3) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_3) + + (get_local $x2_4) + (get_local $x3_4) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_4) + + (get_local $x2_5) + (get_local $x3_5) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_5) + + (get_local $x2_6) + (get_local $x3_6) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_6) + + (get_local $x2_7) + (get_local $x3_7) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_7) + + (get_local $x2_8) + (get_local $x3_8) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_8) + + (get_local $x2_9) + (get_local $x3_9) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_9) + + + (get_local $x2_0) + (get_local $tmp0_0) + (i64.xor) + (set_local $x2_0) + + (get_local $x2_0) + (get_local $tmp0_0) + (i64.xor) + (set_local $x2_0) + + (get_local $x2_1) + (get_local $tmp0_1) + (i64.xor) + (set_local $x2_1) + + (get_local $x2_2) + (get_local $tmp0_2) + (i64.xor) + (set_local $x2_2) + + (get_local $x2_3) + (get_local $tmp0_3) + (i64.xor) + (set_local $x2_3) + + (get_local $x2_4) + (get_local $tmp0_4) + (i64.xor) + (set_local $x2_4) + + (get_local $x2_5) + (get_local $tmp0_5) + (i64.xor) + (set_local $x2_5) + + (get_local $x2_6) + (get_local $tmp0_6) + (i64.xor) + (set_local $x2_6) + + (get_local $x2_7) + (get_local $tmp0_7) + (i64.xor) + (set_local $x2_7) + + (get_local $x2_8) + (get_local $tmp0_8) + (i64.xor) + (set_local $x2_8) + + (get_local $x2_9) + (get_local $tmp0_9) + (i64.xor) + (set_local $x2_9) + + + (get_local $x3_0) + (get_local $tmp0_0) + (i64.xor) + (set_local $x3_0) + + (get_local $x3_0) + (get_local $tmp0_0) + (i64.xor) + (set_local $x3_0) + + (get_local $x3_1) + (get_local $tmp0_1) + (i64.xor) + (set_local $x3_1) + + (get_local $x3_2) + (get_local $tmp0_2) + (i64.xor) + (set_local $x3_2) + + (get_local $x3_3) + (get_local $tmp0_3) + (i64.xor) + (set_local $x3_3) + + (get_local $x3_4) + (get_local $tmp0_4) + (i64.xor) + (set_local $x3_4) + + (get_local $x3_5) + (get_local $tmp0_5) + (i64.xor) + (set_local $x3_5) + + (get_local $x3_6) + (get_local $tmp0_6) + (i64.xor) + (set_local $x3_6) + + (get_local $x3_7) + (get_local $tmp0_7) + (i64.xor) + (set_local $x3_7) + + (get_local $x3_8) + (get_local $tmp0_8) + (i64.xor) + (set_local $x3_8) + + (get_local $x3_9) + (get_local $tmp0_9) + (i64.xor) + (set_local $x3_9) + + + (get_local $z3_0) + (get_local $z2_0) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_0) + + (get_local $z3_1) + (get_local $z2_1) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_1) + + (get_local $z3_2) + (get_local $z2_2) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_2) + + (get_local $z3_3) + (get_local $z2_3) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_3) + + (get_local $z3_4) + (get_local $z2_4) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_4) + + (get_local $z3_5) + (get_local $z2_5) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_5) + + (get_local $z3_6) + (get_local $z2_6) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_6) + + (get_local $z3_7) + (get_local $z2_7) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_7) + + (get_local $z3_8) + (get_local $z2_8) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_8) + + (get_local $z3_9) + (get_local $z2_9) + (i64.xor) + (get_local $mask) + (i64.and) + (set_local $tmp0_9) + + + (get_local $z2_0) + (get_local $tmp0_0) + (i64.xor) + (set_local $z2_0) + + (get_local $z2_0) + (get_local $tmp0_0) + (i64.xor) + (set_local $z2_0) + + (get_local $z2_1) + (get_local $tmp0_1) + (i64.xor) + (set_local $z2_1) + + (get_local $z2_2) + (get_local $tmp0_2) + (i64.xor) + (set_local $z2_2) + + (get_local $z2_3) + (get_local $tmp0_3) + (i64.xor) + (set_local $z2_3) + + (get_local $z2_4) + (get_local $tmp0_4) + (i64.xor) + (set_local $z2_4) + + (get_local $z2_5) + (get_local $tmp0_5) + (i64.xor) + (set_local $z2_5) + + (get_local $z2_6) + (get_local $tmp0_6) + (i64.xor) + (set_local $z2_6) + + (get_local $z2_7) + (get_local $tmp0_7) + (i64.xor) + (set_local $z2_7) + + (get_local $z2_8) + (get_local $tmp0_8) + (i64.xor) + (set_local $z2_8) + + (get_local $z2_9) + (get_local $tmp0_9) + (i64.xor) + (set_local $z2_9) + + + (get_local $z3_0) + (get_local $tmp0_0) + (i64.xor) + (set_local $z3_0) + + (get_local $z3_0) + (get_local $tmp0_0) + (i64.xor) + (set_local $z3_0) + + (get_local $z3_1) + (get_local $tmp0_1) + (i64.xor) + (set_local $z3_1) + + (get_local $z3_2) + (get_local $tmp0_2) + (i64.xor) + (set_local $z3_2) + + (get_local $z3_3) + (get_local $tmp0_3) + (i64.xor) + (set_local $z3_3) + + (get_local $z3_4) + (get_local $tmp0_4) + (i64.xor) + (set_local $z3_4) + + (get_local $z3_5) + (get_local $tmp0_5) + (i64.xor) + (set_local $z3_5) + + (get_local $z3_6) + (get_local $tmp0_6) + (i64.xor) + (set_local $z3_6) + + (get_local $z3_7) + (get_local $tmp0_7) + (i64.xor) + (set_local $z3_7) + + (get_local $z3_8) + (get_local $tmp0_8) + (i64.xor) + (set_local $z3_8) + + (get_local $z3_9) + (get_local $tmp0_9) + (i64.xor) + (set_local $z3_9) + + (get_local $b) + (set_local $swap) + + ;; fe25519_sub(tmp0, x3, z3) + (get_local $x3_0) + (get_local $z3_0) + (i64.sub) + (set_local $tmp0_0) + + (get_local $x3_1) + (get_local $z3_1) + (i64.sub) + (set_local $tmp0_1) + + (get_local $x3_2) + (get_local $z3_2) + (i64.sub) + (set_local $tmp0_2) + + (get_local $x3_3) + (get_local $z3_3) + (i64.sub) + (set_local $tmp0_3) + + (get_local $x3_4) + (get_local $z3_4) + (i64.sub) + (set_local $tmp0_4) + + (get_local $x3_5) + (get_local $z3_5) + (i64.sub) + (set_local $tmp0_5) + + (get_local $x3_6) + (get_local $z3_6) + (i64.sub) + (set_local $tmp0_6) + + (get_local $x3_7) + (get_local $z3_7) + (i64.sub) + (set_local $tmp0_7) + + (get_local $x3_8) + (get_local $z3_8) + (i64.sub) + (set_local $tmp0_8) + + (get_local $x3_9) + (get_local $z3_9) + (i64.sub) + (set_local $tmp0_9) + + ;; fe25519_sub(tmp0, x3, z3) + (get_local $x2_0) + (get_local $z2_0) + (i64.sub) + (set_local $tmp1_0) + + (get_local $x2_1) + (get_local $z2_1) + (i64.sub) + (set_local $tmp1_1) + + (get_local $x2_2) + (get_local $z2_2) + (i64.sub) + (set_local $tmp1_2) + + (get_local $x2_3) + (get_local $z2_3) + (i64.sub) + (set_local $tmp1_3) + + (get_local $x2_4) + (get_local $z2_4) + (i64.sub) + (set_local $tmp1_4) + + (get_local $x2_5) + (get_local $z2_5) + (i64.sub) + (set_local $tmp1_5) + + (get_local $x2_6) + (get_local $z2_6) + (i64.sub) + (set_local $tmp1_6) + + (get_local $x2_7) + (get_local $z2_7) + (i64.sub) + (set_local $tmp1_7) + + (get_local $x2_8) + (get_local $z2_8) + (i64.sub) + (set_local $tmp1_8) + + (get_local $x2_9) + (get_local $z2_9) + (i64.sub) + (set_local $tmp1_9) + + ;; fe25519_add(x2, x2, z2) + (get_local $x2_0) + (get_local $z2_0) + (i64.add) + (set_local $x2_0) + + (get_local $x2_1) + (get_local $z2_1) + (i64.add) + (set_local $x2_1) + + (get_local $x2_2) + (get_local $z2_2) + (i64.add) + (set_local $x2_2) + + (get_local $x2_3) + (get_local $z2_3) + (i64.add) + (set_local $x2_3) + + (get_local $x2_4) + (get_local $z2_4) + (i64.add) + (set_local $x2_4) + + (get_local $x2_5) + (get_local $z2_5) + (i64.add) + (set_local $x2_5) + + (get_local $x2_6) + (get_local $z2_6) + (i64.add) + (set_local $x2_6) + + (get_local $x2_7) + (get_local $z2_7) + (i64.add) + (set_local $x2_7) + + (get_local $x2_8) + (get_local $z2_8) + (i64.add) + (set_local $x2_8) + + (get_local $x2_9) + (get_local $z2_9) + (i64.add) + (set_local $x2_9) + + ;; fe25519_add(z2, x3, z3) + (get_local $x3_0) + (get_local $z3_0) + (i64.add) + (set_local $z2_0) + + (get_local $x3_1) + (get_local $z3_1) + (i64.add) + (set_local $z2_1) + + (get_local $x3_2) + (get_local $z3_2) + (i64.add) + (set_local $z2_2) + + (get_local $x3_3) + (get_local $z3_3) + (i64.add) + (set_local $z2_3) + + (get_local $x3_4) + (get_local $z3_4) + (i64.add) + (set_local $z2_4) + + (get_local $x3_5) + (get_local $z3_5) + (i64.add) + (set_local $z2_5) + + (get_local $x3_6) + (get_local $z3_6) + (i64.add) + (set_local $z2_6) + + (get_local $x3_7) + (get_local $z3_7) + (i64.add) + (set_local $z2_7) + + (get_local $x3_8) + (get_local $z3_8) + (i64.add) + (set_local $z2_8) + + (get_local $x3_9) + (get_local $z3_9) + (i64.add) + (set_local $z2_9) + + ;; ptr0 <- z3 = x2 * tmp0 + (get_local $x2_0) + (get_local $x2_1) + (get_local $x2_2) + (get_local $x2_3) + (get_local $x2_4) + (get_local $x2_5) + (get_local $x2_6) + (get_local $x2_7) + (get_local $x2_8) + (get_local $x2_9) + (get_local $tmp0_0) + (get_local $tmp0_1) + (get_local $tmp0_2) + (get_local $tmp0_3) + (get_local $tmp0_4) + (get_local $tmp0_5) + (get_local $tmp0_6) + (get_local $tmp0_7) + (get_local $tmp0_8) + (get_local $tmp0_9) + (get_local $ptr0) + (i32.const 1) + (call_indirect (type $fe_mul)) + + ;; ptr1 <- z2 = z2 * tmp1 + (get_local $tmp1_0) + (get_local $tmp1_1) + (get_local $tmp1_2) + (get_local $tmp1_3) + (get_local $tmp1_4) + (get_local $tmp1_5) + (get_local $tmp1_6) + (get_local $tmp1_7) + (get_local $tmp1_8) + (get_local $tmp1_9) + (get_local $z2_0) + (get_local $z2_1) + (get_local $z2_2) + (get_local $z2_3) + (get_local $z2_4) + (get_local $z2_5) + (get_local $z2_6) + (get_local $z2_7) + (get_local $z2_8) + (get_local $z2_9) + (get_local $ptr1) + (i32.const 1) + (call_indirect (type $fe_mul)) + + ;; ptr2 <- tmp0 = tmp1 ^ 2 + (get_local $tmp1_0) + (get_local $tmp1_1) + (get_local $tmp1_2) + (get_local $tmp1_3) + (get_local $tmp1_4) + (get_local $tmp1_5) + (get_local $tmp1_6) + (get_local $tmp1_7) + (get_local $tmp1_8) + (get_local $tmp1_9) + (get_local $ptr2) + (i32.const 0) + (i32.const 0) + (i32.const 2) + (call_indirect (type $fe_sq)) + + ;; ptr3 <- tmp1 = x2 ^ 2 + (get_local $x2_0) + (get_local $x2_1) + (get_local $x2_2) + (get_local $x2_3) + (get_local $x2_4) + (get_local $x2_5) + (get_local $x2_6) + (get_local $x2_7) + (get_local $x2_8) + (get_local $x2_9) + (get_local $ptr3) + (i32.const 0) + (i32.const 0) + (i32.const 2) + (call_indirect (type $fe_sq)) + + ;; z3 <- load(ptr0) + (set_local $z3_0 (i64.load32_u offset=0 (get_local $ptr0))) + (set_local $z3_1 (i64.load32_u offset=4 (get_local $ptr0))) + (set_local $z3_2 (i64.load32_u offset=8 (get_local $ptr0))) + (set_local $z3_3 (i64.load32_u offset=12 (get_local $ptr0))) + (set_local $z3_4 (i64.load32_u offset=16 (get_local $ptr0))) + (set_local $z3_5 (i64.load32_u offset=20 (get_local $ptr0))) + (set_local $z3_6 (i64.load32_u offset=24 (get_local $ptr0))) + (set_local $z3_7 (i64.load32_u offset=28 (get_local $ptr0))) + (set_local $z3_8 (i64.load32_u offset=32 (get_local $ptr0))) + (set_local $z3_9 (i64.load32_u offset=36 (get_local $ptr0))) + + ;; z2 <- load(ptr1) + (set_local $z2_0 (i64.load32_u offset=0 (get_local $ptr1))) + (set_local $z2_1 (i64.load32_u offset=4 (get_local $ptr1))) + (set_local $z2_2 (i64.load32_u offset=8 (get_local $ptr1))) + (set_local $z2_3 (i64.load32_u offset=12 (get_local $ptr1))) + (set_local $z2_4 (i64.load32_u offset=16 (get_local $ptr1))) + (set_local $z2_5 (i64.load32_u offset=20 (get_local $ptr1))) + (set_local $z2_6 (i64.load32_u offset=24 (get_local $ptr1))) + (set_local $z2_7 (i64.load32_u offset=28 (get_local $ptr1))) + (set_local $z2_8 (i64.load32_u offset=32 (get_local $ptr1))) + (set_local $z2_9 (i64.load32_u offset=36 (get_local $ptr1))) + + ;; tmp0 <- load(ptr2) + (set_local $tmp0_0 (i64.load32_u offset=0 (get_local $ptr2))) + (set_local $tmp0_1 (i64.load32_u offset=4 (get_local $ptr2))) + (set_local $tmp0_2 (i64.load32_u offset=8 (get_local $ptr2))) + (set_local $tmp0_3 (i64.load32_u offset=12 (get_local $ptr2))) + (set_local $tmp0_4 (i64.load32_u offset=16 (get_local $ptr2))) + (set_local $tmp0_5 (i64.load32_u offset=20 (get_local $ptr2))) + (set_local $tmp0_6 (i64.load32_u offset=24 (get_local $ptr2))) + (set_local $tmp0_7 (i64.load32_u offset=28 (get_local $ptr2))) + (set_local $tmp0_8 (i64.load32_u offset=32 (get_local $ptr2))) + (set_local $tmp0_9 (i64.load32_u offset=36 (get_local $ptr2))) + + ;; tmp1 <- load(ptr3) + (set_local $tmp1_0 (i64.load32_u offset=0 (get_local $ptr3))) + (set_local $tmp1_1 (i64.load32_u offset=4 (get_local $ptr3))) + (set_local $tmp1_2 (i64.load32_u offset=8 (get_local $ptr3))) + (set_local $tmp1_3 (i64.load32_u offset=12 (get_local $ptr3))) + (set_local $tmp1_4 (i64.load32_u offset=16 (get_local $ptr3))) + (set_local $tmp1_5 (i64.load32_u offset=20 (get_local $ptr3))) + (set_local $tmp1_6 (i64.load32_u offset=24 (get_local $ptr3))) + (set_local $tmp1_7 (i64.load32_u offset=28 (get_local $ptr3))) + (set_local $tmp1_8 (i64.load32_u offset=32 (get_local $ptr3))) + (set_local $tmp1_9 (i64.load32_u offset=36 (get_local $ptr3))) + + ;; fe25519_add(x3, z3, z2) + (get_local $z3_0) + (get_local $z2_0) + (i64.add) + (set_local $x3_0) + + (get_local $z3_1) + (get_local $z2_1) + (i64.add) + (set_local $x3_1) + + (get_local $z3_2) + (get_local $z2_2) + (i64.add) + (set_local $x3_2) + + (get_local $z3_3) + (get_local $z2_3) + (i64.add) + (set_local $x3_3) + + (get_local $z3_4) + (get_local $z2_4) + (i64.add) + (set_local $x3_4) + + (get_local $z3_5) + (get_local $z2_5) + (i64.add) + (set_local $x3_5) + + (get_local $z3_6) + (get_local $z2_6) + (i64.add) + (set_local $x3_6) + + (get_local $z3_7) + (get_local $z2_7) + (i64.add) + (set_local $x3_7) + + (get_local $z3_8) + (get_local $z2_8) + (i64.add) + (set_local $x3_8) + + (get_local $z3_9) + (get_local $z2_9) + (i64.add) + (set_local $x3_9) + + ;; fe25519_sub(z2, z3, z2) + (get_local $z3_0) + (get_local $z2_0) + (i64.sub) + (set_local $z2_0) + + (get_local $z3_1) + (get_local $z2_1) + (i64.sub) + (set_local $z2_1) + + (get_local $z3_2) + (get_local $z2_2) + (i64.sub) + (set_local $z2_2) + + (get_local $z3_3) + (get_local $z2_3) + (i64.sub) + (set_local $z2_3) + + (get_local $z3_4) + (get_local $z2_4) + (i64.sub) + (set_local $z2_4) + + (get_local $z3_5) + (get_local $z2_5) + (i64.sub) + (set_local $z2_5) + + (get_local $z3_6) + (get_local $z2_6) + (i64.sub) + (set_local $z2_6) + + (get_local $z3_7) + (get_local $z2_7) + (i64.sub) + (set_local $z2_7) + + (get_local $z3_8) + (get_local $z2_8) + (i64.sub) + (set_local $z2_8) + + (get_local $z3_9) + (get_local $z2_9) + (i64.sub) + (set_local $z2_9) + + ;; ptr1 <- x2 = tmp0 * tmp1 + (get_local $tmp1_0) + (get_local $tmp1_1) + (get_local $tmp1_2) + (get_local $tmp1_3) + (get_local $tmp1_4) + (get_local $tmp1_5) + (get_local $tmp1_6) + (get_local $tmp1_7) + (get_local $tmp1_8) + (get_local $tmp1_9) + (get_local $tmp0_0) + (get_local $tmp0_1) + (get_local $tmp0_2) + (get_local $tmp0_3) + (get_local $tmp0_4) + (get_local $tmp0_5) + (get_local $tmp0_6) + (get_local $tmp0_7) + (get_local $tmp0_8) + (get_local $tmp0_9) + (get_local $ptr1) + (i32.const 1) + (call_indirect (type $fe_mul)) + + ;; tmp1 = tmp1 - tmp0 + (get_local $tmp1_0) + (get_local $tmp0_0) + (i64.sub) + (set_local $tmp1_0) + + (get_local $tmp1_1) + (get_local $tmp0_1) + (i64.sub) + (set_local $tmp1_1) + + (get_local $tmp1_2) + (get_local $tmp0_2) + (i64.sub) + (set_local $tmp1_2) + + (get_local $tmp1_3) + (get_local $tmp0_3) + (i64.sub) + (set_local $tmp1_3) + + (get_local $tmp1_4) + (get_local $tmp0_4) + (i64.sub) + (set_local $tmp1_4) + + (get_local $tmp1_5) + (get_local $tmp0_5) + (i64.sub) + (set_local $tmp1_5) + + (get_local $tmp1_6) + (get_local $tmp0_6) + (i64.sub) + (set_local $tmp1_6) + + (get_local $tmp1_7) + (get_local $tmp0_7) + (i64.sub) + (set_local $tmp1_7) + + (get_local $tmp1_8) + (get_local $tmp0_8) + (i64.sub) + (set_local $tmp1_8) + + (get_local $tmp1_9) + (get_local $tmp0_9) + (i64.sub) + (set_local $tmp1_9) + + ;; ptr0 <- z2 = z2 ^ 2 + (get_local $z2_0) + (get_local $z2_1) + (get_local $z2_2) + (get_local $z2_3) + (get_local $z2_4) + (get_local $z2_5) + (get_local $z2_6) + (get_local $z2_7) + (get_local $z2_8) + (get_local $z2_9) + (get_local $ptr0) + (i32.const 0) + (i32.const 0) + (i32.const 2) + (call_indirect (type $fe_sq)) + + ;; ptr1 <- z3 = tmp1 * _121666 + (i64.const 121666) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (i64.const 0) + (get_local $tmp1_0) + (get_local $tmp1_1) + (get_local $tmp1_2) + (get_local $tmp1_3) + (get_local $tmp1_4) + (get_local $tmp1_5) + (get_local $tmp1_6) + (get_local $tmp1_7) + (get_local $tmp1_8) + (get_local $tmp1_9) + (get_local $ptr1) + (i32.const 1) + (call_indirect (type $fe_mul)) + + ;; ptr2 <- x3 = x3 ^ 2 + (get_local $x3_0) + (get_local $x3_1) + (get_local $x3_2) + (get_local $x3_3) + (get_local $x3_4) + (get_local $x3_5) + (get_local $x3_6) + (get_local $x3_7) + (get_local $x3_8) + (get_local $x3_9) + (get_local $ptr2) + (i32.const 0) + (i32.const 0) + (i32.const 2) + (call_indirect (type $fe_sq)) + + ;; tmp0 <- load(ptr2) + (set_local $z2_0 (i64.load32_u offset=0 (get_local $ptr0))) + (set_local $z2_1 (i64.load32_u offset=4 (get_local $ptr0))) + (set_local $z2_2 (i64.load32_u offset=8 (get_local $ptr0))) + (set_local $z2_3 (i64.load32_u offset=12 (get_local $ptr0))) + (set_local $z2_4 (i64.load32_u offset=16 (get_local $ptr0))) + (set_local $z2_5 (i64.load32_u offset=20 (get_local $ptr0))) + (set_local $z2_6 (i64.load32_u offset=24 (get_local $ptr0))) + (set_local $z2_7 (i64.load32_u offset=28 (get_local $ptr0))) + (set_local $z2_8 (i64.load32_u offset=32 (get_local $ptr0))) + (set_local $z2_9 (i64.load32_u offset=36 (get_local $ptr0))) + + ;; tmp0 <- load(ptr2) + (set_local $z3_0 (i64.load32_u offset=0 (get_local $ptr1))) + (set_local $z3_1 (i64.load32_u offset=4 (get_local $ptr1))) + (set_local $z3_2 (i64.load32_u offset=8 (get_local $ptr1))) + (set_local $z3_3 (i64.load32_u offset=12 (get_local $ptr1))) + (set_local $z3_4 (i64.load32_u offset=16 (get_local $ptr1))) + (set_local $z3_5 (i64.load32_u offset=20 (get_local $ptr1))) + (set_local $z3_6 (i64.load32_u offset=24 (get_local $ptr1))) + (set_local $z3_7 (i64.load32_u offset=28 (get_local $ptr1))) + (set_local $z3_8 (i64.load32_u offset=32 (get_local $ptr1))) + (set_local $z3_9 (i64.load32_u offset=36 (get_local $ptr1))) + + ;; tmp0 <- load(ptr2) + (set_local $x3_0 (i64.load32_u offset=0 (get_local $ptr2))) + (set_local $x3_1 (i64.load32_u offset=4 (get_local $ptr2))) + (set_local $x3_2 (i64.load32_u offset=8 (get_local $ptr2))) + (set_local $x3_3 (i64.load32_u offset=12 (get_local $ptr2))) + (set_local $x3_4 (i64.load32_u offset=16 (get_local $ptr2))) + (set_local $x3_5 (i64.load32_u offset=20 (get_local $ptr2))) + (set_local $x3_6 (i64.load32_u offset=24 (get_local $ptr2))) + (set_local $x3_7 (i64.load32_u offset=28 (get_local $ptr2))) + (set_local $x3_8 (i64.load32_u offset=32 (get_local $ptr2))) + (set_local $x3_9 (i64.load32_u offset=36 (get_local $ptr2))) + + (get_local $tmp0_0) + (get_local $z3_0) + (i64.add) + (set_local $tmp0_0) + + (get_local $tmp0_1) + (get_local $z3_1) + (i64.add) + (set_local $tmp0_1) + + (get_local $tmp0_2) + (get_local $z3_2) + (i64.add) + (set_local $tmp0_2) + + (get_local $tmp0_3) + (get_local $z3_3) + (i64.add) + (set_local $tmp0_3) + + (get_local $tmp0_4) + (get_local $z3_4) + (i64.add) + (set_local $tmp0_4) + + (get_local $tmp0_5) + (get_local $z3_5) + (i64.add) + (set_local $tmp0_5) + + (get_local $tmp0_6) + (get_local $z3_6) + (i64.add) + (set_local $tmp0_6) + + (get_local $tmp0_7) + (get_local $z3_7) + (i64.add) + (set_local $tmp0_7) + + (get_local $tmp0_8) + (get_local $z3_8) + (i64.add) + (set_local $tmp0_8) + + (get_local $tmp0_9) + (get_local $z3_9) + (i64.add) + (set_local $tmp0_9) + + ;; ptr1 <- z3 = x1 * z2 + (get_local $x1_0) + (get_local $x1_1) + (get_local $x1_2) + (get_local $x1_3) + (get_local $x1_4) + (get_local $x1_5) + (get_local $x1_6) + (get_local $x1_7) + (get_local $x1_8) + (get_local $x1_9) + (get_local $z2_0) + (get_local $z2_1) + (get_local $z2_2) + (get_local $z2_3) + (get_local $z2_4) + (get_local $z2_5) + (get_local $z2_6) + (get_local $z2_7) + (get_local $z2_8) + (get_local $z2_9) + (get_local $ptr1) + (i32.const 1) + (call_indirect (type $fe_mul)) + + ;; ptr0 <- z2 = tmp1 * tmp0 + (get_local $tmp0_0) + (get_local $tmp0_1) + (get_local $tmp0_2) + (get_local $tmp0_3) + (get_local $tmp0_4) + (get_local $tmp0_5) + (get_local $tmp0_6) + (get_local $tmp0_7) + (get_local $tmp0_8) + (get_local $tmp0_9) + (get_local $tmp1_0) + (get_local $tmp1_1) + (get_local $tmp1_2) + (get_local $tmp1_3) + (get_local $tmp1_4) + (get_local $tmp1_5) + (get_local $tmp1_6) + (get_local $tmp1_7) + (get_local $tmp1_8) + (get_local $tmp1_9) + (get_local $ptr0) + (i32.const 1) + (call_indirect (type $fe_mul)) + + ;; tmp0 <- load(ptr2) + (set_local $z2_0 (i64.load32_u offset=0 (get_local $ptr0))) + (set_local $z2_1 (i64.load32_u offset=4 (get_local $ptr0))) + (set_local $z2_2 (i64.load32_u offset=8 (get_local $ptr0))) + (set_local $z2_3 (i64.load32_u offset=12 (get_local $ptr0))) + (set_local $z2_4 (i64.load32_u offset=16 (get_local $ptr0))) + (set_local $z2_5 (i64.load32_u offset=20 (get_local $ptr0))) + (set_local $z2_6 (i64.load32_u offset=24 (get_local $ptr0))) + (set_local $z2_7 (i64.load32_u offset=28 (get_local $ptr0))) + (set_local $z2_8 (i64.load32_u offset=32 (get_local $ptr0))) + (set_local $z2_9 (i64.load32_u offset=36 (get_local $ptr0))) + + ;; tmp0 <- load(ptr2) + (set_local $z3_0 (i64.load32_u offset=0 (get_local $ptr1))) + (set_local $z3_1 (i64.load32_u offset=4 (get_local $ptr1))) + (set_local $z3_2 (i64.load32_u offset=8 (get_local $ptr1))) + (set_local $z3_3 (i64.load32_u offset=12 (get_local $ptr1))) + (set_local $z3_4 (i64.load32_u offset=16 (get_local $ptr1))) + (set_local $z3_5 (i64.load32_u offset=20 (get_local $ptr1))) + (set_local $z3_6 (i64.load32_u offset=24 (get_local $ptr1))) + (set_local $z3_7 (i64.load32_u offset=28 (get_local $ptr1))) + (set_local $z3_8 (i64.load32_u offset=32 (get_local $ptr1))) + (set_local $z3_9 (i64.load32_u offset=36 (get_local $ptr1))) + + (get_local $pos) + (i32.const 1) + (i32.sub) + (set_local $pos) + (br $start))) + + ;; (call $i32.log (get_local $res_x2)) (i64.store32 offset=0 (get_local $res_x2) (get_local $x2_0)) (i64.store32 offset=4 (get_local $res_x2) (get_local $x2_1))