for (var i = 0; i < arr.length; i++) arr[i] = 0;\r
}\r
\r
- const sign = function(msg, secretKey) {\r
+ export const sign = function(msg, secretKey) {\r
checkArrayTypes(msg, secretKey);\r
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\r
throw new Error('bad secret key size');\r
return signedMsg;\r
};\r
\r
- sign.open = function(signedMsg, publicKey) {\r
+ export const open = function(signedMsg, publicKey) {\r
checkArrayTypes(signedMsg, publicKey);\r
if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)\r
throw new Error('bad public key size');\r
return m;\r
};\r
\r
- sign.detached = function(msg, secretKey) {\r
+ export const detached = function(msg, secretKey) {\r
var signedMsg = sign(msg, secretKey);\r
var sig = new Uint8Array(crypto_sign_BYTES);\r
for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];\r
return sig;\r
};\r
\r
- sign.detached.verify = function(msg, sig, publicKey) {\r
+ export const verify = function(msg, sig, publicKey) {\r
checkArrayTypes(msg, sig, publicKey);\r
if (sig.length !== crypto_sign_BYTES)\r
throw new Error('bad signature size');\r
return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);\r
};\r
\r
- sign.keyPair = function() {\r
+ export const keyPair = function() {\r
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);\r
var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);\r
crypto_sign_keypair(pk, sk);\r
return {publicKey: pk, secretKey: sk};\r
};\r
\r
- sign.keyPair.fromSecretKey = function(secretKey) {\r
+ keyPair.fromSecretKey = function(secretKey) {\r
checkArrayTypes(secretKey);\r
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)\r
throw new Error('bad secret key size');\r
return {publicKey: pk, secretKey: new Uint8Array(secretKey)};\r
};\r
\r
- sign.keyPair.fromSeed = function(seed) {\r
+ keyPair.fromSeed = function(seed) {\r
checkArrayTypes(seed);\r
if (seed.length !== crypto_sign_SEEDBYTES)\r
throw new Error('bad seed size');\r
return {publicKey: pk, secretKey: sk};\r
};\r
\r
- sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;\r
- sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;\r
- sign.seedLength = crypto_sign_SEEDBYTES;\r
- sign.signatureLength = crypto_sign_BYTES;\r
+ export const publicKeyLength = crypto_sign_PUBLICKEYBYTES;\r
+ export const secretKeyLength = crypto_sign_SECRETKEYBYTES;\r
+ export const seedLength = crypto_sign_SEEDBYTES;\r
+ export const signatureLength = crypto_sign_BYTES;\r
\r
const setPRNG = function(fn) {\r
randombytes = fn;\r
}\r
}\r
})();\r
-\r
- export { sign }\r