scalarmult internal loop in wasm

This commit is contained in:
Christophe Diederichs 2020-10-13 16:10:47 +02:00
parent 40bced0da1
commit a02899bfe2
6 changed files with 1610 additions and 96 deletions

View File

@ -7,8 +7,7 @@ function loadWebAssembly (opts) {
if (!loadWebAssembly.supported) return null
var imp = opts && opts.imports
console.log(imp)
var wasm = toUint8Array('AGFzbQEAAAABMApgAX8AYAF/AX9gAn9/AGABfQBgAX0BfWABfABgAXwBfGABfgBgAX4BfmADf39/AAJhBwVkZWJ1ZwNsb2cAAAVkZWJ1Zwdsb2dfdGVlAAEFZGVidWcDbG9nAAIFZGVidWcDbG9nAAMFZGVidWcHbG9nX3RlZQAEBWRlYnVnA2xvZwAFBWRlYnVnB2xvZ190ZWUABgMEAwcICQUDAQABBxgCBm1lbW9yeQIAC2ZlMjU1MTlfbXVsAAkKuxEDDQAgAEIgh6cgAKcQAgsJACAAEAcgAA8LoBEBmgF+IAE1AgAhAyABNQIEIQQgATUCCCEFIAE1AgwhBiABNQIQIQcgATUCFCEIIAE1AhghCSABNQIcIQogATUCICELIAE1AiQhDCACNQIAIQ0gAjUCBCEOIAI1AgghDyACNQIMIRAgAjUCECERIAI1AhQhEiACNQIYIRMgAjUCHCEUIAI1AiAhFSACNQIkIRYgA6esIQMgBKesIQQgBaesIQUgBqesIQYgB6esIQcgCKesIQggCaesIQkgCqesIQogC6esIQsgDKesIQwgDaesIQ0gDqesIQ4gD6esIQ8gEKesIRAgEaesIREgEqesIRIgE6esIRMgFKesIRQgFaesIRUgFqesIRZCEyAOfiAOQoCAgIAIg0IBhkITfn0hK0ITIA9+IA9CgICAgAiDQgGGQhN+fSEsQhMgEH4gEEKAgICACINCAYZCE359IS1CEyARfiARQoCAgIAIg0IBhkITfn0hLkITIBJ+IBJCgICAgAiDQgGGQhN+fSEvQhMgE34gE0KAgICACINCAYZCE359ITBCEyAUfiAUQoCAgIAIg0IBhkITfn0hMUITIBV+IBVCgICAgAiDQgGGQhN+fSEyQhMgFn4gFkKAgICACINCAY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xCGYchKiAXICpCE358IRcgICAqQgFCGYZ+fSEgIBdCAUIZhnxCGochISAYICF8IRggFyAhQgFCGoZ+fSEXIAAgFz4CACAAIBg+AgQgACAZPgIIIAAgGj4CDCAAIBs+AhAgACAcPgIUIAAgHT4CGCAAIB4+AhwgACAfPgIgIAAgID4CJAs=')
var wasm = toUint8Array('AGFzbQEAAAABHwJgFX5+fn5+fn5+fn5+fn5+fn5+fn5+fwBgA39/fwACDgECanMFdGFibGUBcAABAwMCAAEFAwEAAQcYAgZtZW1vcnkCAAtmZTI1NTE5X211bAABCQcBAEEBCwEACv4QApAQAYYBfiAAp6whACABp6whASACp6whAiADp6whAyAEp6whBCAFp6whBSAGp6whBiAHp6whByAIp6whCCAJp6whCSAKp6whCiALp6whCyAMp6whDCANp6whDSAOp6whDiAPp6whDyAQp6whECARp6whESASp6whEiATp6whE0ITIAt+IAtCgICAgAiDQgGGQhN+fSEpQhMgDH4gDEKAgICACINCAYZCE359ISpCEyANfiANQoCAgIAIg0IBhkITfn0hK0ITIA5+IA5CgICAgAiDQgGGQhN+fSEsQhMgD34gD0KAgICACINCAYZCE359IS1CEyAQfiAQQoCAgIAIg0IBhkITfn0hLkITIBF+IBFCgICAgAiDQgGGQhN+fSEvQhMgEn4gEkKAgICACINCAYZCE359ITBCEyATfiATQoCAgIAIg0IBhkITfn0hMUICIAF+IAFCgICAgAiDQgGGQgJ+fSEyQgIgA34gA0KAgICACINCAYZCAn59ITNCAiAFfiAFQoCAgIAIg0IBhkICfn0hNEICIAd+IAdCgICAgAiDQgGGQgJ+fSE1QgIgCX4gCUKAgICACINCAYZCAn59ITYgKaesISkgKqesISogK6esISsgLKesISwgLaesIS0gLqesIS4gL6esIS8gMKesITAgMaesITEgMqesITIgM6esITMgNKesITQgNaesITUgNqesITYgACAKfiE3IAAgC34hOCAAIAx+ITkgACANfiE6IAAgDn4hOyAAIA9+ITwgACAQfiE9IAAgEX4hPiAAIBJ+IT8gACATfiFAIAEgCn4hQSAyIAt+I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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))
(import "js" "table" (table 1 anyfunc))
(elem (i32.const 1) $fe_mul)
;; (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))
(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))))
;; ;; 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)))
;; (func $i64.log_tee
;; (param $0 i64)
;; (result i64)
;; (call $i64.log (get_local $0))
;; (return (get_local $0)))
(func $mul (export "fe25519_mul") (param $h i32) (param $f i32) (param $g i32)
(local $f0 i64)
(local $f1 i64)
(local $f2 i64)
(local $f3 i64)
(local $f4 i64)
(local $f5 i64)
(local $f6 i64)
(local $f7 i64)
(local $f8 i64)
(local $f9 i64)
(func $fe_mul
(param $f0 i64)
(param $f1 i64)
(param $f2 i64)
(param $f3 i64)
(param $f4 i64)
(param $f5 i64)
(param $f6 i64)
(param $f7 i64)
(param $f8 i64)
(param $f9 i64)
(local $g0 i64)
(local $g1 i64)
(local $g2 i64)
(local $g3 i64)
(local $g4 i64)
(local $g5 i64)
(local $g6 i64)
(local $g7 i64)
(local $g8 i64)
(local $g9 i64)
(param $g0 i64)
(param $g1 i64)
(param $g2 i64)
(param $g3 i64)
(param $g4 i64)
(param $g5 i64)
(param $g6 i64)
(param $g7 i64)
(param $g8 i64)
(param $g9 i64)
(param $h i32)
(local $h0 i64)
(local $h1 i64)
@ -191,28 +196,6 @@
(local $f9g8_19 i64)
(local $f9g9_38 i64)
(set_local $f0 (i64.load32_u offset=0 (get_local $f)))
(set_local $f1 (i64.load32_u offset=4 (get_local $f)))
(set_local $f2 (i64.load32_u offset=8 (get_local $f)))
(set_local $f3 (i64.load32_u offset=12 (get_local $f)))
(set_local $f4 (i64.load32_u offset=16 (get_local $f)))
(set_local $f5 (i64.load32_u offset=20 (get_local $f)))
(set_local $f6 (i64.load32_u offset=24 (get_local $f)))
(set_local $f7 (i64.load32_u offset=28 (get_local $f)))
(set_local $f8 (i64.load32_u offset=32 (get_local $f)))
(set_local $f9 (i64.load32_u offset=36 (get_local $f)))
(set_local $g0 (i64.load32_u offset=0 (get_local $g)))
(set_local $g1 (i64.load32_u offset=4 (get_local $g)))
(set_local $g2 (i64.load32_u offset=8 (get_local $g)))
(set_local $g3 (i64.load32_u offset=12 (get_local $g)))
(set_local $g4 (i64.load32_u offset=16 (get_local $g)))
(set_local $g5 (i64.load32_u offset=20 (get_local $g)))
(set_local $g6 (i64.load32_u offset=24 (get_local $g)))
(set_local $g7 (i64.load32_u offset=28 (get_local $g)))
(set_local $g8 (i64.load32_u offset=32 (get_local $g)))
(set_local $g9 (i64.load32_u offset=36 (get_local $g)))
(set_local $f0 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f0))))
(set_local $f1 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f1))))
(set_local $f2 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f2))))
@ -431,4 +414,28 @@
(i64.store32 offset=24 (get_local $h) (get_local $h6))
(i64.store32 offset=28 (get_local $h) (get_local $h7))
(i64.store32 offset=32 (get_local $h) (get_local $h8))
(i64.store32 offset=36 (get_local $h) (get_local $h9))))
(i64.store32 offset=36 (get_local $h) (get_local $h9)))
(func $fe25519_mul (export "fe25519_mul") (param $h i32) (param $f i32) (param $g i32)
(i64.load32_u offset=0 (get_local $f))
(i64.load32_u offset=4 (get_local $f))
(i64.load32_u offset=8 (get_local $f))
(i64.load32_u offset=12 (get_local $f))
(i64.load32_u offset=16 (get_local $f))
(i64.load32_u offset=20 (get_local $f))
(i64.load32_u offset=24 (get_local $f))
(i64.load32_u offset=28 (get_local $f))
(i64.load32_u offset=32 (get_local $f))
(i64.load32_u offset=36 (get_local $f))
(i64.load32_u offset=0 (get_local $g))
(i64.load32_u offset=4 (get_local $g))
(i64.load32_u offset=8 (get_local $g))
(i64.load32_u offset=12 (get_local $g))
(i64.load32_u offset=16 (get_local $g))
(i64.load32_u offset=20 (get_local $g))
(i64.load32_u offset=24 (get_local $g))
(i64.load32_u offset=28 (get_local $g))
(i64.load32_u offset=32 (get_local $g))
(i64.load32_u offset=36 (get_local $g))
(get_local $h)
(call $fe_mul)))

View File

@ -7,7 +7,7 @@ function loadWebAssembly (opts) {
if (!loadWebAssembly.supported) return null
var imp = opts && opts.imports
var wasm = toUint8Array('AGFzbQEAAAABCAFgBH9/f38AAwIBAAUDAQABBw8CBm1lbW9yeQIAAnNxAAAKzwoBzAoCAX9jfiABNQIAIQYgATUCBCEHIAE1AgghCCABNQIMIQkgATUCECEKIAE1AhQhCyABNQIY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HwhEyASIBxCAUIZhn59IRIgFkIBQhiGfEIZhyEgIBcgIHwhFyAWICBCAUIZhn59IRYgE0IBQhmGfEIahyEdIBQgHXwhFCATIB1CAUIahn59IRMgF0IBQhmGfEIahyEhIBggIXwhGCAXICFCAUIahn59IRcgGEIBQhiGfEIZhyEiIA8gIkITfnwhDyAYICJCAUIZhn59IRggD0IBQhmGfEIahyEZIBAgGXwhECAPIBlCAUIahn59IQ8gDCAPPgIAIAwgED4CBCAMIBE+AgggDCASPgIMIAwgEz4CECAMIBQ+AhQgDCAVPgIYIAwgFj4CHCAMIBc+AiAgDCAYPgIkCzwAIAA1AgAgADUCBCAANQIIIAA1AgwgADUCECAANQIUIAA1AhggADUCHCAANQIgIAA1AiQgASACIAMQAAs=')
var ready = null
var mod = {

View File

@ -1,21 +1,29 @@
(module
(import "js" "table" (table 1 anyfunc))
(elem (i32.const 2) $fe_sq)
(memory $0 1)
(export "memory" (memory $0))
(func $sq (export "sq") (param $h i32) (param $f i32) (param $double i32) (param $repeat i32)
(func $fe_sq
(param $f0 i64)
(param $f1 i64)
(param $f2 i64)
(param $f3 i64)
(param $f4 i64)
(param $f5 i64)
(param $f6 i64)
(param $f7 i64)
(param $f8 i64)
(param $f9 i64)
(param $double i32)
(param $repeat i32)
(param $h i32)
(local $count i32)
(local $tmp i64)
(local $f0 i64)
(local $f1 i64)
(local $f2 i64)
(local $f3 i64)
(local $f4 i64)
(local $f5 i64)
(local $f6 i64)
(local $f7 i64)
(local $f8 i64)
(local $f9 i64)
(local $h0 i64)
(local $h1 i64)
@ -110,17 +118,6 @@
(local $f8f9_38 i64)
(local $f9f9_38 i64)
(set_local $f0 (i64.load32_u offset=0 (get_local $f)))
(set_local $f1 (i64.load32_u offset=4 (get_local $f)))
(set_local $f2 (i64.load32_u offset=8 (get_local $f)))
(set_local $f3 (i64.load32_u offset=12 (get_local $f)))
(set_local $f4 (i64.load32_u offset=16 (get_local $f)))
(set_local $f5 (i64.load32_u offset=20 (get_local $f)))
(set_local $f6 (i64.load32_u offset=24 (get_local $f)))
(set_local $f7 (i64.load32_u offset=28 (get_local $f)))
(set_local $f8 (i64.load32_u offset=32 (get_local $f)))
(set_local $f9 (i64.load32_u offset=36 (get_local $f)))
(block $end
(loop $again
(set_local $f0 (i64.extend_s/i32 (i32.wrap/i64 (get_local $f0))))
@ -285,4 +282,20 @@
(i64.store32 offset=24 (get_local $h) (get_local $h6))
(i64.store32 offset=28 (get_local $h) (get_local $h7))
(i64.store32 offset=32 (get_local $h) (get_local $h8))
(i64.store32 offset=36 (get_local $h) (get_local $h9))))
(i64.store32 offset=36 (get_local $h) (get_local $h9)))
(func $sq (export "sq") (param $f i32) (param $double i32) (param $repeat i32) (param $h i32)
(i64.load32_u offset=0 (get_local $f))
(i64.load32_u offset=4 (get_local $f))
(i64.load32_u offset=8 (get_local $f))
(i64.load32_u offset=12 (get_local $f))
(i64.load32_u offset=16 (get_local $f))
(i64.load32_u offset=20 (get_local $f))
(i64.load32_u offset=24 (get_local $f))
(i64.load32_u offset=28 (get_local $f))
(i64.load32_u offset=32 (get_local $f))
(i64.load32_u offset=36 (get_local $f))
(get_local $double)
(get_local $repeat)
(get_local $h)
(call $fe_sq)))

View File

@ -0,0 +1,61 @@
module.exports = loadWebAssembly
loadWebAssembly.supported = typeof WebAssembly !== 'undefined'
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+IAUpAwAhEyAFKQMIIRQgBSkDECEVIAUpAxghFiAANQIAIRcgADUCBCEYIAA1AgghGSAANQIMIRogADUCECEbIAA1AhQhHCAANQIYIR0gADUCHCEeIAA1AiAhHyAANQIkISAgATUCACEhIAE1Ag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IUQgDjUCGCFFIA41AhwhRiAONQIgIUcgDjUCJCFIIAxBAWshDAwACyAGICE+AgAgBiAiPgIEIAYgIz4CCCAGICQ+AgwgBiAlPgIQIAYgJj4CFCAGICc+AhggBiAoPgIcIAYgKT4CICAGICo+AiQgByA1PgIAIAcgNj4CBCAHIDc+AgggByA4PgIMIAcgOT4CECAHIDo+AhQgByA7PgIYIAcgPD4CHCAHID0+AiAgByA+PgIkIAggKz4CACAIICw+AgQgCCAtPgIIIAggLj4CDCAIIC8+AhAgCCAwPgIUIAggMT4CGCAIIDI+AhwgCCAzPgIgIAggND4CJCAJID8+AgAgCSBAPgIEIAkgQT4CCCAJIEI+AgwgCSBDPgIQIAkgRD4CFCAJIEU+AhggCSBGPgIcIAkgRz4CICAJIEg+AiQgCgs=')
var ready = null
var mod = {
buffer: wasm,
memory: null,
exports: null,
realloc: realloc,
onload: onload
}
onload(function () {})
return mod
function realloc (size) {
mod.exports.memory.grow(Math.max(0, Math.ceil(Math.abs(size - mod.memory.length) / 65536)))
mod.memory = new Uint8Array(mod.exports.memory.buffer)
}
function onload (cb) {
if (mod.exports) return cb()
if (ready) {
ready.then(cb.bind(null, null)).catch(cb)
return
}
try {
if (opts && opts.async) throw new Error('async')
setup({instance: new WebAssembly.Instance(new WebAssembly.Module(wasm), imp)})
} catch (err) {
ready = WebAssembly.instantiate(wasm, imp).then(setup)
}
onload(cb)
}
function setup (w) {
mod.exports = w.instance.exports
mod.memory = mod.exports.memory && mod.exports.memory.buffer && new Uint8Array(mod.exports.memory.buffer)
}
}
function toUint8Array (s) {
if (typeof atob === 'function') return new Uint8Array(atob(s).split('').map(charCodeAt))
return (require('buf' + 'fer').Buffer).from(s, 'base64')
}
function charCodeAt (c) {
return c.charCodeAt(0)
}

File diff suppressed because it is too large Load Diff