Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.unbox = function (boxed, keys) {
boxed = u.toBuffer(boxed)
var sk = keys._exchangeKey || sodium.crypto_sign_ed25519_sk_to_curve25519(u.toBuffer(keys.private || keys))
if(keys.private) keys._exchangeKey = sk //if keys is an object, cache the curve key.
try {
var msg = pb.multibox_open(boxed, sk)
return JSON.parse(''+msg)
} catch (_) { }
return
}
exports.unboxKey = function (boxed, keys) {
boxed = u.toBuffer(boxed)
var sk = sodium.crypto_sign_ed25519_sk_to_curve25519(u.toBuffer(keys.private || keys))
return pb.multibox_open_key(boxed, sk)
}