Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function randombytes(n) {
var b = new Buffer(n)
sodium.randombytes(b)
return b
}
function randomSecret(n) {
var rand = new Buffer(n)
sodium.randombytes(rand)
return rand
}
generate: function (seed) {
if(!seed) sodium.randombytes(seed = new Buffer(32))
var keys = seed ? sodium.crypto_sign_seed_keypair(seed) : sodium.crypto_sign_keypair()
return {
curve: 'ed25519',
public: keys.publicKey,
//so that this works with either sodium
//or libsodium-wrappers (in browser)
private: keys.privateKey || keys.secretKey
}
},