supercop.wasm
Version:
orlp/ed25519 compiled to WebAssembly using Emscripten and optimized for small size
1 lines • 1.13 kB
JavaScript
(function(){function r(r){var n,t;return r=r(),n=r.allocateBytes,t=r.freeBytes,{ready:r.then,createSeed:function(){return e(32)},createKeyPair:function(e){var i,o;if(!(e instanceof Uint8Array))throw new Error("not Uint8Array!");return e=n(0,e),i=n(32),o=n(64),r._ed25519_create_keypair(i,o,e),i=i.get(),o=o.get(),t(),{publicKey:i,secretKey:o}},sign:function(e,i,o){var a;if(!(e instanceof Uint8Array&&i instanceof Uint8Array&&o instanceof Uint8Array))throw new Error("not Uint8Arrays!");return e=n(0,e),i=n(0,i),o=n(0,o),a=n(64),r._ed25519_sign(a,e,e.length,i,o),a=a.get(),t(),a},verify:function(e,i,o){var a;if(!(e instanceof Uint8Array&&i instanceof Uint8Array&&o instanceof Uint8Array))throw new Error("not Uint8Arrays!");return i=n(0,i),o=n(0,o),e=n(0,e),a=1===r._ed25519_verify(e,i,i.length,o),t(),a}}}var e;e="undefined"!=typeof crypto?function(r){var e;return e=new Uint8Array(r),crypto.getRandomValues(e),e}:require("crypto").randomBytes,"function"==typeof define&&define.amd?define(["./supercop"],r):"object"==typeof exports?module.exports=r(require("./supercop")):this.supercop_wasm=r(this.__supercopwasm)}).call(this);