Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Promise.all([Sodium.crypto_box_keypair(),Sodium.crypto_box_keypair()]).then(([alice,bob]) => {
let p = []
for (mlen = 0; mlen <= mlen_max; mlen++) {
p.push(
Promise.all([
Sodium.randombytes_buf(Sodium.crypto_box_NONCEBYTES),
Sodium.randombytes_buf(mlen)
]).then(([n,m]) =>
Sodium.crypto_box_easy(m,n,bob.pk,alice.sk)
.then((c) => Sodium.crypto_box_open_easy(c,n,alice.pk,bob.sk))
.then((mm) => mm === m))
)
}
Promise.all(p).then((pr) => {
let fail = false
for (i = 0; i < pr.length && !fail; ++i) if (!pr[i]) fail = true
this.setState({crypto_box1:!fail})
})
})
}