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 7e1964716c1d8671d11d14c664c13812fee60938
parent 319b4f81b9483efeb4fade17c540c252ad5471b1
Author: finwo <finwo@pm.me>
Date:   Mon, 15 Jul 2019 16:07:10 +0200

Bare compile removes memory management

Diffstat:
A.npmignore | 4++++
Mbuild.sh | 2+-
Mindex.js | 2+-
Msupercop.wasm | 0
Mtest.js | 2++
5 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/.npmignore b/.npmignore @@ -0,0 +1,4 @@ +lib/ +patch/ +.editorconfig +.eslint* diff --git a/build.sh b/build.sh @@ -7,4 +7,4 @@ git submodule update --force --init --recursive ( cd lib/supercop && patch -p1 < ../../patch/supercop/00-single-file-compile.patch ) # Compile -node_modules/.bin/wa compile --bare -o supercop.wasm supercop.c +node_modules/.bin/wa compile -o supercop.wasm supercop.c diff --git a/index.js b/index.js @@ -93,7 +93,7 @@ exports.sign = async function(message, publicKey, secretKey){ publicKeyArr.set(publicKey); secretKeyArr.set(secretKey); - fn.sign(sigPtr, messageArrPtr, messageLen, publicKeyArrPtr, secretKeyArrPtr); + await fn.sign(sigPtr, messageArrPtr, messageLen, publicKeyArrPtr, secretKeyArrPtr); fn._free(messageArrPtr); fn._free(publicKeyArrPtr); diff --git a/supercop.wasm b/supercop.wasm Binary files differ. diff --git a/test.js b/test.js @@ -65,10 +65,12 @@ test('Key generation',async t => { t.plan(6); const seed = await lib.createSeed(); + t.is(isBuffer(seed), true, 'Seed is a buffer' ); t.is(seed.length , 32 , 'Seed\'s length is 32'); const keys = await lib.createKeyPair(seed); + t.is(isBuffer(keys.publicKey), true, 'Public key is a buffer' ); t.is(keys.publicKey.length , 32 , 'Public key\'s length is 32'); t.is(isBuffer(keys.secretKey), true, 'Secret key is a buffer' );