@vbyte/btc-dev
Version:
Batteries-included toolset for plebian bitcoin development
1 lines • 957 kB
Source Map (JSON)
{"version":3,"file":"module.mjs","sources":["../node_modules/@vbyte/buff/dist/util/validate.js","../node_modules/@vbyte/buff/dist/util/assert.js","../node_modules/@vbyte/buff/dist/lib/big.js","../node_modules/@vbyte/buff/dist/lib/num.js","../node_modules/@vbyte/buff/dist/lib/hex.js","../node_modules/@vbyte/buff/dist/lib/bytes.js","../node_modules/@vbyte/buff/dist/lib/bin.js","../node_modules/@vbyte/buff/dist/lib/str.js","../node_modules/@vbyte/buff/dist/lib/rand.js","../node_modules/@vbyte/buff/dist/class/buff.js","../node_modules/@vbyte/buff/dist/class/stream.js","../node_modules/@vbyte/micro-lib/dist/lib/util.js","../node_modules/@vbyte/micro-lib/dist/lib/test.js","../node_modules/@vbyte/micro-lib/dist/lib/assert.js","../node_modules/@noble/hashes/esm/crypto.js","../node_modules/@noble/hashes/esm/utils.js","../node_modules/@noble/hashes/esm/_md.js","../node_modules/@noble/hashes/esm/sha2.js","../node_modules/@noble/hashes/esm/hmac.js","../node_modules/@noble/curves/esm/utils.js","../node_modules/@noble/curves/esm/abstract/modular.js","../node_modules/@noble/curves/esm/abstract/curve.js","../node_modules/@noble/curves/esm/abstract/weierstrass.js","../node_modules/@noble/curves/esm/_shortw_utils.js","../node_modules/@noble/curves/esm/secp256k1.js","../node_modules/@vbyte/micro-lib/dist/lib/ecc.js","../node_modules/@noble/hashes/esm/legacy.js","../node_modules/@vbyte/micro-lib/dist/lib/hash.js","../node_modules/@scure/base/lib/esm/index.js","../node_modules/@vbyte/micro-lib/dist/lib/encode.js","../src/lib/address/encode.ts","../src/const.ts","../src/lib/script/lock.ts","../src/lib/address/script.ts","../src/lib/address/util.ts","../src/lib/address/p2pkh.ts","../src/lib/address/p2sh.ts","../src/lib/address/p2wpkh.ts","../src/lib/address/p2wsh.ts","../src/lib/address/p2tr.ts","../src/lib/address/api.ts","../src/lib/meta/locktime.ts","../src/lib/meta/ref.ts","../src/lib/script/words.ts","../src/lib/script/encode.ts","../src/lib/script/decode.ts","../src/lib/meta/scribe.ts","../src/lib/meta/sequence.ts","../src/lib/script/util.ts","../src/lib/script/index.ts","../src/lib/sighash/util.ts","../src/lib/tx/decode.ts","../node_modules/zod/v4/core/core.js","../node_modules/zod/v4/core/util.js","../node_modules/zod/v4/core/errors.js","../node_modules/zod/v4/core/parse.js","../node_modules/zod/v4/core/regexes.js","../node_modules/zod/v4/core/checks.js","../node_modules/zod/v4/core/doc.js","../node_modules/zod/v4/core/versions.js","../node_modules/zod/v4/core/schemas.js","../node_modules/zod/v4/core/registries.js","../node_modules/zod/v4/core/api.js","../node_modules/zod/v4/classic/iso.js","../node_modules/zod/v4/classic/errors.js","../node_modules/zod/v4/classic/parse.js","../node_modules/zod/v4/classic/schemas.js","../src/schema/base.ts","../src/schema/taproot.ts","../src/schema/tx.ts","../src/lib/tx/validate.ts","../src/lib/tx/encode.ts","../src/lib/tx/parse.ts","../src/lib/tx/util.ts","../src/lib/tx/create.ts","../src/lib/tx/size.ts","../src/lib/sighash/segwit.ts","../src/lib/taproot/encode.ts","../src/lib/sighash/taproot.ts","../src/lib/signer/sign.ts","../src/lib/signer/verify.ts","../src/lib/taproot/tree.ts","../src/lib/witness/parse.ts","../src/lib/taproot/parse.ts","../src/lib/taproot/cblock.ts","../src/lib/witness/util.ts"],"sourcesContent":["export var Check;\n(function (Check) {\n function is_hex(input) {\n return (input.match(/[^a-fA-F0-9]/) === null &&\n input.length % 2 === 0);\n }\n Check.is_hex = is_hex;\n function is_bytes(input) {\n if (typeof input === 'string' && is_hex(input)) {\n return true;\n }\n else if (input instanceof Uint8Array) {\n return true;\n }\n else if (Array.isArray(input) &&\n input.every(e => typeof e === 'number')) {\n return true;\n }\n else {\n return false;\n }\n }\n Check.is_bytes = is_bytes;\n})(Check || (Check = {}));\n","import { Check } from '../util/validate.js';\nexport var Assert;\n(function (Assert) {\n function within_size(data, size) {\n if (data.length > size) {\n throw new TypeError(`Data is larger than array size: ${data.length} > ${size}`);\n }\n }\n Assert.within_size = within_size;\n function is_hex(hex) {\n if (hex.match(/[^a-fA-f0-9]/) !== null) {\n throw new TypeError('Invalid characters in hex string: ' + hex);\n }\n if (hex.length % 2 !== 0) {\n throw new Error(`Length of hex string is invalid: ${hex.length}`);\n }\n }\n Assert.is_hex = is_hex;\n function is_bytes(bytes) {\n if (!Check.is_bytes(bytes)) {\n throw new Error('Bytes contains invalid elements: ' + String(bytes));\n }\n }\n Assert.is_bytes = is_bytes;\n function is_json(str) {\n try {\n JSON.parse(str);\n }\n catch {\n throw new TypeError('JSON string is invalid!');\n }\n }\n Assert.is_json = is_json;\n function is_safe_int(num) {\n if (num > Number.MAX_SAFE_INTEGER) {\n throw new TypeError('Number exceeds safe bounds!');\n }\n }\n Assert.is_safe_int = is_safe_int;\n})(Assert || (Assert = {}));\n","const _0n = BigInt(0);\nconst _255n = BigInt(255);\nconst _256n = BigInt(256);\nexport function get_big_size(big) {\n if (big <= 0xffn)\n return 1;\n if (big <= 0xffffn)\n return 2;\n if (big <= 0xffffffffn)\n return 4;\n if (big <= 0xffffffffffffffffn)\n return 8;\n if (big <= 0xffffffffffffffffffffffffffffffffn)\n return 16;\n if (big <= 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn) {\n return 32;\n }\n throw new TypeError('Must specify a fixed buffer size for bigints greater than 32 bytes.');\n}\nexport function big_to_bytes(big, size, endian = 'be') {\n if (size === undefined)\n size = get_big_size(big);\n const use_le = (endian === 'le');\n const buffer = new ArrayBuffer(size);\n const dataView = new DataView(buffer);\n let offset = (use_le) ? 0 : size - 1;\n while (big > _0n) {\n const byte = big & _255n;\n const num = Number(byte);\n if (use_le) {\n dataView.setUint8(offset++, num);\n }\n else {\n dataView.setUint8(offset--, num);\n }\n big = (big - byte) / _256n;\n }\n return new Uint8Array(buffer);\n}\nexport function bytes_to_big(bytes) {\n let num = BigInt(0);\n for (let i = bytes.length - 1; i >= 0; i--) {\n num = (num * _256n) + BigInt(bytes[i]);\n }\n return BigInt(num);\n}\nexport function bigint_replacer(_, v) {\n return typeof v === 'bigint'\n ? `${v}n`\n : v;\n}\nexport function bigint_reviver(_, v) {\n return typeof v === 'string' && /^[0-9]+n$/.test(v)\n ? BigInt(v.slice(0, -1))\n : v;\n}\n","import { Assert } from '../util/assert.js';\nexport function get_num_size(num) {\n if (num <= 0xFF)\n return 1;\n if (num <= 0xFFFF)\n return 2;\n if (num <= 0xFFFFFFFF)\n return 4;\n throw new TypeError('Numbers larger than 4 bytes must specify a fixed size!');\n}\nexport function num_to_bytes(num, size, endian = 'be') {\n if (size === undefined)\n size = get_num_size(num);\n const use_le = (endian === 'le');\n const buffer = new ArrayBuffer(size);\n const dataView = new DataView(buffer);\n let offset = (use_le) ? 0 : size - 1;\n while (num > 0) {\n const byte = num & 255;\n if (use_le) {\n dataView.setUint8(offset++, num);\n }\n else {\n dataView.setUint8(offset--, num);\n }\n num = (num - byte) / 256;\n }\n return new Uint8Array(buffer);\n}\nexport function bytes_to_num(bytes) {\n let num = 0;\n for (let i = bytes.length - 1; i >= 0; i--) {\n num = (num * 256) + bytes[i];\n Assert.is_safe_int(num);\n }\n return num;\n}\n","import { Assert } from '../util/assert.js';\nexport function hex_to_bytes(hexstr, size, endian = 'be') {\n size = get_hex_size(hexstr, size);\n const use_be = (endian === 'be');\n const buffer = new ArrayBuffer(size);\n const dataView = new DataView(buffer);\n let offset = (use_be) ? 0 : size - 1;\n for (let i = 0; i < hexstr.length; i += 2) {\n const char = hexstr.substring(i, i + 2);\n const num = parseInt(char, 16);\n if (use_be) {\n dataView.setUint8(offset++, num);\n }\n else {\n dataView.setUint8(offset--, num);\n }\n }\n return new Uint8Array(buffer);\n}\nexport function bytes_to_hex(bytes) {\n let chars = '';\n for (let i = 0; i < bytes.length; i++) {\n chars += bytes[i].toString(16).padStart(2, '0');\n }\n return chars;\n}\nfunction get_hex_size(hexstr, size) {\n Assert.is_hex(hexstr);\n const len = hexstr.length / 2;\n if (size === undefined)\n size = len;\n if (len > size) {\n throw new TypeError(`Hex string is larger than array size: ${len} > ${size}`);\n }\n return size;\n}\n","import { Assert } from '../util/assert.js';\nimport { big_to_bytes } from './big.js';\nimport { num_to_bytes } from './num.js';\nimport { hex_to_bytes } from './hex.js';\nexport function buffer(bytes, size, endian) {\n if (bytes instanceof ArrayBuffer) {\n return new Uint8Array(bytes);\n }\n else if (bytes instanceof Uint8Array) {\n return create_bytes(bytes, size, endian);\n }\n else if (typeof bytes === 'string') {\n Assert.is_hex(bytes);\n return hex_to_bytes(bytes, size, endian);\n }\n else if (typeof bytes === 'bigint') {\n return big_to_bytes(bytes, size, endian);\n }\n else if (typeof bytes === 'number') {\n return num_to_bytes(bytes, size, endian);\n }\n throw new TypeError('Input type not supported:' + typeof bytes);\n}\nexport function create_bytes(data, size, endian = 'le') {\n if (size === undefined)\n size = data.length;\n Assert.within_size(data, size);\n const buffer = new Uint8Array(size).fill(0);\n const offset = (endian === 'be') ? 0 : size - data.length;\n buffer.set(data, offset);\n return buffer;\n}\nexport function join_bytes(arr) {\n let i, offset = 0;\n const size = arr.reduce((len, arr) => len + arr.length, 0);\n const buff = new Uint8Array(size);\n for (i = 0; i < arr.length; i++) {\n const a = arr[i];\n buff.set(a, offset);\n offset += a.length;\n }\n return buff;\n}\nexport function split_bytes(data_blob, chunk_size, total_size) {\n const len = data_blob.length, count = total_size / chunk_size;\n if (total_size % chunk_size !== 0) {\n throw new TypeError(`Invalid parameters: ${total_size} % ${chunk_size} !== 0`);\n }\n if (len !== total_size) {\n throw new TypeError(`Invalid data stream: ${len} !== ${total_size}`);\n }\n if (len % chunk_size !== 0) {\n throw new TypeError(`Invalid data stream: ${len} % ${chunk_size} !== 0`);\n }\n const chunks = new Array(count);\n for (let i = 0; i < count; i++) {\n const idx = i * chunk_size;\n chunks[i] = data_blob.subarray(idx, idx + chunk_size);\n }\n return chunks;\n}\n","export function bin_to_bytes(binary) {\n const bins = binary.split('').map(Number);\n if (bins.length % 8 !== 0) {\n throw new Error(`Binary array is invalid length: ${binary.length}`);\n }\n const bytes = new Uint8Array(bins.length / 8);\n for (let i = 0, ct = 0; i < bins.length; i += 8, ct++) {\n let byte = 0;\n for (let j = 0; j < 8; j++) {\n byte |= (bins[i + j] << (7 - j));\n }\n bytes[ct] = byte;\n }\n return bytes;\n}\nexport function bytes_to_bin(bytes) {\n const bin = new Array(bytes.length * 8);\n let count = 0;\n for (const num of bytes) {\n if (num > 255) {\n throw new Error(`Invalid byte value: ${num}. Byte values must be between 0 and 255.`);\n }\n for (let i = 7; i >= 0; i--, count++) {\n bin[count] = (num >> i) & 1;\n }\n }\n return bin.join('');\n}\n","const ec = new TextEncoder();\nconst dc = new TextDecoder();\nexport function str_to_bytes(str) {\n return ec.encode(str);\n}\nexport function bytes_to_str(bytes) {\n return dc.decode(bytes);\n}\n","export function get_random_bytes(length = 32) {\n if (crypto &&\n typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(length));\n }\n const pcrypto = crypto;\n if (pcrypto &&\n pcrypto.randomBytes !== undefined &&\n typeof pcrypto.randomBytes === 'function') {\n return pcrypto.randomBytes(length);\n }\n throw new Error('getRandomValues from crypto library is undefined');\n}\n","import * as Lib from '../lib/index.js';\nimport { Assert, Check } from '../util/index.js';\nexport class Buff extends Uint8Array {\n static { this.num = (number, size, endian) => {\n return new Buff(number, size, endian);\n }; }\n static { this.big = (bigint, size, endian) => {\n return new Buff(bigint, size, endian);\n }; }\n static { this.bin = (data, size, endian) => {\n const uint = Lib.bin_to_bytes(data);\n return new Buff(uint, size, endian);\n }; }\n static { this.uint = (data, size, endian) => {\n return new Buff(data, size, endian);\n }; }\n static { this.str = (data, size, endian) => {\n const uint = Lib.str_to_bytes(data);\n return new Buff(uint, size, endian);\n }; }\n static { this.hex = (data, size, endian) => {\n Assert.is_hex(data);\n return new Buff(data, size, endian);\n }; }\n static { this.bytes = (bytes, size, endian) => {\n Assert.is_bytes(bytes);\n return new Buff(bytes, size, endian);\n }; }\n static { this.json = (data, replacer) => {\n replacer = replacer ?? Lib.bigint_replacer;\n const str = JSON.stringify(data, replacer);\n const uint = Lib.str_to_bytes(str);\n return new Buff(uint);\n }; }\n static { this.blob = (payload, chunk_size, total_size) => {\n const bytes = Lib.buffer(payload);\n const chunks = Lib.split_bytes(bytes, chunk_size, total_size);\n return chunks.map(e => new Buff(e));\n }; }\n static { this.is_equal = (a, b) => {\n return new Buff(a).hex === new Buff(b).hex;\n }; }\n static { this.is_bytes = Check.is_bytes; }\n static { this.is_hex = Check.is_hex; }\n static random(size = 32) {\n const uint = Lib.get_random_bytes(size);\n return new Buff(uint, size);\n }\n static now() {\n const stamp = Math.floor(Date.now() / 1000);\n return new Buff(stamp, 4);\n }\n constructor(data, size, endian) {\n if (data instanceof Buff && size === undefined) {\n return data;\n }\n const buffer = Lib.buffer(data, size, endian);\n super(buffer);\n }\n get arr() {\n return this.to_arr();\n }\n get big() {\n return this.to_big();\n }\n get bin() {\n return this.to_bin();\n }\n get hex() {\n return this.to_hex();\n }\n get num() {\n return this.to_num();\n }\n get str() {\n return this.to_str();\n }\n get uint() {\n return this.to_uint();\n }\n to_big(endian = 'be') {\n const bytes = (endian === 'be')\n ? this.uint.reverse()\n : this.uint;\n return Lib.bytes_to_big(bytes);\n }\n to_hex(endian = 'be') {\n const bytes = (endian === 'be')\n ? this.uint\n : this.uint.reverse();\n return Lib.bytes_to_hex(bytes);\n }\n to_json(reviver) {\n if (reviver === undefined) {\n reviver = Lib.bigint_reviver;\n }\n const str = Lib.bytes_to_str(this);\n return JSON.parse(str, reviver);\n }\n to_num(endian = 'be') {\n const bytes = (endian === 'be')\n ? this.uint.reverse()\n : this.uint;\n return Lib.bytes_to_num(bytes);\n }\n to_arr() { return [...this]; }\n to_bin() { return Lib.bytes_to_bin(this); }\n to_str() { return Lib.bytes_to_str(this); }\n to_uint() { return new Uint8Array(this); }\n append(data) {\n return Buff.join([this, new Buff(data)]);\n }\n equals(data) {\n return new Buff(data).hex === this.hex;\n }\n prepend(data) {\n return Buff.join([new Buff(data), this]);\n }\n prefix_varint(endian) {\n if (this.length === 0)\n throw new Error('buffer is empty');\n const varint = Buff.varint(this.length, endian);\n return this.prepend(varint);\n }\n reverse() {\n super.reverse();\n return this;\n }\n set(array, offset) {\n this.set(array, offset);\n }\n slice(start, end) {\n const arr = new Uint8Array(this).slice(start, end);\n return new Buff(arr);\n }\n subarray(begin, end) {\n const arr = new Uint8Array(this).subarray(begin, end);\n return new Buff(arr);\n }\n toJSON() {\n return this.hex;\n }\n toString() {\n return this.hex;\n }\n static from(data) {\n return new Buff(Uint8Array.from(data));\n }\n static of(...args) {\n return new Buff(Uint8Array.of(...args));\n }\n static join(arr) {\n const bytes = arr.map(e => new Buff(e));\n const joined = Lib.join_bytes(bytes);\n return new Buff(joined);\n }\n static sort(arr, size) {\n const hex = arr.map(e => new Buff(e, size).hex);\n hex.sort();\n return hex.map(e => Buff.hex(e, size));\n }\n static varint(num, endian) {\n if (num < 0xFD) {\n return Buff.num(num, 1);\n }\n else if (num < 0x10000) {\n return Buff.of(0xFD, ...Buff.num(num, 2, endian));\n }\n else if (num < 0x100000000) {\n return Buff.of(0xFE, ...Buff.num(num, 4, endian));\n }\n else if (BigInt(num) < 0x10000000000000000n) {\n return Buff.of(0xFF, ...Buff.num(num, 8, endian));\n }\n else {\n throw new Error(`Value is too large: ${num}`);\n }\n }\n}\n","import { Buff } from '../class/buff.js';\nexport class Stream {\n constructor(data) {\n this.data = new Buff(data);\n this.size = this.data.length;\n }\n peek(size) {\n if (size > this.size) {\n throw new Error(`Size greater than stream: ${size} > ${this.size}`);\n }\n return new Buff(this.data.slice(0, size));\n }\n read(size) {\n const chunk = this.peek(size);\n this.data = this.data.slice(size);\n this.size = this.data.length;\n return chunk;\n }\n varint(endian) {\n const num = this.read(1).num;\n switch (true) {\n case (num >= 0 && num < 0xFD):\n return num;\n case (num === 0xFD):\n return this.read(2).to_num(endian);\n case (num === 0xFE):\n return this.read(4).to_num(endian);\n case (num === 0xFF):\n return this.read(8).to_num(endian);\n default:\n throw new Error(`Varint is out of range: ${num}`);\n }\n }\n}\n","export const now = () => Math.floor(Date.now() / 1000);\nexport const sleep = (ms = 1000) => new Promise(res => setTimeout(res, ms));\nexport function create_timeout(promise, timeout) {\n return new Promise(async (resolve, reject) => {\n const timer = setTimeout(() => reject('timeout'), timeout);\n const res = await promise;\n clearTimeout(timer);\n resolve(res);\n });\n}\nexport function sort_obj(obj) {\n if (obj instanceof Map || Array.isArray(obj) || typeof obj !== 'object') {\n return obj;\n }\n else {\n return Object.keys(obj)\n .sort()\n .filter(([_, value]) => value !== undefined)\n .reduce((sorted, key) => {\n sorted[key] = obj[key];\n return sorted;\n }, {});\n }\n}\nexport function parse_error(err) {\n if (err instanceof Error)\n return err.message;\n if (typeof err === 'string')\n return err;\n return String(err);\n}\n","import { Buff } from '@vbyte/buff';\nimport { sort_obj } from './util.js';\nexport var Test;\n(function (Test) {\n function exists(value) {\n if (typeof value === 'undefined' || value === null) {\n return false;\n }\n return true;\n }\n Test.exists = exists;\n function is_equal(a, b) {\n return a === b;\n }\n Test.is_equal = is_equal;\n function is_object(value) {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n }\n Test.is_object = is_object;\n function is_deep_equal(a, b) {\n if (is_object(a))\n a = sort_obj(a);\n if (is_object(b))\n b = sort_obj(b);\n return String(a) === String(b);\n }\n Test.is_deep_equal = is_deep_equal;\n function has_items(array) {\n return Array.isArray(array) && array.length > 0;\n }\n Test.has_items = has_items;\n function is_string(value) {\n return typeof value === 'string';\n }\n Test.is_string = is_string;\n function is_number(value) {\n return Number.isInteger(value) && !Number.isNaN(value);\n }\n Test.is_number = is_number;\n function is_bigint(value) {\n return typeof value === 'bigint';\n }\n Test.is_bigint = is_bigint;\n function is_uchar(value) {\n return is_number(value) && value >= 0 && value <= 0xFF;\n }\n Test.is_uchar = is_uchar;\n function is_ushort(value) {\n return is_number(value) && value >= 0 && value <= 0xFFFF;\n }\n Test.is_ushort = is_ushort;\n function is_uint(value) {\n return is_number(value) && value >= 0 && value <= 0xFFFFFFFF;\n }\n Test.is_uint = is_uint;\n function is_u8a(value) {\n return value instanceof Uint8Array;\n }\n Test.is_u8a = is_u8a;\n function is_bytes(value) {\n return Buff.is_bytes(value);\n }\n Test.is_bytes = is_bytes;\n function is_base58(value) {\n if (typeof value !== 'string')\n return false;\n return /^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$/.test(value);\n }\n Test.is_base58 = is_base58;\n function is_base64(value) {\n if (typeof value !== 'string')\n return false;\n return /^[a-zA-Z0-9+/]+={0,2}$/.test(value);\n }\n Test.is_base64 = is_base64;\n function is_b64url(value) {\n if (typeof value !== 'string')\n return false;\n return /^[a-zA-Z0-9\\-_]+={0,2}$/.test(value);\n }\n Test.is_b64url = is_b64url;\n function is_bech32(value) {\n if (typeof value !== 'string')\n return false;\n return /^[a-z]+1[023456789acdefghjklmnpqrstuvwxyz]+$/.test(value);\n }\n Test.is_bech32 = is_bech32;\n function is_hex(value) {\n if (!is_string(value))\n return false;\n return (value.match(/[^a-fA-F0-9]/) === null && value.length % 2 === 0);\n }\n Test.is_hex = is_hex;\n function is_hash(value) {\n return (is_string(value) && is_hex(value) && value.length === 64);\n }\n Test.is_hash = is_hash;\n})(Test || (Test = {}));\n","import { Buff } from '@vbyte/buff';\nimport { Test } from './test.js';\nexport var Assert;\n(function (Assert) {\n function ok(value, message) {\n if (value === false) {\n throw new Error(message ?? 'Assertion failed!');\n }\n }\n Assert.ok = ok;\n function exists(value, msg) {\n if (!Test.exists(value)) {\n throw new Error(msg ?? 'Value is null or undefined!');\n }\n }\n Assert.exists = exists;\n function is_empty(value, msg) {\n if (value !== null && value !== undefined) {\n throw new Error(msg ?? 'value is not null or undefined!');\n }\n }\n Assert.is_empty = is_empty;\n function is_instance(value, type, msg) {\n if (!(value instanceof type)) {\n throw new Error(msg ?? `value is not an instance of ${type.name}`);\n }\n }\n Assert.is_instance = is_instance;\n function is_equal(a, b, msg) {\n if (!Test.is_equal(a, b)) {\n throw new Error(msg ?? `values are not equal: ${String(a)} !== ${String(b)}`);\n }\n }\n Assert.is_equal = is_equal;\n function is_object(value, msg) {\n if (!Test.is_object(value)) {\n throw new Error(msg ?? `value is not an object: ${String(value)}`);\n }\n }\n Assert.is_object = is_object;\n function is_deep_equal(a, b, msg) {\n if (!Test.is_deep_equal(a, b)) {\n throw new Error(msg ?? `values are not deep equal: ${String(a)} !== ${String(b)}`);\n }\n }\n Assert.is_deep_equal = is_deep_equal;\n function is_number(value) {\n if (!Test.is_number(value)) {\n throw new TypeError(`invalid number: ${String(value)}`);\n }\n }\n Assert.is_number = is_number;\n function is_bigint(value) {\n if (!Test.is_bigint(value)) {\n throw new TypeError(`invalid bigint: ${String(value)}`);\n }\n }\n Assert.is_bigint = is_bigint;\n function is_hex(value) {\n if (!Test.is_hex(value)) {\n throw new TypeError(`invalid hex: ${String(value)}`);\n }\n }\n Assert.is_hex = is_hex;\n function is_uchar(value) {\n if (!Test.is_uchar(value)) {\n throw new TypeError(`invalid unsignedchar: ${String(value)}`);\n }\n }\n Assert.is_uchar = is_uchar;\n function is_ushort(value) {\n if (!Test.is_ushort(value)) {\n throw new TypeError(`invalid unsigned short: ${String(value)}`);\n }\n }\n Assert.is_ushort = is_ushort;\n function is_uint(value) {\n if (!Test.is_uint(value)) {\n throw new TypeError(`invalid unsigned int: ${String(value)}`);\n }\n }\n Assert.is_uint = is_uint;\n function is_u8a(value) {\n if (!Test.is_u8a(value)) {\n throw new TypeError(`invalid Uint8Array: ${String(value)}`);\n }\n }\n Assert.is_u8a = is_u8a;\n function is_hash(value, msg) {\n if (!Test.is_hash(value)) {\n throw new TypeError(msg ?? `invalid hash: ${String(value)}`);\n }\n }\n Assert.is_hash = is_hash;\n function is_bytes(value, msg) {\n if (!Test.is_bytes(value)) {\n throw new TypeError(msg ?? `invalid bytes: ${String(value)}`);\n }\n }\n Assert.is_bytes = is_bytes;\n function size(input, size, msg) {\n const bytes = Buff.bytes(input);\n if (bytes.length !== size) {\n throw new Error(msg ?? `invalid input size: ${bytes.length} !== ${size}`);\n }\n }\n Assert.size = size;\n function has_items(array, err_msg) {\n if (!Test.has_items(array)) {\n throw new Error(err_msg ?? 'array does not contain any items');\n }\n }\n Assert.has_items = has_items;\n function is_base58(value) {\n if (!Test.is_base58(value)) {\n throw new Error('invalid base58 string');\n }\n }\n Assert.is_base58 = is_base58;\n function is_base64(value) {\n if (!Test.is_base64(value)) {\n throw new Error('invalid base64 string');\n }\n }\n Assert.is_base64 = is_base64;\n function is_b64url(value) {\n if (!Test.is_b64url(value)) {\n throw new Error('invalid base64url string');\n }\n }\n Assert.is_b64url = is_b64url;\n function is_bech32(value) {\n if (!Test.is_bech32(value)) {\n throw new Error('invalid bech32 string');\n }\n }\n Assert.is_bech32 = is_bech32;\n})(Assert || (Assert = {}));\n","export const crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;\n//# sourceMappingURL=crypto.js.map","/**\n * Utilities for hex, bytes, CSPRNG.\n * @module\n */\n/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\n/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */\nexport function isBytes(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n/** Asserts something is positive integer. */\nexport function anumber(n) {\n if (!Number.isSafeInteger(n) || n < 0)\n throw new Error('positive integer expected, got ' + n);\n}\n/** Asserts something is Uint8Array. */\nexport function abytes(b, ...lengths) {\n if (!isBytes(b))\n throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\n/** Asserts something is hash */\nexport function ahash(h) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.createHasher');\n anumber(h.outputLen);\n anumber(h.blockLen);\n}\n/** Asserts a hash instance has not been destroyed / finished */\nexport function aexists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\n/** Asserts output is properly-sized byte array */\nexport function aoutput(out, instance) {\n abytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\n/** Cast u8 / u16 / u32 to u8. */\nexport function u8(arr) {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/** Cast u8 / u16 / u32 to u32. */\nexport function u32(arr) {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n/** Zeroize a byte array. Warning: JS provides no guarantees. */\nexport function clean(...arrays) {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n/** Create DataView of an array for easy byte-level manipulation. */\nexport function createView(arr) {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/** The rotate right (circular right shift) operation for uint32 */\nexport function rotr(word, shift) {\n return (word << (32 - shift)) | (word >>> shift);\n}\n/** The rotate left (circular left shift) operation for uint32 */\nexport function rotl(word, shift) {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n/** Is current platform little-endian? Most are. Big-Endian platform: IBM */\nexport const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n/** The byte swap operation for uint32 */\nexport function byteSwap(word) {\n return (((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff));\n}\n/** Conditionally byte swap if on a big-endian platform */\nexport const swap8IfBE = isLE\n ? (n) => n\n : (n) => byteSwap(n);\n/** @deprecated */\nexport const byteSwapIfBE = swap8IfBE;\n/** In place byte swap for Uint32Array */\nexport function byteSwap32(arr) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n return arr;\n}\nexport const swap32IfBE = isLE\n ? (u) => u\n : byteSwap32;\n// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex\nconst hasHexBuiltin = /* @__PURE__ */ (() => \n// @ts-ignore\ntypeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * Convert byte array to hex string. Uses built-in function, when available.\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes) {\n abytes(bytes);\n // @ts-ignore\n if (hasHexBuiltin)\n return bytes.toHex();\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };\nfunction asciiToBase16(ch) {\n if (ch >= asciis._0 && ch <= asciis._9)\n return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F)\n return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f)\n return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n/**\n * Convert hex string to byte array. Uses built-in function, when available.\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n // @ts-ignore\n if (hasHexBuiltin)\n return Uint8Array.fromHex(hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n/**\n * There is no setImmediate in browser and setTimeout is slow.\n * Call of async fn will return Promise, which will be fullfiled only on\n * next scheduler queue processing step and this is exactly what we need.\n */\nexport const nextTick = async () => { };\n/** Returns control to thread each 'tick' ms to avoid blocking. */\nexport async function asyncLoop(iters, tick, cb) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await nextTick();\n ts += diff;\n }\n}\n/**\n * Converts string to bytes using UTF8 encoding.\n * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])\n */\nexport function utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error('string expected');\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n/**\n * Converts bytes to string using UTF8 encoding.\n * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc'\n */\nexport function bytesToUtf8(bytes) {\n return new TextDecoder().decode(bytes);\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n/**\n * Helper for KDFs: consumes uint8array or string.\n * When string is passed, does utf8 decoding, using TextDecoder.\n */\nexport function kdfInputToBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n/** Copies several Uint8Arrays into one. */\nexport function concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\nexport function checkOpts(defaults, opts) {\n if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')\n throw new Error('options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged;\n}\n/** For runtime check if class implements interface */\nexport class Hash {\n}\n/** Wraps hash function, creating an interface on top of it */\nexport function createHasher(hashCons) {\n const hashC = (msg) => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\nexport function createOptHasher(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\nexport function createXOFer(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\nexport const wrapConstructor = createHasher;\nexport const wrapConstructorWithOpts = createOptHasher;\nexport const wrapXOFConstructorWithOpts = createXOFer;\n/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */\nexport function randomBytes(bytesLength = 32) {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return Uint8Array.from(crypto.randomBytes(bytesLength));\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n//# sourceMappingURL=utils.js.map","/**\n * Internal Merkle-Damgard hash utils.\n * @module\n */\nimport { Hash, abytes, aexists, aoutput, clean, createView, toBytes } from \"./utils.js\";\n/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */\nexport function setBigUint64(view, byteOffset, value, isLE) {\n if (typeof view.setBigUint64 === 'function')\n return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n/** Choice: a ? b : c */\nexport function Chi(a, b, c) {\n return (a & b) ^ (~a & c);\n}\n/** Majority function, true if any two inputs is true. */\nexport function Maj(a, b, c) {\n return (a & b) ^ (a & c) ^ (b & c);\n}\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nexport class HashMD extends Hash {\n constructor(blockLen, outputLen, padOffset, isLE) {\n super();\n this.finished = false;\n this.length = 0;\n this.pos = 0;\n this.destroyed = false;\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data) {\n aexists(this);\n data = toBytes(data);\n abytes(data);\n const { view, buffer, blockLen } = this;\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out) {\n aexists(this);\n aoutput(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n clean(this.buffer.subarray(pos));\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++)\n buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4)\n throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length)\n throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++)\n oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to) {\n to || (to = new this.constructor());\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.destroyed = destroyed;\n to.finished = finished;\n to.length = length;\n to.pos = pos;\n if (length % blockLen)\n to.buffer.set(buffer);\n return to;\n }\n clone() {\n return this._cloneInto();\n }\n}\n/**\n * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.\n * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.\n */\n/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */\nexport const SHA256_IV = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n]);\n/** Initial SHA224 state. Bits 32..64 of frac part of sqrt of primes 23..53 */\nexport const SHA224_IV = /* @__PURE__ */ Uint32Array.from([\n 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4,\n]);\n/** Initial SHA384 state. Bits 0..64 of frac part of sqrt of primes 23..53 */\nexport const SHA384_IV = /* @__PURE__ */ Uint32Array.from([\n 0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939,\n 0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4,\n]);\n/** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */\nexport const SHA512_IV = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,\n 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179,\n]);\n//# sourceMappingURL=_md.js.map","/**\n * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.\n * SHA256 is the fastest hash implementable in JS, even faster than Blake3.\n * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and\n * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).\n * @module\n */\nimport { Chi, HashMD, Maj, SHA224_IV, SHA256_IV, SHA384_IV, SHA512_IV } from \"./_md.js\";\nimport * as u64 from \"./_u64.js\";\nimport { clean, createHasher, rotr } from \"./utils.js\";\n/**\n * Round constants:\n * First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)\n */\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ Uint32Array.from([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n/** Reusable temporary buffer. \"W\" comes straight from spec. */\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nexport class SHA256 extends HashMD {\n constructor(outputLen = 32) {\n super(64, outputLen, 8, false);\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n this.A = SHA256_IV[0] | 0;\n this.B = SHA256_IV[1] | 0;\n this.C = SHA256_IV[2] | 0;\n this.D = SHA256_IV[3] | 0;\n this.E = SHA256_IV[4] | 0;\n this.F = SHA256_IV[5] | 0;\n this.G = SHA256_IV[6] | 0;\n this.H = SHA256_IV[7] | 0;\n }\n get() {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4)\n SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n clean(SHA256_W);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n clean(this.buffer);\n }\n}\nexport class SHA224 extends SHA256 {\n constructor() {\n super(28);\n this.A = SHA224_IV[0] | 0;\n this.B = SHA224_IV[1] | 0;\n this.C = S