UNPKG

@waku/rln

Version:

RLN (Rate Limiting Nullifier) implementation for Waku

25 lines (22 loc) 836 B
import { abytes } from '../../@noble/hashes/esm/_assert.js'; import { hexToBytes as hexToBytes$1 } from '../../@noble/hashes/esm/utils.js'; export { bytesToHex, concatBytes, createView, bytesToHex as toHex, utf8ToBytes } from '../../@noble/hashes/esm/utils.js'; // buf.toString('utf8') -> bytesToUtf8(buf) function bytesToUtf8(data) { if (!(data instanceof Uint8Array)) { throw new TypeError(`bytesToUtf8 expected Uint8Array, got ${typeof data}`); } return new TextDecoder().decode(data); } function hexToBytes(data) { const sliced = data.startsWith("0x") ? data.substring(2) : data; return hexToBytes$1(sliced); } // Internal utils function wrapHash(hash) { return (msg) => { abytes(msg); return hash(msg); }; } export { abytes as assertBytes, bytesToUtf8, hexToBytes, wrapHash };