@qntx/wallet-worker 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -486,11 +486,11 @@ function abytes(value, length, title = "") {
486
486
  return value;
487
487
  if (length !== undefined)
488
488
  anumber(length, "length");
489
- const bytes2 = isBytes(value);
489
+ const bytes = isBytes(value);
490
490
  const ofLen = length !== undefined ? ` of length ${length}` : "";
491
- const got = bytes2 ? `length=${value.length}` : `type=${typeof value}`;
491
+ const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
492
492
  const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
493
- if (!bytes2)
493
+ if (!bytes)
494
494
  throw new TypeError(message);
495
495
  throw new RangeError(message);
496
496
  }
@@ -527,16 +527,16 @@ function aoutput(out, instance) {
527
527
  throw new RangeError('"output" expected length >= ' + min);
528
528
  }
529
529
  }
530
- function u32(arr2) {
531
- return new Uint32Array(arr2.buffer, arr2.byteOffset, Math.floor(arr2.byteLength / 4));
530
+ function u32(arr) {
531
+ return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
532
532
  }
533
533
  function clean(...arrays) {
534
534
  for (let i = 0;i < arrays.length; i++) {
535
535
  arrays[i].fill(0);
536
536
  }
537
537
  }
538
- function createView(arr2) {
539
- return new DataView(arr2.buffer, arr2.byteOffset, arr2.byteLength);
538
+ function createView(arr) {
539
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
540
540
  }
541
541
  function rotr(word, shift) {
542
542
  return word << 32 - shift | word >>> shift;
@@ -548,22 +548,22 @@ var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).bu
548
548
  function byteSwap(word) {
549
549
  return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
550
550
  }
551
- function byteSwap32(arr2) {
552
- for (let i = 0;i < arr2.length; i++) {
553
- arr2[i] = byteSwap(arr2[i]);
551
+ function byteSwap32(arr) {
552
+ for (let i = 0;i < arr.length; i++) {
553
+ arr[i] = byteSwap(arr[i]);
554
554
  }
555
- return arr2;
555
+ return arr;
556
556
  }
557
557
  var swap32IfBE = isLE ? (u) => u : byteSwap32;
558
558
  var hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
559
559
  var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
560
- function bytesToHex(bytes2) {
561
- abytes(bytes2);
560
+ function bytesToHex(bytes) {
561
+ abytes(bytes);
562
562
  if (hasHexBuiltin)
563
- return bytes2.toHex();
563
+ return bytes.toHex();
564
564
  let hex = "";
565
- for (let i = 0;i < bytes2.length; i++) {
566
- hex += hexes[bytes2[i]];
565
+ for (let i = 0;i < bytes.length; i++) {
566
+ hex += hexes[bytes[i]];
567
567
  }
568
568
  return hex;
569
569
  }
@@ -623,10 +623,10 @@ async function asyncLoop(iters, tick, cb, onReject) {
623
623
  ts = Date.now();
624
624
  }
625
625
  }
626
- function utf8ToBytes(str2) {
627
- if (typeof str2 !== "string")
626
+ function utf8ToBytes(str) {
627
+ if (typeof str !== "string")
628
628
  throw new TypeError("string expected");
629
- const encoded = new TextEncoder().encode(str2);
629
+ const encoded = new TextEncoder().encode(str);
630
630
  try {
631
631
  return new Uint8Array(encoded);
632
632
  } finally {
@@ -692,45 +692,45 @@ function wipe(...buffers) {
692
692
  buffer.fill(0);
693
693
  }
694
694
  }
695
- function decodeUtf8Secret(bytes2) {
695
+ function decodeUtf8Secret(bytes) {
696
696
  try {
697
- return new TextDecoder("utf-8", { fatal: true }).decode(bytes2);
697
+ return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
698
698
  } catch {
699
699
  throw new KernelError("invalid-input", "input is not valid UTF-8");
700
700
  } finally {
701
- wipe(bytes2);
701
+ wipe(bytes);
702
702
  }
703
703
  }
704
704
 
705
705
  class Secret {
706
706
  #bytes;
707
- constructor(bytes2) {
708
- this.#bytes = bytes2;
707
+ constructor(bytes) {
708
+ this.#bytes = bytes;
709
709
  }
710
- static take(bytes2) {
711
- return new Secret(bytes2);
710
+ static take(bytes) {
711
+ return new Secret(bytes);
712
712
  }
713
713
  get length() {
714
- const bytes2 = this.#bytes;
715
- if (bytes2 === undefined) {
714
+ const bytes = this.#bytes;
715
+ if (bytes === undefined) {
716
716
  throw new KernelError("integrity", "secret already wiped");
717
717
  }
718
- return bytes2.length;
718
+ return bytes.length;
719
719
  }
720
720
  get wiped() {
721
721
  return this.#bytes === undefined;
722
722
  }
723
723
  use(fn) {
724
- const bytes2 = this.#bytes;
725
- if (bytes2 === undefined) {
724
+ const bytes = this.#bytes;
725
+ if (bytes === undefined) {
726
726
  throw new KernelError("integrity", "secret already wiped");
727
727
  }
728
- return fn(bytes2);
728
+ return fn(bytes);
729
729
  }
730
730
  wipe() {
731
- const bytes2 = this.#bytes;
732
- if (bytes2 !== undefined) {
733
- bytes2.fill(0);
731
+ const bytes = this.#bytes;
732
+ if (bytes !== undefined) {
733
+ bytes.fill(0);
734
734
  this.#bytes = undefined;
735
735
  }
736
736
  }
@@ -913,11 +913,11 @@ function split(lst, le = false) {
913
913
  }
914
914
  var fromNumH = (n) => n / 2 ** 32 | 0;
915
915
  var fromNumL = (n) => n >>> 0;
916
- function setU64FromNum(view, byteOffset, n, isLE2) {
916
+ function setU64FromNum(view, byteOffset, n, isLE) {
917
917
  const h = fromNumH(n);
918
918
  const l = fromNumL(n);
919
- view.setUint32(byteOffset, isLE2 ? l : h, isLE2);
920
- view.setUint32(byteOffset + 4, isLE2 ? h : l, isLE2);
919
+ view.setUint32(byteOffset, isLE ? l : h, isLE);
920
+ view.setUint32(byteOffset + 4, isLE ? h : l, isLE);
921
921
  }
922
922
  var shrSH = (h, _l, s) => h >>> s;
923
923
  var shrSL = (h, l, s) => h << 32 - s | l >>> s;
@@ -956,11 +956,11 @@ class HashMD {
956
956
  length = 0;
957
957
  pos = 0;
958
958
  destroyed = false;
959
- constructor(blockLen, outputLen, padOffset, isLE2) {
959
+ constructor(blockLen, outputLen, padOffset, isLE) {
960
960
  this.blockLen = blockLen;
961
961
  this.outputLen = outputLen;
962
962
  this.padOffset = padOffset;
963
- this.isLE = isLE2;
963
+ this.isLE = isLE;
964
964
  this.buffer = new Uint8Array(blockLen);
965
965
  this.view = createView(this.buffer);
966
966
  }
@@ -997,7 +997,7 @@ class HashMD {
997
997
  aexists(this);
998
998
  aoutput(out, this);
999
999
  this.finished = true;
1000
- const { buffer, view, blockLen, isLE: isLE2 } = this;
1000
+ const { buffer, view, blockLen, isLE } = this;
1001
1001
  let { pos } = this;
1002
1002
  buffer[pos++] = 128;
1003
1003
  buffer.fill(0, pos);
@@ -1005,7 +1005,7 @@ class HashMD {
1005
1005
  this.process(view, 0);
1006
1006
  buffer.fill(0);
1007
1007
  }
1008
- setU64FromNum(view, blockLen - 8, this.length * 8, isLE2);
1008
+ setU64FromNum(view, blockLen - 8, this.length * 8, isLE);
1009
1009
  this.process(view, 0);
1010
1010
  this.roundClean();
1011
1011
  const oview = out === buffer ? view : createView(out);
@@ -1015,7 +1015,7 @@ class HashMD {
1015
1015
  if (len % 4 || outLen > state.length)
1016
1016
  throw new Error("invalid outputLen");
1017
1017
  for (let i = 0;i < outLen; i++)
1018
- oview.setUint32(4 * i, state[i], isLE2);
1018
+ oview.setUint32(4 * i, state[i], isLE);
1019
1019
  }
1020
1020
  digest() {
1021
1021
  const { buffer, outputLen } = this;
@@ -1468,15 +1468,15 @@ function isWellFormedUnicode(value) {
1468
1468
  }
1469
1469
  return true;
1470
1470
  }
1471
- function nfkd(str2) {
1472
- if (typeof str2 !== "string")
1473
- throw new TypeError("invalid mnemonic type: " + typeof str2);
1474
- if (!isWellFormedUnicode(str2))
1471
+ function nfkd(str) {
1472
+ if (typeof str !== "string")
1473
+ throw new TypeError("invalid mnemonic type: " + typeof str);
1474
+ if (!isWellFormedUnicode(str))
1475
1475
  throw new TypeError("expected well-formed Unicode string");
1476
- return str2.normalize("NFKD");
1476
+ return str.normalize("NFKD");
1477
1477
  }
1478
- function normalize(str2) {
1479
- const norm = nfkd(str2);
1478
+ function normalize(str) {
1479
+ const norm = nfkd(str);
1480
1480
  const words = norm.split(" ");
1481
1481
  if (![12, 15, 18, 21, 24].includes(words.length))
1482
1482
  throw new Error("Invalid mnemonic");
@@ -1503,13 +1503,13 @@ function awordlist(wordlist) {
1503
1503
  }
1504
1504
  function encodeWords(entropy, wordlist) {
1505
1505
  awordlist(wordlist);
1506
- const bytes2 = new Uint8Array(entropy.length + 1);
1507
- bytes2.set(entropy);
1508
- bytes2[entropy.length] = calcChecksum(entropy);
1506
+ const bytes = new Uint8Array(entropy.length + 1);
1507
+ bytes.set(entropy);
1508
+ bytes[entropy.length] = calcChecksum(entropy);
1509
1509
  const words = [];
1510
1510
  let carry = 0;
1511
1511
  let bits = 0;
1512
- for (const byte of bytes2) {
1512
+ for (const byte of bytes) {
1513
1513
  carry = carry << 8 | byte;
1514
1514
  bits += 8;
1515
1515
  if (bits >= 11) {
@@ -1523,7 +1523,7 @@ function encodeWords(entropy, wordlist) {
1523
1523
  function decodeWords(words, wordlist) {
1524
1524
  awordlist(wordlist);
1525
1525
  const entLen = words.length / 3 * 4;
1526
- const bytes2 = new Uint8Array(entLen + 1);
1526
+ const bytes = new Uint8Array(entLen + 1);
1527
1527
  let carry = 0;
1528
1528
  let bits = 0;
1529
1529
  let pos = 0;
@@ -1535,14 +1535,14 @@ function decodeWords(words, wordlist) {
1535
1535
  bits += 11;
1536
1536
  while (bits >= 8) {
1537
1537
  bits -= 8;
1538
- bytes2[pos++] = carry >>> bits & 255;
1538
+ bytes[pos++] = carry >>> bits & 255;
1539
1539
  }
1540
1540
  carry &= (1 << bits) - 1;
1541
1541
  }
1542
1542
  if (bits > 0)
1543
- bytes2[pos] = carry << 8 - bits;
1544
- const entropy = bytes2.subarray(0, entLen);
1545
- if (bytes2[entLen] !== calcChecksum(entropy))
1543
+ bytes[pos] = carry << 8 - bits;
1544
+ const entropy = bytes.subarray(0, entLen);
1545
+ if (bytes[entLen] !== calcChecksum(entropy))
1546
1546
  throw new Error("Invalid checksum");
1547
1547
  return Uint8Array.from(entropy);
1548
1548
  }
@@ -3650,15 +3650,15 @@ function abytes2(b) {
3650
3650
  if (!isBytes2(b))
3651
3651
  throw new TypeError("Uint8Array expected");
3652
3652
  }
3653
- function isArrayOf(isString, arr2) {
3654
- if (!Array.isArray(arr2))
3653
+ function isArrayOf(isString, arr) {
3654
+ if (!Array.isArray(arr))
3655
3655
  return false;
3656
- if (arr2.length === 0)
3656
+ if (arr.length === 0)
3657
3657
  return true;
3658
3658
  if (isString) {
3659
- return arr2.every((item) => typeof item === "string");
3659
+ return arr.every((item) => typeof item === "string");
3660
3660
  } else {
3661
- return arr2.every((item) => Number.isSafeInteger(item));
3661
+ return arr.every((item) => Number.isSafeInteger(item));
3662
3662
  }
3663
3663
  }
3664
3664
  function afn(input) {
@@ -3726,20 +3726,20 @@ function radix2(bits) {
3726
3726
  throw new RangeError("radix2: bits should be in (0..8]");
3727
3727
  const mask = powers[bits] - 1;
3728
3728
  return {
3729
- encode: (bytes2) => {
3730
- abytes2(bytes2);
3731
- const len = bytes2.length;
3729
+ encode: (bytes) => {
3730
+ abytes2(bytes);
3731
+ const len = bytes.length;
3732
3732
  const res = new Uint8Array(Math.ceil(len * 8 / bits));
3733
3733
  let carry = 0;
3734
3734
  let pos = 0;
3735
3735
  let j = 0;
3736
3736
  for (let i = 0;i < len; ) {
3737
3737
  if (i + 2 < len) {
3738
- carry = carry << 24 | bytes2[i] << 16 | bytes2[i + 1] << 8 | bytes2[i + 2];
3738
+ carry = carry << 24 | bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2];
3739
3739
  pos += 24;
3740
3740
  i += 3;
3741
3741
  } else {
3742
- carry = (carry << 8 | bytes2[i]) & 65535;
3742
+ carry = (carry << 8 | bytes[i]) & 65535;
3743
3743
  pos += 8;
3744
3744
  i++;
3745
3745
  }
@@ -3886,10 +3886,10 @@ var hasBase64Builtin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toBase6
3886
3886
  var ASCII_WHITESPACE = /[\t\n\f\r ]/;
3887
3887
  var decodeBase64Builtin = (s, isUrl) => {
3888
3888
  astr("base64", s);
3889
- const alphabet2 = isUrl ? "base64url" : "base64";
3889
+ const alphabet = isUrl ? "base64url" : "base64";
3890
3890
  if (s.length > 0 && ASCII_WHITESPACE.test(s))
3891
3891
  throw new Error("invalid base64");
3892
- return Uint8Array.fromBase64(s, { alphabet: alphabet2, lastChunkHandling: "strict" });
3892
+ return Uint8Array.fromBase64(s, { alphabet, lastChunkHandling: "strict" });
3893
3893
  };
3894
3894
  var base64Fallback = /* @__PURE__ */ freeze(() => chain(radix2(6), alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), padding(6)));
3895
3895
  var base64 = /* @__PURE__ */ freeze(() => hasBase64Builtin ? {
@@ -3907,23 +3907,23 @@ var RADIX_BASE_N_MAX_LENGTH = 65536;
3907
3907
  var BASE_N_MAX_BYTES = 2048;
3908
3908
  var BASE_N_MAX_CHARS = 4096;
3909
3909
  var radixBaseN = (BASE, GROUP) => ({
3910
- encode: (bytes2) => {
3911
- abytes2(bytes2);
3912
- const blen = bytes2.length;
3910
+ encode: (bytes) => {
3911
+ abytes2(bytes);
3912
+ const blen = bytes.length;
3913
3913
  if (blen === 0)
3914
3914
  return new Uint8Array(0);
3915
3915
  if (blen >= RADIX_BASE_N_MAX_LENGTH)
3916
3916
  throw new Error("invalid length");
3917
3917
  let zeros = 0;
3918
- while (zeros < blen - 1 && bytes2[zeros] === 0)
3918
+ while (zeros < blen - 1 && bytes[zeros] === 0)
3919
3919
  zeros++;
3920
3920
  const nlimbs = Math.ceil(blen / 2);
3921
3921
  const limbs = new Uint16Array(nlimbs);
3922
3922
  const odd = blen & 1;
3923
3923
  if (odd)
3924
- limbs[0] = bytes2[0];
3925
- for (let i = odd, j2 = odd;i < blen; i += 2, j2++)
3926
- limbs[j2] = bytes2[i] << 8 | bytes2[i + 1];
3924
+ limbs[0] = bytes[0];
3925
+ for (let i = odd, j = odd;i < blen; i += 2, j++)
3926
+ limbs[j] = bytes[i] << 8 | bytes[i + 1];
3927
3927
  const groups = [];
3928
3928
  let pos = 0;
3929
3929
  while (pos < nlimbs) {
@@ -3974,18 +3974,18 @@ var radixBaseN = (BASE, GROUP) => ({
3974
3974
  let group = dlen % 5 || 5;
3975
3975
  while (i < dlen) {
3976
3976
  let gval = 0;
3977
- let factor2 = 1;
3977
+ let factor = 1;
3978
3978
  for (const end = i + group;i < end; i++) {
3979
3979
  const d = digits[i];
3980
3980
  if (d >= BASE)
3981
3981
  throw new Error(`invalid integer: ${d}`);
3982
3982
  gval = gval * BASE + d;
3983
- factor2 *= BASE;
3983
+ factor *= BASE;
3984
3984
  }
3985
3985
  group = 5;
3986
3986
  let carry = gval;
3987
3987
  for (let k = 0;k < used; k++) {
3988
- const cur = limbs[k] * factor2 + carry;
3988
+ const cur = limbs[k] * factor + carry;
3989
3989
  carry = Math.floor(cur / 65536);
3990
3990
  limbs[k] = cur - carry * 65536;
3991
3991
  }
@@ -4007,26 +4007,26 @@ var radixBaseN = (BASE, GROUP) => ({
4007
4007
  var genBaseN = (radix, abc) => {
4008
4008
  const letters = alphabet(abc);
4009
4009
  return {
4010
- encode(bytes2) {
4011
- abytes2(bytes2);
4012
- if (bytes2.length > BASE_N_MAX_BYTES)
4010
+ encode(bytes) {
4011
+ abytes2(bytes);
4012
+ if (bytes.length > BASE_N_MAX_BYTES)
4013
4013
  throw new Error("invalid length");
4014
- return letters.encode(radix.encode(bytes2));
4014
+ return letters.encode(radix.encode(bytes));
4015
4015
  },
4016
- decode(str2) {
4017
- astr("baseN.decode", str2);
4018
- if (str2.length > BASE_N_MAX_CHARS)
4016
+ decode(str) {
4017
+ astr("baseN.decode", str);
4018
+ if (str.length > BASE_N_MAX_CHARS)
4019
4019
  throw new Error("invalid length");
4020
- return radix.decode(letters.decode(str2));
4020
+ return radix.decode(letters.decode(str));
4021
4021
  }
4022
4022
  };
4023
4023
  };
4024
4024
  var radix58 = /* @__PURE__ */ radixBaseN(58, B58_GROUP);
4025
4025
  var genBase58 = (abc) => genBaseN(radix58, abc);
4026
4026
  var base58 = /* @__PURE__ */ freeze(() => genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"));
4027
- var createBase58check = (sha2562) => {
4028
- afn(sha2562);
4029
- const _sha256 = sha2562;
4027
+ var createBase58check = (sha256) => {
4028
+ afn(sha256);
4029
+ const _sha256 = sha256;
4030
4030
  return chain(checksum(4, (data) => _sha256(_sha256(data))), base58);
4031
4031
  };
4032
4032
  var BECH_ALPHABET = /* @__PURE__ */ alphabet("qpzry9x8gf2tvdw0s3jn54khce6mua7l");
@@ -4132,17 +4132,17 @@ function genBech32(encoding) {
4132
4132
  const sum = bechChecksum(lowered, words, ENCODING_CONST);
4133
4133
  return `${lowered}1${BECH_ALPHABET.encode(wordsToU8(words))}${sum}`;
4134
4134
  }
4135
- function decode(str2, limit = 90) {
4136
- astr("bech32.decode input", str2);
4135
+ function decode(str, limit = 90) {
4136
+ astr("bech32.decode input", str);
4137
4137
  if (limit !== false)
4138
4138
  anumber2(limit, "limit");
4139
- const slen = str2.length;
4139
+ const slen = str.length;
4140
4140
  if (slen < 8 || limit !== false && slen > limit)
4141
4141
  throw new TypeError(`invalid string length ${slen}, expected (8..${limit})`);
4142
- const lowered = str2.toLowerCase();
4143
- if (str2 !== lowered) {
4144
- if (!BECH_UPPERCASE_PRINTABLE.test(str2)) {
4145
- assertBech32Printable("bech32.decode input", str2);
4142
+ const lowered = str.toLowerCase();
4143
+ if (str !== lowered) {
4144
+ if (!BECH_UPPERCASE_PRINTABLE.test(str)) {
4145
+ assertBech32Printable("bech32.decode input", str);
4146
4146
  throw new Error(`mixed-case string not allowed`);
4147
4147
  }
4148
4148
  }
@@ -4157,20 +4157,20 @@ function genBech32(encoding) {
4157
4157
  const words = u8ToNumArr(digits, digits.length - 6);
4158
4158
  const sum = bechChecksum(prefix, words, ENCODING_CONST);
4159
4159
  if (!data.endsWith(sum))
4160
- throw new Error(`Invalid checksum in ${str2}`);
4160
+ throw new Error(`Invalid checksum in ${str}`);
4161
4161
  return { prefix, words };
4162
4162
  }
4163
4163
  const decodeUnsafe = unsafeWrapper(decode);
4164
- function decodeToBytes(str2, limit = 90) {
4165
- const { prefix, words } = decode(str2, limit);
4164
+ function decodeToBytes(str, limit = 90) {
4165
+ const { prefix, words } = decode(str, limit);
4166
4166
  return {
4167
4167
  prefix,
4168
4168
  words,
4169
4169
  bytes: fromWords(words)
4170
4170
  };
4171
4171
  }
4172
- function encodeFromBytes(prefix, bytes2) {
4173
- return encode(prefix, toWords(bytes2));
4172
+ function encodeFromBytes(prefix, bytes) {
4173
+ return encode(prefix, toWords(bytes));
4174
4174
  }
4175
4175
  return {
4176
4176
  encode,
@@ -4352,11 +4352,11 @@ function abytes3(value, length, title = "") {
4352
4352
  return value;
4353
4353
  if (length !== undefined)
4354
4354
  anumber3(length, "length");
4355
- const bytes2 = isBytes3(value);
4355
+ const bytes = isBytes3(value);
4356
4356
  const ofLen = length !== undefined ? ` of length ${length}` : "";
4357
- const got = bytes2 ? `length=${value.length}` : `type=${typeof value}`;
4357
+ const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
4358
4358
  const message = atitle2(title) + "expected Uint8Array" + ofLen + ", got " + got;
4359
- if (!bytes2)
4359
+ if (!bytes)
4360
4360
  throw new TypeError(message);
4361
4361
  throw new RangeError(message);
4362
4362
  }
@@ -4377,26 +4377,26 @@ function aoutput2(out, instance) {
4377
4377
  throw new RangeError('"output" expected length >= ' + min);
4378
4378
  }
4379
4379
  }
4380
- function u322(arr2) {
4381
- return new Uint32Array(arr2.buffer, arr2.byteOffset, Math.floor(arr2.byteLength / 4));
4380
+ function u322(arr) {
4381
+ return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
4382
4382
  }
4383
4383
  function clean2(...arrays) {
4384
4384
  for (let i = 0;i < arrays.length; i++) {
4385
4385
  arrays[i].fill(0);
4386
4386
  }
4387
4387
  }
4388
- function createView2(arr2) {
4389
- return new DataView(arr2.buffer, arr2.byteOffset, arr2.byteLength);
4388
+ function createView2(arr) {
4389
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
4390
4390
  }
4391
4391
  var isLE2 = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
4392
4392
  function byteSwap2(word) {
4393
4393
  return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
4394
4394
  }
4395
- function byteSwap322(arr2) {
4396
- for (let i = 0;i < arr2.length; i++) {
4397
- arr2[i] = byteSwap2(arr2[i]);
4395
+ function byteSwap322(arr) {
4396
+ for (let i = 0;i < arr.length; i++) {
4397
+ arr[i] = byteSwap2(arr[i]);
4398
4398
  }
4399
- return arr2;
4399
+ return arr;
4400
4400
  }
4401
4401
  var swap32IfBE2 = isLE2 ? (u) => u : byteSwap322;
4402
4402
  function overlapBytes(a, b) {
@@ -4489,25 +4489,25 @@ function getOutput(expectedLength, out, onlyAligned = true) {
4489
4489
  throw new Error("invalid output, must be aligned");
4490
4490
  return out;
4491
4491
  }
4492
- function u64Lengths(dataLength, aadLength, isLE3) {
4492
+ function u64Lengths(dataLength, aadLength, isLE) {
4493
4493
  anumber3(dataLength);
4494
4494
  anumber3(aadLength);
4495
- abool(isLE3);
4495
+ abool(isLE);
4496
4496
  const num = new Uint8Array(16);
4497
4497
  const view = createView2(num);
4498
- view.setBigUint64(0, BigInt(aadLength), isLE3);
4499
- view.setBigUint64(8, BigInt(dataLength), isLE3);
4498
+ view.setBigUint64(0, BigInt(aadLength), isLE);
4499
+ view.setBigUint64(8, BigInt(dataLength), isLE);
4500
4500
  return num;
4501
4501
  }
4502
- function isAligned32(bytes2) {
4503
- return bytes2.byteOffset % 4 === 0;
4502
+ function isAligned32(bytes) {
4503
+ return bytes.byteOffset % 4 === 0;
4504
4504
  }
4505
- function copyBytes(bytes2) {
4506
- return Uint8Array.from(abytes3(bytes2));
4505
+ function copyBytes(bytes) {
4506
+ return Uint8Array.from(abytes3(bytes));
4507
4507
  }
4508
4508
 
4509
4509
  // ../../node_modules/.bun/@noble+ciphers@2.4.0/node_modules/@noble/ciphers/_arx.js
4510
- var encodeStr = (str2) => Uint8Array.from(str2.split(""), (c) => c.charCodeAt(0));
4510
+ var encodeStr = (str) => Uint8Array.from(str.split(""), (c) => c.charCodeAt(0));
4511
4511
  var sigma16_32 = /* @__PURE__ */ (() => swap32IfBE2(u322(encodeStr("expand 16-byte k"))))();
4512
4512
  var sigma32_32 = /* @__PURE__ */ (() => swap32IfBE2(u322(encodeStr("expand 32-byte k"))))();
4513
4513
  function rotl2(a, b) {
@@ -5183,27 +5183,27 @@ function assertPasswordPolicy(password) {
5183
5183
  throw new KernelError("invalid-input", "password must be at least 10 characters");
5184
5184
  }
5185
5185
  }
5186
- async function passwordKek(password, salt, pbkdf22) {
5186
+ async function passwordKek(password, salt, pbkdf2) {
5187
5187
  const normalized = decodeUtf8Secret(password).normalize("NFKC");
5188
5188
  const normalizedBytes = utf8ToBytes(normalized);
5189
5189
  try {
5190
- return await pbkdf22("sha256", normalizedBytes, salt, PASSWORD_ITERATIONS2, 32);
5190
+ return await pbkdf2("sha256", normalizedBytes, salt, PASSWORD_ITERATIONS2, 32);
5191
5191
  } finally {
5192
5192
  wipe(normalizedBytes);
5193
5193
  }
5194
5194
  }
5195
- function passkeyKek(prf, credentialId2) {
5195
+ function passkeyKek(prf, credentialId) {
5196
5196
  try {
5197
5197
  if (prf.length !== 32) {
5198
5198
  throw new KernelError("invalid-input", "PRF output must be 32 bytes");
5199
5199
  }
5200
- return hkdf(sha256, prf, credentialId2, utf8ToBytes("qntx-wallet/kek/passkey/v1"), 32);
5200
+ return hkdf(sha256, prf, credentialId, utf8ToBytes("qntx-wallet/kek/passkey/v1"), 32);
5201
5201
  } finally {
5202
5202
  wipe(prf);
5203
5203
  }
5204
5204
  }
5205
- function wrapDek(kek, dek, factor2, random) {
5206
- return dek.use((bytes2) => seal(kek, bytes2, factorContext(factor2.kind, factor2.id), factor2.header, random));
5205
+ function wrapDek(kek, dek, factor, random) {
5206
+ return dek.use((bytes) => seal(kek, bytes, factorContext(factor.kind, factor.id), factor.header, random));
5207
5207
  }
5208
5208
  function unwrapDek(kek, stored) {
5209
5209
  return Secret.take(open(kek, stored.sealed, factorContext(stored.kind, stored.id), stored.header));
@@ -5216,15 +5216,15 @@ var PASSWORD_FACTOR_ITERATIONS = 600000;
5216
5216
  function factorId(random) {
5217
5217
  return bytesToHex(random(16));
5218
5218
  }
5219
- async function newFactorKek(platform, factor2) {
5220
- if (factor2.kind === "password") {
5221
- assertPasswordPolicy(factor2.password);
5219
+ async function newFactorKek(platform, factor) {
5220
+ if (factor.kind === "password") {
5221
+ assertPasswordPolicy(factor.password);
5222
5222
  const salt = platform.random(16);
5223
- const kek2 = await passwordKek(factor2.password, salt, platform.pbkdf2);
5224
- return { kind: "password", kek: kek2, salt };
5223
+ const kek = await passwordKek(factor.password, salt, platform.pbkdf2);
5224
+ return { kind: "password", kek, salt };
5225
5225
  }
5226
- const kek = passkeyKek(factor2.prf, factor2.credentialId);
5227
- return { kind: "passkey", kek, credentialId: factor2.credentialId };
5226
+ const kek = passkeyKek(factor.prf, factor.credentialId);
5227
+ return { kind: "passkey", kek, credentialId: factor.credentialId };
5228
5228
  }
5229
5229
  function factorHeader(material, createdAt) {
5230
5230
  if (material.kind === "password") {
@@ -5239,8 +5239,8 @@ function factorHeader(material, createdAt) {
5239
5239
  createdAt
5240
5240
  });
5241
5241
  }
5242
- async function makeFactor(platform, factor2, dek) {
5243
- const material = await newFactorKek(platform, factor2);
5242
+ async function makeFactor(platform, factor, dek) {
5243
+ const material = await newFactorKek(platform, factor);
5244
5244
  const id = factorId(platform.random);
5245
5245
  const header = factorHeader(material, platform.now());
5246
5246
  try {
@@ -5253,14 +5253,14 @@ async function makeFactor(platform, factor2, dek) {
5253
5253
  }
5254
5254
  }
5255
5255
  }
5256
- async function kekFor(platform, factor2, stored) {
5257
- if (factor2.kind === "password") {
5256
+ async function kekFor(platform, factor, stored) {
5257
+ if (factor.kind === "password") {
5258
5258
  const { salt } = parsePasswordFactorHeader(stored.header);
5259
- return passwordKek(factor2.password, base64urlnopad.decode(salt), platform.pbkdf2);
5259
+ return passwordKek(factor.password, base64urlnopad.decode(salt), platform.pbkdf2);
5260
5260
  }
5261
- return passkeyKek(factor2.prf, factor2.credentialId);
5261
+ return passkeyKek(factor.prf, factor.credentialId);
5262
5262
  }
5263
- async function unlock(platform, image, factor2) {
5263
+ async function unlock(platform, image, factor) {
5264
5264
  const { meta } = image;
5265
5265
  if (meta === undefined) {
5266
5266
  throw new KernelError("invalid-input", "vault is not initialized");
@@ -5270,13 +5270,13 @@ async function unlock(platform, image, factor2) {
5270
5270
  throw new KernelError("rate-limited", "too many wrong passwords", meta.retryAt);
5271
5271
  }
5272
5272
  let dek;
5273
- if (factor2.kind === "password") {
5273
+ if (factor.kind === "password") {
5274
5274
  let lastError;
5275
5275
  for (const stored of image.factors) {
5276
5276
  if (stored.kind !== "password") {
5277
5277
  continue;
5278
5278
  }
5279
- const kek = await kekFor(platform, factor2, stored);
5279
+ const kek = await kekFor(platform, factor, stored);
5280
5280
  try {
5281
5281
  dek = unwrapDek(kek, stored);
5282
5282
  break;
@@ -5306,13 +5306,13 @@ async function unlock(platform, image, factor2) {
5306
5306
  ]);
5307
5307
  }
5308
5308
  } else {
5309
- const wanted = base64urlnopad.encode(factor2.credentialId);
5309
+ const wanted = base64urlnopad.encode(factor.credentialId);
5310
5310
  const stored = image.factors.find((f) => f.kind === "passkey" && credentialIdOf(f) === wanted);
5311
5311
  if (stored === undefined) {
5312
- wipe(factor2.prf);
5312
+ wipe(factor.prf);
5313
5313
  throw new KernelError("integrity", "no passkey factor matches the credential");
5314
5314
  }
5315
- const kek = await kekFor(platform, factor2, stored);
5315
+ const kek = await kekFor(platform, factor, stored);
5316
5316
  try {
5317
5317
  dek = unwrapDek(kek, stored);
5318
5318
  } finally {
@@ -5341,7 +5341,7 @@ function authenticateRecords(dek, records) {
5341
5341
  const opened = [];
5342
5342
  try {
5343
5343
  for (const record of records) {
5344
- const plaintext = dek.use((bytes2) => open(bytes2, record.sealed, recordContext(record.kind, record.id), record.header));
5344
+ const plaintext = dek.use((bytes) => open(bytes, record.sealed, recordContext(record.kind, record.id), record.header));
5345
5345
  opened.push({ kind: record.kind, id: record.id, plaintext });
5346
5346
  }
5347
5347
  return opened;
@@ -5352,16 +5352,16 @@ function authenticateRecords(dek, records) {
5352
5352
  throw error;
5353
5353
  }
5354
5354
  }
5355
- async function verifyFactor(platform, image, factor2, dek) {
5355
+ async function verifyFactor(platform, image, factor, dek) {
5356
5356
  const candidates = image.factors.filter((stored) => {
5357
- if (factor2.kind !== stored.kind) {
5357
+ if (factor.kind !== stored.kind) {
5358
5358
  return false;
5359
5359
  }
5360
- return factor2.kind === "password" || credentialIdOf(stored) === base64urlnopad.encode(factor2.credentialId);
5360
+ return factor.kind === "password" || credentialIdOf(stored) === base64urlnopad.encode(factor.credentialId);
5361
5361
  });
5362
5362
  let sawPasswordFactor = false;
5363
5363
  for (const stored of candidates) {
5364
- const kek = await kekFor(platform, factor2, stored);
5364
+ const kek = await kekFor(platform, factor, stored);
5365
5365
  try {
5366
5366
  const opened = unwrapDek(kek, stored);
5367
5367
  try {
@@ -5382,17 +5382,17 @@ async function verifyFactor(platform, image, factor2, dek) {
5382
5382
  wipe(kek);
5383
5383
  }
5384
5384
  }
5385
- if (factor2.kind === "password") {
5385
+ if (factor.kind === "password") {
5386
5386
  throw new KernelError(sawPasswordFactor ? "wrong-password" : "invalid-input", "password did not verify");
5387
5387
  }
5388
5388
  throw new KernelError("integrity", "factor did not verify");
5389
5389
  }
5390
5390
  function sealRecord(platform, dek, kind, id, header, plaintext) {
5391
- const sealed = dek.use((bytes2) => seal(bytes2, plaintext, recordContext(kind, id), header, platform.random));
5391
+ const sealed = dek.use((bytes) => seal(bytes, plaintext, recordContext(kind, id), header, platform.random));
5392
5392
  return { kind, id, header, sealed };
5393
5393
  }
5394
5394
  function openRecord(dek, record) {
5395
- return dek.use((bytes2) => open(bytes2, record.sealed, recordContext(record.kind, record.id), record.header));
5395
+ return dek.use((bytes) => open(bytes, record.sealed, recordContext(record.kind, record.id), record.header));
5396
5396
  }
5397
5397
  function findRecord(image, kind, id) {
5398
5398
  const record = image.records.find((r) => r.kind === kind && r.id === id);
@@ -5401,12 +5401,12 @@ function findRecord(image, kind, id) {
5401
5401
  }
5402
5402
  return record;
5403
5403
  }
5404
- function establishOps(factor2, records) {
5404
+ function establishOps(factor, records) {
5405
5405
  const meta = { format: 1, failedAttempts: 0, retryAt: 0 };
5406
5406
  return [
5407
5407
  { op: "expect-uninitialized" },
5408
5408
  { op: "put-meta", meta },
5409
- { op: "put-factor", factor: factor2 },
5409
+ { op: "put-factor", factor },
5410
5410
  ...records.map((record) => ({ op: "put-record", record }))
5411
5411
  ];
5412
5412
  }
@@ -5586,11 +5586,11 @@ function hexToNumber(hex) {
5586
5586
  throw new TypeError("hex string expected, got " + typeof hex);
5587
5587
  return hex === "" ? _0n : BigInt("0x" + hex);
5588
5588
  }
5589
- function bytesToNumberBE(bytes2) {
5590
- return hexToNumber(bytesToHex(bytes2));
5589
+ function bytesToNumberBE(bytes) {
5590
+ return hexToNumber(bytesToHex(bytes));
5591
5591
  }
5592
- function bytesToNumberLE(bytes2) {
5593
- return hexToNumber(bytesToHex(copyBytes2(abytes(bytes2)).reverse()));
5592
+ function bytesToNumberLE(bytes) {
5593
+ return hexToNumber(bytesToHex(copyBytes2(abytes(bytes)).reverse()));
5594
5594
  }
5595
5595
  function numberToBytesBE(n, len) {
5596
5596
  anumber(len);
@@ -5606,8 +5606,8 @@ function numberToBytesBE(n, len) {
5606
5606
  function numberToBytesLE(n, len) {
5607
5607
  return numberToBytesBE(n, len).reverse();
5608
5608
  }
5609
- function copyBytes2(bytes2) {
5610
- return Uint8Array.from(abytes4(bytes2));
5609
+ function copyBytes2(bytes) {
5610
+ return Uint8Array.from(abytes4(bytes));
5611
5611
  }
5612
5612
  function asciiToBytes(ascii) {
5613
5613
  if (typeof ascii !== "string")
@@ -5746,14 +5746,14 @@ function pow(num, power, modulo) {
5746
5746
  if (d < _0n2)
5747
5747
  d += modulo;
5748
5748
  if (power < POW_WINDOWED_MIN) {
5749
- let p2 = _1n2;
5749
+ let p = _1n2;
5750
5750
  while (power > _0n2) {
5751
5751
  if (power & _1n2)
5752
- p2 = p2 * d % modulo;
5752
+ p = p * d % modulo;
5753
5753
  d = d * d % modulo;
5754
5754
  power >>= _1n2;
5755
5755
  }
5756
- return p2;
5756
+ return p;
5757
5757
  }
5758
5758
  const digits = [];
5759
5759
  while (power > _0n2) {
@@ -6112,20 +6112,20 @@ class _Field {
6112
6112
  toBytes(num) {
6113
6113
  return this.isLE ? numberToBytesLE(num, this.BYTES) : numberToBytesBE(num, this.BYTES);
6114
6114
  }
6115
- fromBytes(bytes2, skipValidation = false) {
6116
- abytes4(bytes2);
6117
- const { _lengths: allowedLengths, BYTES, isLE: isLE3, ORDER, _mod: modFromBytes } = this;
6115
+ fromBytes(bytes, skipValidation = false) {
6116
+ abytes4(bytes);
6117
+ const { _lengths: allowedLengths, BYTES, isLE, ORDER, _mod: modFromBytes } = this;
6118
6118
  if (allowedLengths) {
6119
- if (bytes2.length < 1 || !allowedLengths.includes(bytes2.length) || bytes2.length > BYTES) {
6120
- throw new Error("Field.fromBytes: expected " + allowedLengths + " bytes, got " + bytes2.length);
6119
+ if (bytes.length < 1 || !allowedLengths.includes(bytes.length) || bytes.length > BYTES) {
6120
+ throw new Error("Field.fromBytes: expected " + allowedLengths + " bytes, got " + bytes.length);
6121
6121
  }
6122
6122
  const padded = new Uint8Array(BYTES);
6123
- padded.set(bytes2, isLE3 ? 0 : padded.length - bytes2.length);
6124
- bytes2 = padded;
6123
+ padded.set(bytes, isLE ? 0 : padded.length - bytes.length);
6124
+ bytes = padded;
6125
6125
  }
6126
- if (bytes2.length !== BYTES)
6127
- throw new Error("Field.fromBytes: expected " + BYTES + " bytes, got " + bytes2.length);
6128
- let scalar = isLE3 ? bytesToNumberLE(bytes2) : bytesToNumberBE(bytes2);
6126
+ if (bytes.length !== BYTES)
6127
+ throw new Error("Field.fromBytes: expected " + BYTES + " bytes, got " + bytes.length);
6128
+ let scalar = isLE ? bytesToNumberLE(bytes) : bytesToNumberBE(bytes);
6129
6129
  if (modFromBytes)
6130
6130
  scalar = mod(scalar, ORDER);
6131
6131
  if (!skipValidation) {
@@ -6158,16 +6158,16 @@ function getMinHashLength(fieldOrder) {
6158
6158
  const length = getFieldBytesLength(fieldOrder);
6159
6159
  return length + Math.ceil(length / 2);
6160
6160
  }
6161
- function mapHashToField(key, fieldOrder, isLE3 = false) {
6161
+ function mapHashToField(key, fieldOrder, isLE = false) {
6162
6162
  abytes4(key);
6163
6163
  const len = key.length;
6164
6164
  const fieldLen = getFieldBytesLength(fieldOrder);
6165
6165
  const minLen = Math.max(getMinHashLength(fieldOrder), 16);
6166
6166
  if (len < minLen || len > 1024)
6167
6167
  throw new Error("expected " + minLen + "-1024 bytes of input, got " + len);
6168
- const num = isLE3 ? bytesToNumberLE(key) : bytesToNumberBE(key);
6168
+ const num = isLE ? bytesToNumberLE(key) : bytesToNumberBE(key);
6169
6169
  const reduced = mod(num, fieldOrder - _1n2) + _1n2;
6170
- return isLE3 ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
6170
+ return isLE ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
6171
6171
  }
6172
6172
 
6173
6173
  // ../../node_modules/.bun/@noble+curves@2.4.0/node_modules/@noble/curves/abstract/curve.js
@@ -6202,22 +6202,22 @@ function validateW(W, bits, min = 1) {
6202
6202
  throw new Error("invalid window size, expected [" + min + ".." + bits + "], got W=" + W);
6203
6203
  }
6204
6204
  function validateTableBytes(numPoints, fpBytes) {
6205
- const bytes2 = numPoints * (4 * fpBytes + 128);
6206
- if (bytes2 > TABLE_BYTES_MAX)
6207
- throw new Error("invalid window size: table would need ~" + Math.ceil(bytes2 / 2 ** 20) + " MiB, max " + TABLE_BYTES_MAX / 2 ** 20 + " MiB");
6205
+ const bytes = numPoints * (4 * fpBytes + 128);
6206
+ if (bytes > TABLE_BYTES_MAX)
6207
+ throw new Error("invalid window size: table would need ~" + Math.ceil(bytes / 2 ** 20) + " MiB, max " + TABLE_BYTES_MAX / 2 ** 20 + " MiB");
6208
6208
  }
6209
- function probeRandomBytes(randomBytes4, length) {
6210
- if (randomBytes4 === undefined)
6209
+ function probeRandomBytes(randomBytes, length) {
6210
+ if (randomBytes === undefined)
6211
6211
  return;
6212
- afunction(randomBytes4, "randomBytes");
6212
+ afunction(randomBytes, "randomBytes");
6213
6213
  try {
6214
- const probe = randomBytes4(length);
6214
+ const probe = randomBytes(length);
6215
6215
  if (!isBytes4(probe) || probe.length !== length)
6216
6216
  return;
6217
6217
  } catch {
6218
6218
  return;
6219
6219
  }
6220
- return randomBytes4;
6220
+ return randomBytes;
6221
6221
  }
6222
6222
  function validateMSMPoints(points, c) {
6223
6223
  aarray(points, "points");
@@ -6310,9 +6310,9 @@ class ScalarMultiplier {
6310
6310
  wnafPrecomputes = new WeakMap;
6311
6311
  baseCanBeBlinded;
6312
6312
  bits;
6313
- constructor(Point, randomBytes4) {
6313
+ constructor(Point, randomBytes) {
6314
6314
  validatePointCons(Point);
6315
- this.randomBytes = probeRandomBytes(randomBytes4, BLIND_BYTES);
6315
+ this.randomBytes = probeRandomBytes(randomBytes, BLIND_BYTES);
6316
6316
  this.Point = Point;
6317
6317
  this.BASE = Point.BASE;
6318
6318
  this.ZERO = Point.ZERO;
@@ -6469,14 +6469,14 @@ function mulAddUnsafe(c, points, scalars, allowOversized = false) {
6469
6469
  const digits = scalars.map((n) => wnafDigits(n, 4));
6470
6470
  return wnafWalk(c.ZERO, tables, digits);
6471
6471
  }
6472
- function createField(order, field, isLE3) {
6472
+ function createField(order, field, isLE) {
6473
6473
  if (field) {
6474
6474
  if (field.ORDER !== order)
6475
6475
  throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
6476
6476
  validateField(field);
6477
6477
  return field;
6478
6478
  } else {
6479
- return Field(order, { isLE: isLE3 });
6479
+ return Field(order, { isLE });
6480
6480
  }
6481
6481
  }
6482
6482
  function createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) {
@@ -6598,14 +6598,14 @@ var _DER = {
6598
6598
  return bytesToNumberBE(data);
6599
6599
  }
6600
6600
  },
6601
- toSig(bytes2, maxScalarBytes) {
6602
- const { Err: E, _int: int2, _tlv: tlv } = _DER;
6601
+ toSig(bytes, maxScalarBytes) {
6602
+ const { Err: E, _int: int, _tlv: tlv } = _DER;
6603
6603
  if (maxScalarBytes !== undefined) {
6604
6604
  asafenumber(maxScalarBytes, "maxScalarBytes");
6605
6605
  if (maxScalarBytes < 1)
6606
6606
  throw new E("invalid signature: maxScalarBytes must be positive");
6607
6607
  }
6608
- const data = abytes4(bytes2, undefined, "signature");
6608
+ const data = abytes4(bytes, undefined, "signature");
6609
6609
  const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
6610
6610
  if (seqLeftBytes.length)
6611
6611
  throw new E("invalid signature: left bytes after parsing");
@@ -6615,13 +6615,13 @@ var _DER = {
6615
6615
  throw new E("invalid signature: left bytes after parsing");
6616
6616
  if (maxScalarBytes !== undefined && (rBytes.length > maxScalarBytes || sBytes.length > maxScalarBytes))
6617
6617
  throw new E("invalid signature: integer too large");
6618
- return { r: int2.decode(rBytes), s: int2.decode(sBytes) };
6618
+ return { r: int.decode(rBytes), s: int.decode(sBytes) };
6619
6619
  },
6620
6620
  hexFromSig(sig) {
6621
- const { _tlv: tlv, _int: int2 } = _DER;
6621
+ const { _tlv: tlv, _int: int } = _DER;
6622
6622
  validateObject(sig, { r: "bigint", s: "bigint" }, {}, "sig");
6623
- const rs = tlv.encode(2, int2.encode(sig.r));
6624
- const ss = tlv.encode(2, int2.encode(sig.s));
6623
+ const rs = tlv.encode(2, int.encode(sig.r));
6624
+ const ss = tlv.encode(2, int.encode(sig.s));
6625
6625
  const seq = rs + ss;
6626
6626
  return tlv.encode(48, seq);
6627
6627
  }
@@ -6692,7 +6692,7 @@ function weierstrass(params, extraOpts = {}) {
6692
6692
  randomBytes: "function"
6693
6693
  });
6694
6694
  const { endo: endoOpts, allowInfinityPoint, clearCofactor, isTorsionFree, fromBytes, toBytes } = extraOpts;
6695
- const randomBytes4 = extraOpts.randomBytes === undefined ? randomBytes3 : extraOpts.randomBytes;
6695
+ const randomBytes = extraOpts.randomBytes === undefined ? randomBytes3 : extraOpts.randomBytes;
6696
6696
  if (endoOpts) {
6697
6697
  if (!Fp.is0(CURVE.a) || typeof endoOpts.beta !== "bigint" || !Array.isArray(endoOpts.basises)) {
6698
6698
  throw new Error('invalid endo: expected "beta": bigint and "basises": array');
@@ -6724,12 +6724,12 @@ function weierstrass(params, extraOpts = {}) {
6724
6724
  return concatBytes2(Uint8Array.of(4), bx, Fp.toBytes(y));
6725
6725
  }
6726
6726
  }
6727
- function pointFromBytes(bytes2) {
6728
- abytes4(bytes2, undefined, "Point");
6727
+ function pointFromBytes(bytes) {
6728
+ abytes4(bytes, undefined, "Point");
6729
6729
  const { publicKey: comp, publicKeyUncompressed: uncomp } = lengths;
6730
- const length = bytes2.length;
6731
- const head = bytes2[0];
6732
- const tail = bytes2.subarray(1);
6730
+ const length = bytes.length;
6731
+ const head = bytes[0];
6732
+ const tail = bytes.subarray(1);
6733
6733
  if (allowInfinityPoint && length === 1 && head === 0)
6734
6734
  return { x: Fp.ZERO, y: Fp.ZERO };
6735
6735
  if (length === comp && (head === 2 || head === 3)) {
@@ -6837,8 +6837,8 @@ function weierstrass(params, extraOpts = {}) {
6837
6837
  return Point.ZERO;
6838
6838
  return new Point(x, y, Fp.ONE);
6839
6839
  }
6840
- static fromBytes(bytes2) {
6841
- const P = Point.fromAffine(decodePoint(abytes4(bytes2, undefined, "point")));
6840
+ static fromBytes(bytes) {
6841
+ const P = Point.fromAffine(decodePoint(abytes4(bytes, undefined, "point")));
6842
6842
  P.assertValidity();
6843
6843
  return P;
6844
6844
  }
@@ -6985,8 +6985,8 @@ function weierstrass(params, extraOpts = {}) {
6985
6985
  multiply(scalar) {
6986
6986
  if (!Fn.isValidNot0(scalar))
6987
6987
  throw new RangeError("invalid scalar: out of range");
6988
- const { p, f } = wnaf.mulSecret(this, scalar, cofactor, normalize2);
6989
- return normalize2([p, f])[0];
6988
+ const { p, f } = wnaf.mulSecret(this, scalar, cofactor, normalize);
6989
+ return normalize([p, f])[0];
6990
6990
  }
6991
6991
  multiplyUnsafe(scalar) {
6992
6992
  const p = this;
@@ -6998,7 +6998,7 @@ function weierstrass(params, extraOpts = {}) {
6998
6998
  if (sc === _1n4)
6999
6999
  return p;
7000
7000
  if (wnaf.hasWindowSize(this))
7001
- return wnaf.mulUnsafe(p, sc, normalize2);
7001
+ return wnaf.mulUnsafe(p, sc, normalize);
7002
7002
  const points = [];
7003
7003
  const scalars = [];
7004
7004
  pushWnafPair(points, scalars, p, sc);
@@ -7063,8 +7063,8 @@ function weierstrass(params, extraOpts = {}) {
7063
7063
  return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
7064
7064
  }
7065
7065
  }
7066
- const normalize2 = (points) => normalizeZ(Point, points);
7067
- const wnaf = new ScalarMultiplier(Point, randomBytes4);
7066
+ const normalize = (points) => normalizeZ(Point, points);
7067
+ const wnaf = new ScalarMultiplier(Point, randomBytes);
7068
7068
  if (wnaf.bits >= 6)
7069
7069
  Point.BASE.precompute(6);
7070
7070
  Object.freeze(Point.prototype);
@@ -7098,15 +7098,15 @@ function ecdh(Point, ecdhOpts = {}) {
7098
7098
  return false;
7099
7099
  }
7100
7100
  }
7101
- function isValidPublicKey(publicKey2, isCompressed) {
7101
+ function isValidPublicKey(publicKey, isCompressed) {
7102
7102
  const { publicKey: comp, publicKeyUncompressed } = lengths;
7103
7103
  try {
7104
- const l = publicKey2.length;
7104
+ const l = publicKey.length;
7105
7105
  if (isCompressed === true && l !== comp)
7106
7106
  return false;
7107
7107
  if (isCompressed === false && l !== publicKeyUncompressed)
7108
7108
  return false;
7109
- return !Point.fromBytes(publicKey2).is0();
7109
+ return !Point.fromBytes(publicKey).is0();
7110
7110
  } catch (error) {
7111
7111
  return false;
7112
7112
  }
@@ -7119,12 +7119,12 @@ function ecdh(Point, ecdhOpts = {}) {
7119
7119
  return Point.BASE.multiply(Fn.fromBytes(secretKey)).toBytes(isCompressed);
7120
7120
  }
7121
7121
  function isProbPub(item) {
7122
- const { secretKey, publicKey: publicKey2, publicKeyUncompressed } = lengths;
7122
+ const { secretKey, publicKey, publicKeyUncompressed } = lengths;
7123
7123
  const allowedLengths = Fn._lengths;
7124
7124
  if (!isBytes4(item))
7125
7125
  return;
7126
7126
  const l = abytes4(item, undefined, "key").length;
7127
- const isPub = l === publicKey2 || l === publicKeyUncompressed;
7127
+ const isPub = l === publicKey || l === publicKeyUncompressed;
7128
7128
  const isSec = l === secretKey || !!allowedLengths?.includes(l);
7129
7129
  if (isPub && isSec)
7130
7130
  return;
@@ -7163,12 +7163,12 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
7163
7163
  bits2int_modN: "function"
7164
7164
  });
7165
7165
  const opts = Object.assign({}, ecdsaOpts);
7166
- const randomBytes4 = opts.randomBytes === undefined ? randomBytes3 : opts.randomBytes;
7166
+ const randomBytes = opts.randomBytes === undefined ? randomBytes3 : opts.randomBytes;
7167
7167
  const hmac2 = opts.hmac === undefined ? (key, msg) => hmac(hash_, key, msg) : opts.hmac;
7168
7168
  const { Fp, Fn } = Point;
7169
7169
  const { ORDER: CURVE_ORDER, BITS: fnBits } = Fn;
7170
7170
  const blindLength = getMinHashLength(CURVE_ORDER);
7171
- const csprng = probeRandomBytes(randomBytes4, blindLength);
7171
+ const csprng = probeRandomBytes(randomBytes, blindLength);
7172
7172
  const { keygen, getPublicKey, getSharedSecret, utils, lengths } = ecdh(Point, opts);
7173
7173
  const defaultSigOpts = {
7174
7174
  prehash: true,
@@ -7198,11 +7198,11 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
7198
7198
  if (hasLargeRecoveryLifts)
7199
7199
  throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
7200
7200
  }
7201
- function validateSigLength(bytes2, format) {
7201
+ function validateSigLength(bytes, format) {
7202
7202
  validateSigFormat(format);
7203
7203
  const size = lengths.signature;
7204
7204
  const sizer = format === "compact" ? size : format === "recovered" ? size + 1 : undefined;
7205
- return abytes4(bytes2, sizer);
7205
+ return abytes4(bytes, sizer);
7206
7206
  }
7207
7207
 
7208
7208
  class Signature {
@@ -7220,23 +7220,23 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
7220
7220
  }
7221
7221
  Object.freeze(this);
7222
7222
  }
7223
- static fromBytes(bytes2, format = defaultSigOpts.format) {
7224
- validateSigLength(bytes2, format);
7223
+ static fromBytes(bytes, format = defaultSigOpts.format) {
7224
+ validateSigLength(bytes, format);
7225
7225
  let recid;
7226
7226
  if (format === "der") {
7227
- if (bytes2.length > 2 * Fn.BYTES + 16)
7227
+ if (bytes.length > 2 * Fn.BYTES + 16)
7228
7228
  throw new DER.Err("invalid signature: DER signature too long");
7229
- const { r: r2, s: s2 } = DER.toSig(abytes4(bytes2), Fn.BYTES + 1);
7230
- return new Signature(r2, s2);
7229
+ const { r, s } = DER.toSig(abytes4(bytes), Fn.BYTES + 1);
7230
+ return new Signature(r, s);
7231
7231
  }
7232
7232
  if (format === "recovered") {
7233
- recid = bytes2[0];
7233
+ recid = bytes[0];
7234
7234
  format = "compact";
7235
- bytes2 = bytes2.subarray(1);
7235
+ bytes = bytes.subarray(1);
7236
7236
  }
7237
7237
  const L = lengths.signature / 2;
7238
- const r = bytes2.subarray(0, L);
7239
- const s = bytes2.subarray(L, L * 2);
7238
+ const r = bytes.subarray(0, L);
7239
+ const s = bytes.subarray(L, L * 2);
7240
7240
  return new Signature(Fn.fromBytes(r), Fn.fromBytes(s), recid);
7241
7241
  }
7242
7242
  static fromHex(hex, format) {
@@ -7291,15 +7291,15 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
7291
7291
  }
7292
7292
  Object.freeze(Signature.prototype);
7293
7293
  Object.freeze(Signature);
7294
- const bits2int = opts.bits2int === undefined ? function bits2int_def(bytes2) {
7295
- if (bytes2.length > 8192)
7294
+ const bits2int = opts.bits2int === undefined ? function bits2int_def(bytes) {
7295
+ if (bytes.length > 8192)
7296
7296
  throw new Error("input is too large");
7297
- const num = bytesToNumberBE(bytes2);
7298
- const delta = bytes2.length * 8 - fnBits;
7297
+ const num = bytesToNumberBE(bytes);
7298
+ const delta = bytes.length * 8 - fnBits;
7299
7299
  return delta > 0 ? num >> BigInt(delta) : num;
7300
7300
  } : opts.bits2int;
7301
- const bits2int_modN = opts.bits2int_modN === undefined ? function bits2int_modN_def(bytes2) {
7302
- return Fn.create(bits2int(bytes2));
7301
+ const bits2int_modN = opts.bits2int_modN === undefined ? function bits2int_modN_def(bytes) {
7302
+ return Fn.create(bits2int(bytes));
7303
7303
  } : opts.bits2int_modN;
7304
7304
  const ORDER_MASK = bitMask(fnBits);
7305
7305
  function int2octets(num) {
@@ -7310,8 +7310,8 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
7310
7310
  abytes4(message, undefined, "message");
7311
7311
  return prehash ? abytes4(hash_(message), undefined, "prehashed message") : message;
7312
7312
  }
7313
- function prepSig(message, secretKey, opts2) {
7314
- const { lowS, prehash, extraEntropy } = validateSigOpts(opts2, defaultSigOpts);
7313
+ function prepSig(message, secretKey, opts) {
7314
+ const { lowS, prehash, extraEntropy } = validateSigOpts(opts, defaultSigOpts);
7315
7315
  message = validateMsgAndHash(message, prehash);
7316
7316
  const h1int = bits2int_modN(message);
7317
7317
  const d = Fn.fromBytes(secretKey);
@@ -7319,7 +7319,7 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
7319
7319
  throw new Error("invalid private key");
7320
7320
  const seedArgs = [int2octets(d), int2octets(h1int)];
7321
7321
  if (extraEntropy != null && extraEntropy !== false) {
7322
- const e = extraEntropy === true ? randomBytes4(lengths.secretKey) : extraEntropy;
7322
+ const e = extraEntropy === true ? randomBytes(lengths.secretKey) : extraEntropy;
7323
7323
  seedArgs.push(abytes4(e, undefined, "extraEntropy"));
7324
7324
  }
7325
7325
  const seed = concatBytes2(...seedArgs);
@@ -7355,15 +7355,15 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
7355
7355
  }
7356
7356
  return { seed, k2sig };
7357
7357
  }
7358
- function sign(message, secretKey, opts2 = {}) {
7359
- const { seed, k2sig } = prepSig(message, secretKey, opts2);
7358
+ function sign(message, secretKey, opts = {}) {
7359
+ const { seed, k2sig } = prepSig(message, secretKey, opts);
7360
7360
  const drbg = createHmacDrbg(hash_.outputLen, Fn.BYTES, hmac2);
7361
7361
  const sig = drbg(seed, k2sig);
7362
- return sig.toBytes(opts2.format);
7362
+ return sig.toBytes(opts.format);
7363
7363
  }
7364
- function verify(signature, message, publicKey2, opts2 = {}) {
7365
- const { lowS, prehash, format } = validateSigOpts(opts2, defaultSigOpts);
7366
- publicKey2 = abytes4(publicKey2, undefined, "publicKey");
7364
+ function verify(signature, message, publicKey, opts = {}) {
7365
+ const { lowS, prehash, format } = validateSigOpts(opts, defaultSigOpts);
7366
+ publicKey = abytes4(publicKey, undefined, "publicKey");
7367
7367
  message = validateMsgAndHash(message, prehash);
7368
7368
  if (!isBytes4(signature)) {
7369
7369
  const end = signature instanceof Signature ? ", use sig.toBytes()" : "";
@@ -7372,7 +7372,7 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
7372
7372
  validateSigLength(signature, format);
7373
7373
  try {
7374
7374
  const sig = Signature.fromBytes(signature, format);
7375
- const P = Point.fromBytes(publicKey2);
7375
+ const P = Point.fromBytes(publicKey);
7376
7376
  if (P.is0())
7377
7377
  return false;
7378
7378
  if (lowS && sig.hasHighS())
@@ -7396,8 +7396,8 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
7396
7396
  return false;
7397
7397
  }
7398
7398
  }
7399
- function recoverPublicKey(signature, message, opts2 = {}) {
7400
- const { prehash } = validateSigOpts(opts2, defaultSigOpts);
7399
+ function recoverPublicKey(signature, message, opts = {}) {
7400
+ const { prehash } = validateSigOpts(opts, defaultSigOpts);
7401
7401
  message = validateMsgAndHash(message, prehash);
7402
7402
  return Signature.fromBytes(signature, "recovered").recoverPublicKey(message).toBytes();
7403
7403
  }
@@ -7438,19 +7438,19 @@ var _0n6 = /* @__PURE__ */ BigInt(0);
7438
7438
  var _2n3 = /* @__PURE__ */ BigInt(2);
7439
7439
  function sqrtMod(y) {
7440
7440
  const P = secp256k1_CURVE.p;
7441
- const _3n3 = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);
7441
+ const _3n = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);
7442
7442
  const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);
7443
7443
  const b2 = y * y * y % P;
7444
7444
  const b3 = b2 * b2 * y % P;
7445
- const b6 = pow2(b3, _3n3, P) * b3 % P;
7446
- const b9 = pow2(b6, _3n3, P) * b3 % P;
7445
+ const b6 = pow2(b3, _3n, P) * b3 % P;
7446
+ const b9 = pow2(b6, _3n, P) * b3 % P;
7447
7447
  const b11 = pow2(b9, _2n3, P) * b2 % P;
7448
7448
  const b22 = pow2(b11, _11n, P) * b11 % P;
7449
7449
  const b44 = pow2(b22, _22n, P) * b22 % P;
7450
7450
  const b88 = pow2(b44, _44n, P) * b44 % P;
7451
7451
  const b176 = pow2(b88, _88n, P) * b88 % P;
7452
7452
  const b220 = pow2(b176, _44n, P) * b44 % P;
7453
- const b223 = pow2(b220, _3n3, P) * b3 % P;
7453
+ const b223 = pow2(b220, _3n, P) * b3 % P;
7454
7454
  const t1 = pow2(b223, _23n, P) * b22 % P;
7455
7455
  const t2 = pow2(t1, _6n, P) * b2 % P;
7456
7456
  const root = pow2(t2, _2n3, P);
@@ -7527,11 +7527,11 @@ function schnorrSign(message, secretKey, auxRand = randomBytes(32)) {
7527
7527
  throw new Error("sign: Invalid signature produced");
7528
7528
  return sig;
7529
7529
  }
7530
- function schnorrVerify(signature, message, publicKey2) {
7530
+ function schnorrVerify(signature, message, publicKey) {
7531
7531
  const { Fp, Fn, BASE } = Pointk1;
7532
7532
  const sig = abytes4(signature, 64, "signature");
7533
7533
  const m = abytes4(message, undefined, "message");
7534
- const pub = abytes4(publicKey2, 32, "publicKey");
7534
+ const pub = abytes4(publicKey, 32, "publicKey");
7535
7535
  try {
7536
7536
  const P = lift_x(num(pub));
7537
7537
  const rBytes = sig.subarray(0, 32);
@@ -7787,7 +7787,7 @@ class HDKey {
7787
7787
  }
7788
7788
  const keyView = createView(keyBuffer);
7789
7789
  const version = keyView.getUint32(0, false);
7790
- const opt2 = {
7790
+ const opt = {
7791
7791
  versions,
7792
7792
  depth: keyBuffer[4],
7793
7793
  parentFingerprint: keyView.getUint32(5, false),
@@ -7800,9 +7800,9 @@ class HDKey {
7800
7800
  throw new Error("Version mismatch");
7801
7801
  }
7802
7802
  if (isPriv) {
7803
- return new HDKey({ ...opt2, privateKey: key.slice(1) });
7803
+ return new HDKey({ ...opt, privateKey: key.slice(1) });
7804
7804
  } else {
7805
- return new HDKey({ ...opt2, publicKey: key });
7805
+ return new HDKey({ ...opt, publicKey: key });
7806
7806
  }
7807
7807
  }
7808
7808
  static fromJSON(json) {
@@ -7816,13 +7816,13 @@ class HDKey {
7816
7816
  _privateKey;
7817
7817
  _publicKey;
7818
7818
  _pubHash;
7819
- constructor(opt2) {
7820
- if (!opt2 || typeof opt2 !== "object") {
7819
+ constructor(opt) {
7820
+ if (!opt || typeof opt !== "object") {
7821
7821
  throw new Error("HDKey.constructor must not be called directly");
7822
7822
  }
7823
- const depth = opt2.depth ?? 0;
7824
- const index = opt2.index ?? 0;
7825
- const parentFingerprint = opt2.parentFingerprint ?? 0;
7823
+ const depth = opt.depth ?? 0;
7824
+ const index = opt.index ?? 0;
7825
+ const parentFingerprint = opt.parentFingerprint ?? 0;
7826
7826
  if (!Number.isSafeInteger(depth) || depth < 0 || depth > MAX_DEPTH) {
7827
7827
  throw new RangeError("HDKey: depth must be an integer in range 0..255");
7828
7828
  }
@@ -7831,23 +7831,23 @@ class HDKey {
7831
7831
  if (depth === 0 && (index !== 0 || parentFingerprint !== 0)) {
7832
7832
  throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");
7833
7833
  }
7834
- this.versions = opt2.versions ? validateVersions(opt2.versions) : BITCOIN_VERSIONS;
7834
+ this.versions = opt.versions ? validateVersions(opt.versions) : BITCOIN_VERSIONS;
7835
7835
  this.depth = depth;
7836
- if (opt2.chainCode)
7837
- abytes(opt2.chainCode, 32);
7838
- this._chainCode = opt2.chainCode ? Uint8Array.from(opt2.chainCode) : null;
7836
+ if (opt.chainCode)
7837
+ abytes(opt.chainCode, 32);
7838
+ this._chainCode = opt.chainCode ? Uint8Array.from(opt.chainCode) : null;
7839
7839
  this.index = index;
7840
7840
  this.parentFingerprint = parentFingerprint;
7841
- if (opt2.publicKey && opt2.privateKey) {
7841
+ if (opt.publicKey && opt.privateKey) {
7842
7842
  throw new Error("HDKey: publicKey and privateKey at same time.");
7843
7843
  }
7844
- if (opt2.privateKey) {
7845
- if (!secp256k1.utils.isValidSecretKey(opt2.privateKey))
7844
+ if (opt.privateKey) {
7845
+ if (!secp256k1.utils.isValidSecretKey(opt.privateKey))
7846
7846
  throw new Error("Invalid private key");
7847
- this._privateKey = Uint8Array.from(opt2.privateKey);
7847
+ this._privateKey = Uint8Array.from(opt.privateKey);
7848
7848
  this._publicKey = secp256k1.getPublicKey(this._privateKey, true);
7849
- } else if (opt2.publicKey) {
7850
- this._publicKey = Point.fromBytes(opt2.publicKey).toBytes(true);
7849
+ } else if (opt.publicKey) {
7850
+ this._publicKey = Point.fromBytes(opt.publicKey).toBytes(true);
7851
7851
  } else {
7852
7852
  throw new Error("HDKey: no public or private key provided");
7853
7853
  }
@@ -7902,14 +7902,14 @@ class HDKey {
7902
7902
  abytes(out, 64);
7903
7903
  const childTweak = out.slice(0, 32);
7904
7904
  const chainCode = out.slice(32);
7905
- const opt2 = {
7905
+ const opt = {
7906
7906
  versions: this.versions,
7907
7907
  chainCode,
7908
7908
  depth: this.depth + 1,
7909
7909
  parentFingerprint: this.fingerprint,
7910
7910
  index
7911
7911
  };
7912
- if (opt2.depth > MAX_DEPTH) {
7912
+ if (opt.depth > MAX_DEPTH) {
7913
7913
  throw new Error("HDKey: depth exceeds the serializable value 255");
7914
7914
  }
7915
7915
  const retry = () => {
@@ -7926,15 +7926,15 @@ class HDKey {
7926
7926
  const added = Fn.create(Fn.fromBytes(this._privateKey) + ctweak);
7927
7927
  if (!Fn.isValidNot0(added))
7928
7928
  return retry();
7929
- opt2.privateKey = Fn.toBytes(added);
7929
+ opt.privateKey = Fn.toBytes(added);
7930
7930
  } else {
7931
7931
  const point = Point.fromBytes(this._publicKey);
7932
7932
  const added = ctweak === 0n ? point : point.add(Point.BASE.multiply(ctweak));
7933
7933
  if (added.equals(Point.ZERO))
7934
7934
  return retry();
7935
- opt2.publicKey = added.toBytes(true);
7935
+ opt.publicKey = added.toBytes(true);
7936
7936
  }
7937
- return new HDKey(opt2);
7937
+ return new HDKey(opt);
7938
7938
  }
7939
7939
  sign(hash) {
7940
7940
  if (!this._privateKey) {
@@ -7983,11 +7983,11 @@ function masterKey(seed) {
7983
7983
 
7984
7984
  // ../wallet-kernel/src/derive/wallet-id.ts
7985
7985
  function walletIdOf(master) {
7986
- const { publicKey: publicKey2 } = master;
7987
- if (publicKey2 === null || publicKey2.length !== 33) {
7986
+ const { publicKey } = master;
7987
+ if (publicKey === null || publicKey.length !== 33) {
7988
7988
  throw new KernelError("integrity", "master key has no compressed public key");
7989
7989
  }
7990
- return bytesToHex(sha256(concatBytes(utf8ToBytes("qntx-wallet/wallet-id/v1"), publicKey2)).slice(0, 8));
7990
+ return bytesToHex(sha256(concatBytes(utf8ToBytes("qntx-wallet/wallet-id/v1"), publicKey)).slice(0, 8));
7991
7991
  }
7992
7992
 
7993
7993
  // ../wallet-kernel/src/seed/entropy.ts
@@ -8013,17 +8013,17 @@ function entropyFromPrf(prf) {
8013
8013
  }
8014
8014
 
8015
8015
  // ../wallet-kernel/src/seed/seed.ts
8016
- async function seedFromMnemonic(mnemonic, passphrase, pbkdf22) {
8016
+ async function seedFromMnemonic(mnemonic, passphrase, pbkdf2) {
8017
8017
  const password = utf8ToBytes(mnemonic.normalize("NFKD"));
8018
8018
  const salt = utf8ToBytes(`mnemonic${passphrase}`.normalize("NFKD"));
8019
8019
  try {
8020
- return await pbkdf22("sha512", password, salt, 2048, 64);
8020
+ return await pbkdf2("sha512", password, salt, 2048, 64);
8021
8021
  } finally {
8022
8022
  wipe(password, salt);
8023
8023
  }
8024
8024
  }
8025
- async function seedFromEntropy(entropy, pbkdf22) {
8026
- return seedFromMnemonic(mnemonicFromEntropy(entropy), "", pbkdf22);
8025
+ async function seedFromEntropy(entropy, pbkdf2) {
8026
+ return seedFromMnemonic(mnemonicFromEntropy(entropy), "", pbkdf2);
8027
8027
  }
8028
8028
 
8029
8029
  // ../wallet-kernel/src/commands/wallets.ts
@@ -8037,9 +8037,9 @@ async function deriveWalletMaterial(platform, entropy) {
8037
8037
  }
8038
8038
  }
8039
8039
  async function walletMaterial(platform, entropy, origin, words) {
8040
- const { master, walletId: walletId2 } = await deriveWalletMaterial(platform, entropy);
8040
+ const { master, walletId } = await deriveWalletMaterial(platform, entropy);
8041
8041
  try {
8042
- return { walletId: walletId2, entropy, words, origin };
8042
+ return { walletId, entropy, words, origin };
8043
8043
  } finally {
8044
8044
  master.wipePrivateData();
8045
8045
  }
@@ -8063,25 +8063,25 @@ function walletRecord(ctx, dek, material, backedUp, createdAt) {
8063
8063
  });
8064
8064
  return sealRecord(ctx.platform, dek, "entropy", material.walletId, header, new Uint8Array(material.entropy));
8065
8065
  }
8066
- function gate(ctx, factor2, requestSession) {
8066
+ function gate(ctx, factor, requestSession) {
8067
8067
  if (ctx.image.meta === undefined) {
8068
- if (factor2 === undefined) {
8068
+ if (factor === undefined) {
8069
8069
  throw new KernelError("invalid-input", "an initial factor is required");
8070
8070
  }
8071
8071
  return { uninitialized: true, dek: Secret.take(ctx.platform.random(32)) };
8072
8072
  }
8073
- if (factor2 !== undefined) {
8073
+ if (factor !== undefined) {
8074
8074
  throw new KernelError("invalid-input", "vault is already initialized");
8075
8075
  }
8076
8076
  const session = ctx.session.require(requestSession);
8077
8077
  return { uninitialized: false, dek: session.dek };
8078
8078
  }
8079
- async function commitRecords(ctx, gated, factor2, records) {
8079
+ async function commitRecords(ctx, gated, factor, records) {
8080
8080
  if (gated.uninitialized) {
8081
- if (factor2 === undefined) {
8081
+ if (factor === undefined) {
8082
8082
  throw new KernelError("integrity", "unreachable: initial factor missing");
8083
8083
  }
8084
- const storedFactor = await makeFactor(ctx.platform, factor2, gated.dek);
8084
+ const storedFactor = await makeFactor(ctx.platform, factor, gated.dek);
8085
8085
  try {
8086
8086
  await ctx.commit([...establishOps(storedFactor, records)]);
8087
8087
  } catch (error) {
@@ -8104,17 +8104,17 @@ function quizPositions(random, count) {
8104
8104
  while (picked.size < 3) {
8105
8105
  const draw = random(4);
8106
8106
  for (let i = 0;i < 4 && picked.size < 3; i++) {
8107
- const b2 = draw[i];
8108
- if (b2 !== undefined && b2 < limit) {
8109
- picked.add(b2 % count);
8107
+ const b = draw[i];
8108
+ if (b !== undefined && b < limit) {
8109
+ picked.add(b % count);
8110
8110
  }
8111
8111
  }
8112
8112
  }
8113
8113
  const [a, b, c] = [...picked];
8114
8114
  return [a ?? 0, b ?? 0, c ?? 0];
8115
8115
  }
8116
- async function pendingFactorOf(ctx, factor2) {
8117
- const material = await newFactorKek(ctx.platform, factor2);
8116
+ async function pendingFactorOf(ctx, factor) {
8117
+ const material = await newFactorKek(ctx.platform, factor);
8118
8118
  return material.kind === "password" ? { kind: "password", kek: Secret.take(material.kek), salt: material.salt } : { kind: "passkey", kek: Secret.take(material.kek), credentialId: material.credentialId };
8119
8119
  }
8120
8120
  async function createMnemonic(ctx, params, requestSession) {
@@ -8166,7 +8166,7 @@ async function confirmMnemonic(ctx, params) {
8166
8166
  }
8167
8167
  const taken = ctx.session.takeDraft(params.draft);
8168
8168
  try {
8169
- const entropy = taken.entropy.use((bytes2) => new Uint8Array(bytes2));
8169
+ const entropy = taken.entropy.use((bytes) => new Uint8Array(bytes));
8170
8170
  const material = await walletMaterial(ctx.platform, entropy, "mnemonic", taken.words);
8171
8171
  try {
8172
8172
  ensureNewWallet(ctx, material);
@@ -8174,15 +8174,15 @@ async function confirmMnemonic(ctx, params) {
8174
8174
  if (taken.pendingFactor !== undefined) {
8175
8175
  const dek = Secret.take(ctx.platform.random(32));
8176
8176
  const storedFactor = storedFactorForPending(ctx, taken.pendingFactor, dek);
8177
- const record2 = walletRecord(ctx, dek, material, true, createdAt);
8177
+ const record = walletRecord(ctx, dek, material, true, createdAt);
8178
8178
  try {
8179
- await ctx.commit(establishOps(storedFactor, [record2]));
8179
+ await ctx.commit(establishOps(storedFactor, [record]));
8180
8180
  } catch (error) {
8181
8181
  dek.wipe();
8182
8182
  throw error;
8183
8183
  }
8184
- const session2 = ctx.session.open(dek);
8185
- return { wallet: walletInfoOf(material, true, createdAt), session: session2 };
8184
+ const session = ctx.session.open(dek);
8185
+ return { wallet: walletInfoOf(material, true, createdAt), session };
8186
8186
  }
8187
8187
  const session = ctx.session.current();
8188
8188
  const record = walletRecord(ctx, session.dek, material, true, createdAt);
@@ -8298,8 +8298,8 @@ var utf8Encoder = new TextEncoder;
8298
8298
  var utf8Decoder = new TextDecoder;
8299
8299
  var HEX32_RE = /^[0-9a-f]{64}$/;
8300
8300
  var HEX64_RE = /^[0-9a-f]{128}$/;
8301
- function bytesToHex$1(bytes2) {
8302
- return bytesToHex(bytes2);
8301
+ function bytesToHex$1(bytes) {
8302
+ return bytesToHex(bytes);
8303
8303
  }
8304
8304
  function hexToBytes$1(hex) {
8305
8305
  try {
@@ -8320,12 +8320,12 @@ function assertHex32(value, label) {
8320
8320
  throw new HexError(`invalid ${label}: expected 64-char hex`);
8321
8321
  return normalized;
8322
8322
  }
8323
- function assertByteLength(bytes2, expected, label) {
8324
- if (bytes2.length !== expected)
8325
- throw new HexError(`invalid ${label} length: expected ${expected}, got ${bytes2.length}`);
8323
+ function assertByteLength(bytes, expected, label) {
8324
+ if (bytes.length !== expected)
8325
+ throw new HexError(`invalid ${label} length: expected ${expected}, got ${bytes.length}`);
8326
8326
  }
8327
- function assertSecretKeyBytes(bytes2) {
8328
- assertByteLength(bytes2, 32, "secret key");
8327
+ function assertSecretKeyBytes(bytes) {
8328
+ assertByteLength(bytes, 32, "secret key");
8329
8329
  }
8330
8330
  function isRecord(value) {
8331
8331
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -8461,20 +8461,20 @@ function getEventHash(event) {
8461
8461
  }
8462
8462
 
8463
8463
  // ../../node_modules/.bun/@qntx+nostr@0.14.0+ea9f70ecde856c26/node_modules/@qntx/nostr/dist/key-D_oEutQ6.mjs
8464
- var SecretKey = class SecretKey2 {
8464
+ var SecretKey = class SecretKey {
8465
8465
  #bytes;
8466
- constructor(bytes2) {
8467
- assertSecretKeyBytes(bytes2);
8468
- this.#bytes = new Uint8Array(bytes2);
8466
+ constructor(bytes) {
8467
+ assertSecretKeyBytes(bytes);
8468
+ this.#bytes = new Uint8Array(bytes);
8469
8469
  }
8470
8470
  static generate() {
8471
- return new SecretKey2(schnorr.utils.randomSecretKey());
8471
+ return new SecretKey(schnorr.utils.randomSecretKey());
8472
8472
  }
8473
- static fromBytes(bytes2) {
8474
- return new SecretKey2(bytes2);
8473
+ static fromBytes(bytes) {
8474
+ return new SecretKey(bytes);
8475
8475
  }
8476
8476
  static fromHex(hex) {
8477
- return new SecretKey2(hexToBytes$1(assertHex32(hex, "secret key")));
8477
+ return new SecretKey(hexToBytes$1(assertHex32(hex, "secret key")));
8478
8478
  }
8479
8479
  get bytes() {
8480
8480
  if (!this.#bytes)
@@ -8505,7 +8505,7 @@ var nobleSigning = {
8505
8505
  function getPublicKey(secretKey) {
8506
8506
  return bytesToHex$1(schnorr.getPublicKey(toSecretKey(secretKey).bytes));
8507
8507
  }
8508
- var Keys = class Keys2 {
8508
+ var Keys = class Keys {
8509
8509
  secretKey;
8510
8510
  publicKey;
8511
8511
  backend;
@@ -8524,10 +8524,10 @@ var Keys = class Keys2 {
8524
8524
  this.publicKey = bytesToHex$1(pubkey);
8525
8525
  }
8526
8526
  static generate(backend = nobleSigning) {
8527
- return new Keys2(SecretKey.generate(), backend);
8527
+ return new Keys(SecretKey.generate(), backend);
8528
8528
  }
8529
8529
  static fromSecretKey(secretKey, backend = nobleSigning) {
8530
- return new Keys2(toSecretKey(secretKey), backend);
8530
+ return new Keys(toSecretKey(secretKey), backend);
8531
8531
  }
8532
8532
  };
8533
8533
  function resolveKeys(secretKey) {
@@ -8636,25 +8636,25 @@ var sbox = /* @__PURE__ */ (() => {
8636
8636
  var invSbox = /* @__PURE__ */ sbox.map((_, j) => sbox.indexOf(j));
8637
8637
  var rotr32_8 = (n) => n << 24 | n >>> 8;
8638
8638
  var rotl32_8 = (n) => n << 8 | n >>> 24;
8639
- function genTtable(sbox2, fn) {
8640
- if (sbox2.length !== 256)
8639
+ function genTtable(sbox, fn) {
8640
+ if (sbox.length !== 256)
8641
8641
  throw new Error("wrong sbox length");
8642
- const T0 = new Uint32Array(256).map((_, j) => fn(sbox2[j]));
8642
+ const T0 = new Uint32Array(256).map((_, j) => fn(sbox[j]));
8643
8643
  const T1 = T0.map(rotl32_8);
8644
8644
  const T2 = T1.map(rotl32_8);
8645
8645
  const T3 = T2.map(rotl32_8);
8646
8646
  const T01 = new Uint32Array(256 * 256);
8647
8647
  const T23 = new Uint32Array(256 * 256);
8648
- const sbox22 = new Uint16Array(256 * 256);
8648
+ const sbox2 = new Uint16Array(256 * 256);
8649
8649
  for (let i = 0;i < 256; i++) {
8650
8650
  for (let j = 0;j < 256; j++) {
8651
8651
  const idx = i * 256 + j;
8652
8652
  T01[idx] = T0[i] ^ T1[j];
8653
8653
  T23[idx] = T2[i] ^ T3[j];
8654
- sbox22[idx] = sbox2[i] << 8 | sbox2[j];
8654
+ sbox2[idx] = sbox[i] << 8 | sbox[j];
8655
8655
  }
8656
8656
  }
8657
- return { sbox: sbox2, sbox2: sbox22, T0, T1, T2, T3, T01, T23 };
8657
+ return { sbox, sbox2, T0, T1, T2, T3, T01, T23 };
8658
8658
  }
8659
8659
  var tableEncoding = /* @__PURE__ */ genTtable(sbox, (s) => mul(s, 3) << 24 | s << 16 | s << 8 | mul(s, 2));
8660
8660
  var tableDecoding = /* @__PURE__ */ genTtable(invSbox, (s) => mul(s, 11) << 24 | mul(s, 13) << 16 | mul(s, 9) << 8 | mul(s, 14));
@@ -8718,11 +8718,11 @@ function encrypt(xk, s0, s1, s2, s3) {
8718
8718
  s0 ^= xk[k++], s1 ^= xk[k++], s2 ^= xk[k++], s3 ^= xk[k++];
8719
8719
  const rounds = xk.length / 4 - 2;
8720
8720
  for (let i = 0;i < rounds; i++) {
8721
- const t02 = xk[k++] ^ apply0123(T01, T23, s0, s1, s2, s3);
8722
- const t12 = xk[k++] ^ apply0123(T01, T23, s1, s2, s3, s0);
8723
- const t22 = xk[k++] ^ apply0123(T01, T23, s2, s3, s0, s1);
8724
- const t32 = xk[k++] ^ apply0123(T01, T23, s3, s0, s1, s2);
8725
- s0 = t02, s1 = t12, s2 = t22, s3 = t32;
8721
+ const t0 = xk[k++] ^ apply0123(T01, T23, s0, s1, s2, s3);
8722
+ const t1 = xk[k++] ^ apply0123(T01, T23, s1, s2, s3, s0);
8723
+ const t2 = xk[k++] ^ apply0123(T01, T23, s2, s3, s0, s1);
8724
+ const t3 = xk[k++] ^ apply0123(T01, T23, s3, s0, s1, s2);
8725
+ s0 = t0, s1 = t1, s2 = t2, s3 = t3;
8726
8726
  }
8727
8727
  const t0 = xk[k++] ^ applySbox(sbox2, s0, s1, s2, s3);
8728
8728
  const t1 = xk[k++] ^ applySbox(sbox2, s1, s2, s3, s0);
@@ -8736,11 +8736,11 @@ function decrypt(xk, s0, s1, s2, s3) {
8736
8736
  s0 ^= xk[k++], s1 ^= xk[k++], s2 ^= xk[k++], s3 ^= xk[k++];
8737
8737
  const rounds = xk.length / 4 - 2;
8738
8738
  for (let i = 0;i < rounds; i++) {
8739
- const t02 = xk[k++] ^ apply0123(T01, T23, s0, s3, s2, s1);
8740
- const t12 = xk[k++] ^ apply0123(T01, T23, s1, s0, s3, s2);
8741
- const t22 = xk[k++] ^ apply0123(T01, T23, s2, s1, s0, s3);
8742
- const t32 = xk[k++] ^ apply0123(T01, T23, s3, s2, s1, s0);
8743
- s0 = t02, s1 = t12, s2 = t22, s3 = t32;
8739
+ const t0 = xk[k++] ^ apply0123(T01, T23, s0, s3, s2, s1);
8740
+ const t1 = xk[k++] ^ apply0123(T01, T23, s1, s0, s3, s2);
8741
+ const t2 = xk[k++] ^ apply0123(T01, T23, s2, s1, s0, s3);
8742
+ const t3 = xk[k++] ^ apply0123(T01, T23, s3, s2, s1, s0);
8743
+ s0 = t0, s1 = t1, s2 = t2, s3 = t3;
8744
8744
  }
8745
8745
  const t0 = xk[k++] ^ applySbox(sbox2, s0, s3, s2, s1);
8746
8746
  const t1 = xk[k++] ^ applySbox(sbox2, s1, s0, s3, s2);
@@ -8938,8 +8938,8 @@ var minPlaintextSize = 1;
8938
8938
  var maxPlaintextSize = 4294967295;
8939
8939
  var extendedPrefixThreshold = 65536;
8940
8940
  var DEFAULT_MAX_PAYLOAD_CHARS = Math.ceil((71 + calcPaddedLen(1048576)) / 3) * 4;
8941
- function assert32(bytes2, label) {
8942
- if (bytes2.length !== 32)
8941
+ function assert32(bytes, label) {
8942
+ if (bytes.length !== 32)
8943
8943
  throw new CryptoError(`${label} must be 32 bytes`);
8944
8944
  }
8945
8945
  function getConversationKey(privkeyA, pubkeyB) {
@@ -8970,19 +8970,19 @@ function calcPaddedLen(len) {
8970
8970
  const chunk = nextPower <= 256 ? 32 : nextPower / 8;
8971
8971
  return chunk * (Math.floor((len - 1) / chunk) + 1);
8972
8972
  }
8973
- function writeU16BE(num2) {
8974
- if (!Number.isSafeInteger(num2) || num2 < minPlaintextSize || num2 > 65535)
8973
+ function writeU16BE(num) {
8974
+ if (!Number.isSafeInteger(num) || num < minPlaintextSize || num > 65535)
8975
8975
  throw new CryptoError("invalid plaintext size: must be between 1 and 65535 bytes");
8976
- const arr2 = /* @__PURE__ */ new Uint8Array(2);
8977
- new DataView(arr2.buffer).setUint16(0, num2, false);
8978
- return arr2;
8976
+ const arr = /* @__PURE__ */ new Uint8Array(2);
8977
+ new DataView(arr.buffer).setUint16(0, num, false);
8978
+ return arr;
8979
8979
  }
8980
- function writeU32BE(num2) {
8981
- if (!Number.isSafeInteger(num2) || num2 < extendedPrefixThreshold || num2 > maxPlaintextSize)
8980
+ function writeU32BE(num) {
8981
+ if (!Number.isSafeInteger(num) || num < extendedPrefixThreshold || num > maxPlaintextSize)
8982
8982
  throw new CryptoError("invalid plaintext size: must be between 65536 and 4294967295 bytes");
8983
- const arr2 = /* @__PURE__ */ new Uint8Array(4);
8984
- new DataView(arr2.buffer).setUint32(0, num2, false);
8985
- return arr2;
8983
+ const arr = /* @__PURE__ */ new Uint8Array(4);
8984
+ new DataView(arr.buffer).setUint32(0, num, false);
8985
+ return arr;
8986
8986
  }
8987
8987
  function pad(plaintext) {
8988
8988
  const unpadded = utf8Encoder.encode(plaintext);
@@ -9132,11 +9132,11 @@ var KeysSigner = class {
9132
9132
  };
9133
9133
  // ../wallet-kernel/src/modules/nostr/derive.ts
9134
9134
  var NIP06_PATH = "m/44'/1237'/i'/0/0";
9135
- function nostrKeyAt(master, groupIndex2) {
9136
- if (!Number.isSafeInteger(groupIndex2) || groupIndex2 < 0 || groupIndex2 > 2147483647) {
9135
+ function nostrKeyAt(master, groupIndex) {
9136
+ if (!Number.isSafeInteger(groupIndex) || groupIndex < 0 || groupIndex > 2147483647) {
9137
9137
  throw new KernelError("invalid-input", "group index out of range");
9138
9138
  }
9139
- const path = NIP06_PATH.split("/").map((segment) => segment === "i'" ? `${groupIndex2}'` : segment).join("/");
9139
+ const path = NIP06_PATH.split("/").map((segment) => segment === "i'" ? `${groupIndex}'` : segment).join("/");
9140
9140
  const node = master.derive(path);
9141
9141
  try {
9142
9142
  const key = node.privateKey;
@@ -9181,15 +9181,15 @@ function encodeBech32(prefix, data) {
9181
9181
  const words = bech32.toWords(data);
9182
9182
  return bech32.encode(prefix, words, Bech32MaxSize2);
9183
9183
  }
9184
- function encodeBytes(prefix, bytes2) {
9185
- return encodeBech32(prefix, bytes2);
9184
+ function encodeBytes(prefix, bytes) {
9185
+ return encodeBech32(prefix, bytes);
9186
9186
  }
9187
9187
  function nsecEncode2(key) {
9188
9188
  assertByteLength(key, 32, "secret key");
9189
9189
  return encodeBytes("nsec", key);
9190
9190
  }
9191
- function readUint32(bytes2) {
9192
- return new DataView(bytes2.buffer, bytes2.byteOffset, bytes2.byteLength).getUint32(0);
9191
+ function readUint32(bytes) {
9192
+ return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getUint32(0);
9193
9193
  }
9194
9194
  function decode2(code) {
9195
9195
  let prefix;
@@ -9493,8 +9493,8 @@ async function encrypt4(secretKey, password, opts) {
9493
9493
  const nonce = randomBytes(NONCE_LEN);
9494
9494
  const aad = Uint8Array.from([opts?.ksb ?? 2]);
9495
9495
  const ciphertext = xchacha20poly1305(key, nonce, aad).encrypt(secretKey);
9496
- const bytes2 = concatBytes(Uint8Array.from([VERSION2]), Uint8Array.from([logn]), salt, nonce, aad, ciphertext);
9497
- return encodeBytes("ncryptsec", bytes2);
9496
+ const bytes = concatBytes(Uint8Array.from([VERSION2]), Uint8Array.from([logn]), salt, nonce, aad, ciphertext);
9497
+ return encodeBytes("ncryptsec", bytes);
9498
9498
  }
9499
9499
  async function decrypt4(ncryptsec, password, opts) {
9500
9500
  const { maxLogN } = opts;
@@ -9559,10 +9559,10 @@ function isGiftWrapKind(kind) {
9559
9559
  return kind === Kind.GiftWrap || kind === Kind.GiftWrapEphemeral;
9560
9560
  }
9561
9561
  function requireNip44Decryptor(crypto2) {
9562
- const decrypt5 = crypto2.nip44Decrypt;
9563
- if (!decrypt5)
9562
+ const decrypt = crypto2.nip44Decrypt;
9563
+ if (!decrypt)
9564
9564
  throw new Nip59Error("NIP-44 is required");
9565
- return { nip44Decrypt: async (peer, payload) => decrypt5.call(crypto2, peer, payload) };
9565
+ return { nip44Decrypt: async (peer, payload) => decrypt.call(crypto2, peer, payload) };
9566
9566
  }
9567
9567
  function parseJson(text) {
9568
9568
  try {
@@ -9617,10 +9617,10 @@ async function unwrap(crypto2, giftWrap) {
9617
9617
  throw new Nip59Error("seal tags must be empty");
9618
9618
  if (!verifyEvent(sealRaw))
9619
9619
  throw new Nip59Error("seal signature");
9620
- const rumor2 = parseRumor(parseJson(await decryptLayer(decryptor, sealRaw.pubkey, sealRaw.content)));
9621
- if (sealRaw.pubkey.toLowerCase() !== rumor2.pubkey.toLowerCase())
9620
+ const rumor = parseRumor(parseJson(await decryptLayer(decryptor, sealRaw.pubkey, sealRaw.content)));
9621
+ if (sealRaw.pubkey.toLowerCase() !== rumor.pubkey.toLowerCase())
9622
9622
  throw new Nip59Error("seal pubkey does not match rumor pubkey");
9623
- return rumor2;
9623
+ return rumor;
9624
9624
  }
9625
9625
 
9626
9626
  // ../wallet-kernel/src/modules/nostr/pool.ts
@@ -9629,25 +9629,25 @@ class SignerPool {
9629
9629
  add(secretKey) {
9630
9630
  try {
9631
9631
  const signer = new KeysSigner(Keys.fromSecretKey(secretKey));
9632
- const { publicKey: publicKey2 } = signer.keys;
9633
- this.signers.set(publicKey2, signer);
9634
- return publicKey2;
9632
+ const { publicKey } = signer.keys;
9633
+ this.signers.set(publicKey, signer);
9634
+ return publicKey;
9635
9635
  } finally {
9636
9636
  wipe(secretKey);
9637
9637
  }
9638
9638
  }
9639
- get(publicKey2) {
9640
- const signer = this.signers.get(publicKey2);
9639
+ get(publicKey) {
9640
+ const signer = this.signers.get(publicKey);
9641
9641
  if (signer === undefined) {
9642
9642
  throw new KernelError("not-found", "no such nostr key");
9643
9643
  }
9644
9644
  return signer;
9645
9645
  }
9646
- remove(publicKey2) {
9647
- const signer = this.signers.get(publicKey2);
9646
+ remove(publicKey) {
9647
+ const signer = this.signers.get(publicKey);
9648
9648
  if (signer !== undefined) {
9649
9649
  signer.dispose();
9650
- this.signers.delete(publicKey2);
9650
+ this.signers.delete(publicKey);
9651
9651
  }
9652
9652
  }
9653
9653
  dispose() {
@@ -9699,26 +9699,26 @@ async function ncryptsecFromSecretKey(secretKey, password, ksb) {
9699
9699
  const encoded = await encrypt4(secretKey, text, { logn: 16, ksb });
9700
9700
  return new TextEncoder().encode(encoded);
9701
9701
  }
9702
- async function signEvent2(pool, publicKey2, event) {
9703
- if (event.pubkey !== undefined && event.pubkey !== publicKey2) {
9702
+ async function signEvent2(pool, publicKey, event) {
9703
+ if (event.pubkey !== undefined && event.pubkey !== publicKey) {
9704
9704
  throw new KernelError("invalid-input", "event pubkey does not match the selected key");
9705
9705
  }
9706
9706
  const unsigned = {
9707
- pubkey: publicKey2,
9707
+ pubkey: publicKey,
9708
9708
  kind: event.kind,
9709
9709
  created_at: event.created_at,
9710
9710
  tags: event.tags,
9711
9711
  content: event.content
9712
9712
  };
9713
- return pool.get(publicKey2).signEvent(unsigned);
9713
+ return pool.get(publicKey).signEvent(unsigned);
9714
9714
  }
9715
- async function unwrapGiftWrap(pool, publicKey2, event) {
9715
+ async function unwrapGiftWrap(pool, publicKey, event) {
9716
9716
  if (!isGiftWrapKind(event.kind)) {
9717
9717
  return { err: "invalid-input" };
9718
9718
  }
9719
9719
  try {
9720
- const rumor2 = await unwrap(pool.get(publicKey2), event);
9721
- return { ok: rumor2 };
9720
+ const rumor = await unwrap(pool.get(publicKey), event);
9721
+ return { ok: rumor };
9722
9722
  } catch (error) {
9723
9723
  const err = error instanceof KernelError ? error.code : "integrity";
9724
9724
  return { err };
@@ -9742,12 +9742,12 @@ function encodeNostrKeyHeader(header) {
9742
9742
  }
9743
9743
  function parseNostrKeyHeader(text) {
9744
9744
  const object = headerObject(text);
9745
- const publicKey2 = asPublicKey(object["publicKey"]);
9745
+ const publicKey = asPublicKey(object["publicKey"]);
9746
9746
  const createdAt = asCreatedAt(object["createdAt"]);
9747
9747
  if (object["origin"] === "derived") {
9748
9748
  expectKeys(object, ["publicKey", "origin", "walletId", "groupIndex", "createdAt"]);
9749
9749
  return {
9750
- publicKey: publicKey2,
9750
+ publicKey,
9751
9751
  origin: "derived",
9752
9752
  walletId: asWalletId(object["walletId"]),
9753
9753
  groupIndex: asGroupIndex(object["groupIndex"]),
@@ -9759,7 +9759,7 @@ function parseNostrKeyHeader(text) {
9759
9759
  if (origin !== "nsec" && origin !== "ncryptsec" && origin !== "generated" && origin !== "nip46-client") {
9760
9760
  throw headerFailure();
9761
9761
  }
9762
- return { publicKey: publicKey2, origin, createdAt };
9762
+ return { publicKey, origin, createdAt };
9763
9763
  }
9764
9764
  function nostrKeyInfo2(header) {
9765
9765
  return {
@@ -9786,18 +9786,18 @@ function nostrStatus2(records) {
9786
9786
  function keyRecord(ctx, dek, secretKey, header) {
9787
9787
  return sealRecord(ctx.platform, dek, NOSTR_KEY_KIND, header.publicKey, encodeNostrKeyHeader(header), new Uint8Array(secretKey));
9788
9788
  }
9789
- function ensureNewKey(ctx, publicKey2) {
9790
- if (ctx.image.records.some((r) => r.kind === NOSTR_KEY_KIND && r.id === publicKey2)) {
9789
+ function ensureNewKey(ctx, publicKey) {
9790
+ if (ctx.image.records.some((r) => r.kind === NOSTR_KEY_KIND && r.id === publicKey)) {
9791
9791
  throw new KernelError("already-exists", "nostr key already exists");
9792
9792
  }
9793
9793
  }
9794
- async function addKey(ctx, pool, secretKey, origin, factor2, requestSession) {
9795
- const gated = gate(ctx, factor2, requestSession);
9796
- const publicKey2 = getPublicKey(secretKey);
9797
- ensureNewKey(ctx, publicKey2);
9798
- const header = { publicKey: publicKey2, origin, createdAt: ctx.platform.now() };
9794
+ async function addKey(ctx, pool, secretKey, origin, factor, requestSession) {
9795
+ const gated = gate(ctx, factor, requestSession);
9796
+ const publicKey = getPublicKey(secretKey);
9797
+ ensureNewKey(ctx, publicKey);
9798
+ const header = { publicKey, origin, createdAt: ctx.platform.now() };
9799
9799
  const record = keyRecord(ctx, gated.dek, secretKey, header);
9800
- const session = await commitRecords(ctx, gated, factor2, [record]);
9800
+ const session = await commitRecords(ctx, gated, factor, [record]);
9801
9801
  pool.add(secretKey);
9802
9802
  return { key: nostrKeyInfo2(header), session };
9803
9803
  }
@@ -9822,10 +9822,10 @@ async function createNip46ClientKey(ctx, pool, requestSession) {
9822
9822
  const { dek } = ctx.session.require(requestSession);
9823
9823
  const secretKey = generateSecretKey(ctx.platform.random);
9824
9824
  try {
9825
- const publicKey2 = getPublicKey(secretKey);
9826
- ensureNewKey(ctx, publicKey2);
9825
+ const publicKey = getPublicKey(secretKey);
9826
+ ensureNewKey(ctx, publicKey);
9827
9827
  const header = {
9828
- publicKey: publicKey2,
9828
+ publicKey,
9829
9829
  origin: "nip46-client",
9830
9830
  createdAt: ctx.platform.now()
9831
9831
  };
@@ -9847,10 +9847,10 @@ async function deriveKey2(ctx, pool, params, requestSession) {
9847
9847
  try {
9848
9848
  const secretKey = nostrKeyAt(master, params.groupIndex);
9849
9849
  try {
9850
- const publicKey2 = getPublicKey(secretKey);
9851
- ensureNewKey(ctx, publicKey2);
9850
+ const publicKey = getPublicKey(secretKey);
9851
+ ensureNewKey(ctx, publicKey);
9852
9852
  const header = {
9853
- publicKey: publicKey2,
9853
+ publicKey,
9854
9854
  origin: "derived",
9855
9855
  walletId: params.walletId,
9856
9856
  groupIndex: params.groupIndex,
@@ -9877,9 +9877,9 @@ async function discover(ctx, params, requestSession) {
9877
9877
  wipe(seed);
9878
9878
  try {
9879
9879
  for (let i = 0;i < params.count; i++) {
9880
- const groupIndex2 = params.from + i;
9881
- const secretKey = nostrKeyAt(master, groupIndex2);
9882
- keys.push({ groupIndex: groupIndex2, publicKey: getPublicKey(secretKey) });
9880
+ const groupIndex = params.from + i;
9881
+ const secretKey = nostrKeyAt(master, groupIndex);
9882
+ keys.push({ groupIndex, publicKey: getPublicKey(secretKey) });
9883
9883
  wipe(secretKey);
9884
9884
  }
9885
9885
  return { keys };
@@ -9967,14 +9967,14 @@ function createNostrModule() {
9967
9967
  lock: () => {
9968
9968
  pool.dispose();
9969
9969
  },
9970
- walletDeleteOps: (image, walletId2) => {
9970
+ walletDeleteOps: (image, walletId) => {
9971
9971
  const ids = [];
9972
9972
  for (const record of image.records) {
9973
9973
  if (record.kind !== NOSTR_KEY_KIND) {
9974
9974
  continue;
9975
9975
  }
9976
9976
  const header = parseNostrKeyHeader(record.header);
9977
- if (header.origin === "derived" && header.walletId === walletId2) {
9977
+ if (header.origin === "derived" && header.walletId === walletId) {
9978
9978
  ids.push(record.id);
9979
9979
  }
9980
9980
  }
@@ -10172,9 +10172,9 @@ function statusContents(image, modules, nostr) {
10172
10172
  const wallets = [];
10173
10173
  const owned = [];
10174
10174
  let corrupted = false;
10175
- for (const factor2 of image.factors) {
10175
+ for (const factor of image.factors) {
10176
10176
  try {
10177
- factors.push(factorInfo2(factor2));
10177
+ factors.push(factorInfo2(factor));
10178
10178
  } catch {
10179
10179
  corrupted = true;
10180
10180
  }
@@ -10237,7 +10237,7 @@ function isMethodName(method) {
10237
10237
  function startKernel(platform, port) {
10238
10238
  const nostr = createNostrModule();
10239
10239
  const HANDLERS = {
10240
- status: (ctx2) => statusPayload2(ctx2, nostr),
10240
+ status: (ctx) => statusPayload2(ctx, nostr),
10241
10241
  ...CORE_HANDLERS,
10242
10242
  ...nostr.handlers
10243
10243
  };
@@ -10402,6 +10402,9 @@ function startKernel(platform, port) {
10402
10402
  }
10403
10403
  // ../wallet-kernel/src/vault/store.ts
10404
10404
  var RECORD_KIND_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
10405
+ function isRecordKind(kind) {
10406
+ return RECORD_KIND_PATTERN.test(kind);
10407
+ }
10405
10408
  // src/shared.ts
10406
10409
  var MAX_ID = 128;
10407
10410
  var MAX_HEADER = 4096;
@@ -10460,7 +10463,7 @@ function assertVaultImage(value) {
10460
10463
  for (const entry of records) {
10461
10464
  const row = plainObject(entry);
10462
10465
  exactKeys(row, "header,id,kind,sealed");
10463
- if (typeof row["kind"] !== "string" || !RECORD_KIND_PATTERN.test(row["kind"])) {
10466
+ if (typeof row["kind"] !== "string" || !isRecordKind(row["kind"])) {
10464
10467
  throw bad("record kind is not a valid kind string");
10465
10468
  }
10466
10469
  boundedString(row["id"], MAX_ID, "record id");
@@ -10520,11 +10523,11 @@ async function transactionDone(tx) {
10520
10523
  tx.addEventListener("complete", () => {
10521
10524
  resolve();
10522
10525
  });
10523
- const fail2 = () => {
10526
+ const fail = () => {
10524
10527
  reject(tx.error instanceof Error ? tx.error : new Error("indexeddb transaction failed"));
10525
10528
  };
10526
- tx.addEventListener("error", fail2);
10527
- tx.addEventListener("abort", fail2);
10529
+ tx.addEventListener("error", fail);
10530
+ tx.addEventListener("abort", fail);
10528
10531
  });
10529
10532
  }
10530
10533
  async function openDb() {