From ec9cac17d0c27c31085c21fc03a9edc3af88e8f6 Mon Sep 17 00:00:00 2001 From: Christophe Diederichs Date: Wed, 17 Jun 2020 13:19:05 +0200 Subject: [PATCH] added: sodium_is_zero --- crypto_verify.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crypto_verify.js b/crypto_verify.js index 29ab54c..bfa5099 100644 --- a/crypto_verify.js +++ b/crypto_verify.js @@ -3,7 +3,8 @@ const assert = require('nanoassert') module.exports = { crypto_verify_16, crypto_verify_32, - sodium_memcmp + sodium_memcmp, + sodium_is_zero } function vn (x, xi, y, yi, n) { @@ -25,3 +26,9 @@ function sodium_memcmp (a, b) { return vn(a, 0, b, 0, a.byteLength) === 0 } + +function sodium_is_zero = function (arr) { + var d = 0 + for (let i = 0; i < arr.length; i++) d |= arr[i] + return d === 0 +}