supercop.ts

cross-compiled javascript implementation of ed25519 based on supercop-ref10
git clone git://git.finwo.net/lib/supercop.ts
Log | Files | Refs | README | LICENSE

commit 7f1e177078a26d7ac6d5fc0f887d4c3ea33b67f6
parent 8354998d3fe334baef380b82396ecf46f8c1fa91
Author: finwo <finwo@pm.me>
Date:   Wed, 17 Jun 2020 17:11:34 +0200

Keep instantiate compatible with older nodejs versions

Diffstat:
Mindex.js | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/index.js b/index.js @@ -5,9 +5,13 @@ async function instantiateModule() { if (Module) return; const memory = new WebAssembly.Memory({initial: 2}); - const sp = new WebAssembly.Global({value: 'i32', mutable: true}); + const imports = {env:{memory}}; + + if ('function' === WebAssembly.Global) { + imports.env.__stack_pointer = new WebAssembly.Global({value: 'i32', mutable: true}); + } + const bytes = require('./supercop.wasm.js'); - const imports = {env:{memory,__stack_pointer:sp}}; const program = await WebAssembly.instantiate(bytes, imports); Module = {