From 0b37ca03ece84f6779b576661eb0414baeeea0f0 Mon Sep 17 00:00:00 2001 From: Christophe Diederichs Date: Wed, 17 Jun 2020 13:06:30 +0200 Subject: [PATCH] added: sodium_memcmp --- crypto_verify.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crypto_verify.js b/crypto_verify.js index d4b219d..65a60db 100644 --- a/crypto_verify.js +++ b/crypto_verify.js @@ -1,3 +1,5 @@ +const assert = require('nanoassert') + module.exports = { crypto_verify_16, crypto_verify_32 @@ -16,3 +18,9 @@ function crypto_verify_16(x, xi, y, yi) { function crypto_verify_32(x, xi, y, yi) { return vn(x, xi, y, yi, 32) } + +function sodium_memcmp (a, b) { + assert(a.byteLength = b.byteLength, 'buffers must be the same size') + + return vn(a, 0, b, 0, a.byteLength) +}