UNPKG

tweetnacl-ts

Version:

Port of TweetNaCl cryptographic library to TypeScript (and ES6)

21 lines 614 B
import { checkArrayTypes } from './check'; function vn(x, xi, y, yi, n) { var i, d = 0; for (i = 0; i < n; i++) d |= x[xi + i] ^ y[yi + i]; return (1 & ((d - 1) >>> 8)) - 1; } export function _verify_16(x, xi, y, yi) { return vn(x, xi, y, yi, 16); } export function _verify_32(x, xi, y, yi) { return vn(x, xi, y, yi, 32); } export function verify(x, y) { checkArrayTypes(x, y); // Zero length arguments are considered not equal return x.length > 0 && y.length > 0 && x.length == y.length && vn(x, 0, y, 0, x.length) == 0; } //# sourceMappingURL=verify.js.map