@did-btcr2/method 0.15.0 → 0.16.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.
Files changed (90) hide show
  1. package/dist/browser.js +228 -206
  2. package/dist/browser.mjs +228 -206
  3. package/dist/cjs/core/beacon/aggregation/protocol/nostr.js +4 -4
  4. package/dist/cjs/core/beacon/aggregation/protocol/nostr.js.map +1 -1
  5. package/dist/cjs/core/beacon/cid-aggregate.js +2 -2
  6. package/dist/cjs/core/beacon/singleton.js +2 -2
  7. package/dist/cjs/core/beacon/singleton.js.map +1 -1
  8. package/dist/cjs/core/crud/create.js +4 -4
  9. package/dist/cjs/core/crud/create.js.map +1 -1
  10. package/dist/cjs/core/crud/deactivate.js +4 -4
  11. package/dist/cjs/core/crud/deactivate.js.map +1 -1
  12. package/dist/cjs/core/crud/read.js +20 -20
  13. package/dist/cjs/core/crud/read.js.map +1 -1
  14. package/dist/cjs/core/crud/update.js +2 -2
  15. package/dist/cjs/core/crud/update.js.map +1 -1
  16. package/dist/cjs/core/key-manager/index.js +5 -5
  17. package/dist/cjs/core/key-manager/index.js.map +1 -1
  18. package/dist/cjs/did-btcr2.js +1 -1
  19. package/dist/cjs/utils/appendix.js +4 -4
  20. package/dist/cjs/utils/appendix.js.map +1 -1
  21. package/dist/cjs/utils/did-document-builder.js +1 -1
  22. package/dist/cjs/utils/did-document-builder.js.map +1 -1
  23. package/dist/cjs/utils/did-document.js +2 -2
  24. package/dist/cjs/utils/did-document.js.map +1 -1
  25. package/dist/cjs/utils/identifier.js +5 -5
  26. package/dist/cjs/utils/identifier.js.map +1 -1
  27. package/dist/esm/core/beacon/aggregation/protocol/nostr.js +4 -4
  28. package/dist/esm/core/beacon/aggregation/protocol/nostr.js.map +1 -1
  29. package/dist/esm/core/beacon/cid-aggregate.js +2 -2
  30. package/dist/esm/core/beacon/singleton.js +2 -2
  31. package/dist/esm/core/beacon/singleton.js.map +1 -1
  32. package/dist/esm/core/crud/create.js +4 -4
  33. package/dist/esm/core/crud/create.js.map +1 -1
  34. package/dist/esm/core/crud/deactivate.js +4 -4
  35. package/dist/esm/core/crud/deactivate.js.map +1 -1
  36. package/dist/esm/core/crud/read.js +20 -20
  37. package/dist/esm/core/crud/read.js.map +1 -1
  38. package/dist/esm/core/crud/update.js +2 -2
  39. package/dist/esm/core/crud/update.js.map +1 -1
  40. package/dist/esm/core/key-manager/index.js +5 -5
  41. package/dist/esm/core/key-manager/index.js.map +1 -1
  42. package/dist/esm/did-btcr2.js +1 -1
  43. package/dist/esm/utils/appendix.js +4 -4
  44. package/dist/esm/utils/appendix.js.map +1 -1
  45. package/dist/esm/utils/did-document-builder.js +1 -1
  46. package/dist/esm/utils/did-document-builder.js.map +1 -1
  47. package/dist/esm/utils/did-document.js +2 -2
  48. package/dist/esm/utils/did-document.js.map +1 -1
  49. package/dist/esm/utils/identifier.js +5 -5
  50. package/dist/esm/utils/identifier.js.map +1 -1
  51. package/dist/types/core/beacon/aggregation/protocol/nostr.d.ts +1 -1
  52. package/dist/types/core/beacon/cid-aggregate.d.ts +2 -2
  53. package/dist/types/core/crud/deactivate.d.ts +4 -4
  54. package/dist/types/core/crud/deactivate.d.ts.map +1 -1
  55. package/dist/types/core/crud/read.d.ts +4 -4
  56. package/dist/types/core/crud/read.d.ts.map +1 -1
  57. package/dist/types/core/key-manager/index.d.ts +6 -6
  58. package/dist/types/core/key-manager/index.d.ts.map +1 -1
  59. package/dist/types/core/key-manager/interface.d.ts +3 -3
  60. package/dist/types/core/key-manager/interface.d.ts.map +1 -1
  61. package/dist/types/did-btcr2.d.ts +1 -1
  62. package/dist/types/interfaces/crud.d.ts +1 -4
  63. package/dist/types/interfaces/crud.d.ts.map +1 -1
  64. package/dist/types/types/crud.d.ts +5 -5
  65. package/dist/types/types/crud.d.ts.map +1 -1
  66. package/dist/types/utils/appendix.d.ts +7 -7
  67. package/dist/types/utils/appendix.d.ts.map +1 -1
  68. package/dist/types/utils/did-document-builder.d.ts +1 -1
  69. package/dist/types/utils/did-document-builder.d.ts.map +1 -1
  70. package/dist/types/utils/did-document.d.ts +1 -1
  71. package/dist/types/utils/did-document.d.ts.map +1 -1
  72. package/dist/types/utils/identifier.d.ts +2 -2
  73. package/dist/types/utils/identifier.d.ts.map +1 -1
  74. package/package.json +7 -6
  75. package/src/core/beacon/aggregation/protocol/nostr.ts +4 -4
  76. package/src/core/beacon/cid-aggregate.ts +2 -2
  77. package/src/core/beacon/singleton.ts +2 -2
  78. package/src/core/crud/create.ts +4 -4
  79. package/src/core/crud/deactivate.ts +4 -4
  80. package/src/core/crud/read.ts +21 -21
  81. package/src/core/crud/update.ts +2 -2
  82. package/src/core/key-manager/index.ts +7 -7
  83. package/src/core/key-manager/interface.ts +3 -3
  84. package/src/did-btcr2.ts +1 -1
  85. package/src/interfaces/crud.ts +1 -4
  86. package/src/types/crud.ts +5 -5
  87. package/src/utils/appendix.ts +9 -9
  88. package/src/utils/did-document-builder.ts +1 -1
  89. package/src/utils/did-document.ts +2 -2
  90. package/src/utils/identifier.ts +5 -5
package/dist/browser.js CHANGED
@@ -7362,7 +7362,7 @@ var BTCR2 = (() => {
7362
7362
  return false;
7363
7363
  }
7364
7364
  }
7365
- function isPoint3(p3) {
7365
+ function isPoint4(p3) {
7366
7366
  return _isPoint(p3, false);
7367
7367
  }
7368
7368
  function isPointCompressed(p3) {
@@ -7389,7 +7389,7 @@ var BTCR2 = (() => {
7389
7389
  });
7390
7390
  }
7391
7391
  function xOnlyPointFromPoint(p3) {
7392
- if (!isPoint3(p3)) {
7392
+ if (!isPoint4(p3)) {
7393
7393
  throw new Error(THROW_BAD_POINT);
7394
7394
  }
7395
7395
  return p3.slice(1, 33);
@@ -7409,13 +7409,13 @@ var BTCR2 = (() => {
7409
7409
  return xOnlyPointFromPoint(pointFromScalar2(d2));
7410
7410
  }
7411
7411
  function pointCompress(p3, compressed) {
7412
- if (!isPoint3(p3)) {
7412
+ if (!isPoint4(p3)) {
7413
7413
  throw new Error(THROW_BAD_POINT);
7414
7414
  }
7415
7415
  return fromHex2(p3).toRawBytes(assumeCompression(compressed, p3));
7416
7416
  }
7417
7417
  function pointMultiply(a3, tweak, compressed) {
7418
- if (!isPoint3(a3)) {
7418
+ if (!isPoint4(a3)) {
7419
7419
  throw new Error(THROW_BAD_POINT);
7420
7420
  }
7421
7421
  if (!isTweak(tweak)) {
@@ -7426,7 +7426,7 @@ var BTCR2 = (() => {
7426
7426
  );
7427
7427
  }
7428
7428
  function pointAdd2(a3, b2, compressed) {
7429
- if (!isPoint3(a3) || !isPoint3(b2)) {
7429
+ if (!isPoint4(a3) || !isPoint4(b2)) {
7430
7430
  throw new Error(THROW_BAD_POINT);
7431
7431
  }
7432
7432
  return throwToNull(() => {
@@ -7440,7 +7440,7 @@ var BTCR2 = (() => {
7440
7440
  });
7441
7441
  }
7442
7442
  function pointAddScalar(p3, tweak, compressed) {
7443
- if (!isPoint3(p3)) {
7443
+ if (!isPoint4(p3)) {
7444
7444
  throw new Error(THROW_BAD_POINT);
7445
7445
  }
7446
7446
  if (!isTweak(tweak)) {
@@ -7534,7 +7534,7 @@ var BTCR2 = (() => {
7534
7534
  return Q.toRawBytes(assumeCompression(compressed));
7535
7535
  }
7536
7536
  function verify(h2, Q, signature2, strict) {
7537
- if (!isPoint3(Q)) {
7537
+ if (!isPoint4(Q)) {
7538
7538
  throw new Error(THROW_BAD_POINT);
7539
7539
  }
7540
7540
  if (!isSignature(signature2)) {
@@ -7557,7 +7557,7 @@ var BTCR2 = (() => {
7557
7557
  }
7558
7558
  return secp256k13.schnorr.verify(signature2, h2, Q);
7559
7559
  }
7560
- exports.isPoint = isPoint3;
7560
+ exports.isPoint = isPoint4;
7561
7561
  exports.isPointCompressed = isPointCompressed;
7562
7562
  exports.isPrivate = isPrivate3;
7563
7563
  exports.isXOnlyPoint = isXOnlyPoint;
@@ -30638,7 +30638,7 @@ var BTCR2 = (() => {
30638
30638
  EDDSA.prototype.decodeInt = function decodeInt(bytes3) {
30639
30639
  return utils3.intFromLE(bytes3);
30640
30640
  };
30641
- EDDSA.prototype.isPoint = function isPoint3(val) {
30641
+ EDDSA.prototype.isPoint = function isPoint4(val) {
30642
30642
  return val instanceof this.pointClass;
30643
30643
  };
30644
30644
  }
@@ -32250,13 +32250,13 @@ var BTCR2 = (() => {
32250
32250
  ).optional()
32251
32251
  );
32252
32252
  });
32253
- var PublicKey4 = asn1.define("SubjectPublicKeyInfo", function() {
32253
+ var PublicKey3 = asn1.define("SubjectPublicKeyInfo", function() {
32254
32254
  this.seq().obj(
32255
32255
  this.key("algorithm").use(AlgorithmIdentifier2),
32256
32256
  this.key("subjectPublicKey").bitstr()
32257
32257
  );
32258
32258
  });
32259
- exports.PublicKey = PublicKey4;
32259
+ exports.PublicKey = PublicKey3;
32260
32260
  var PrivateKeyInfo2 = asn1.define("PrivateKeyInfo", function() {
32261
32261
  this.seq().obj(
32262
32262
  this.key("version")["int"](),
@@ -45987,16 +45987,16 @@ var BTCR2 = (() => {
45987
45987
  __export(index_exports, {
45988
45988
  Appendix: () => Appendix,
45989
45989
  BECH32M_CHARS: () => BECH32M_CHARS,
45990
- BTC1_DID_REGEX: () => BTC1_DID_REGEX,
45991
45990
  Beacon: () => Beacon,
45992
45991
  BeaconFactory: () => BeaconFactory,
45993
45992
  BeaconUtils: () => BeaconUtils,
45994
- Btc1Deactivate: () => Btc1Deactivate,
45995
- Btc1DidDocumentBuilder: () => Btc1DidDocumentBuilder,
45996
45993
  CIDAggregateBeacon: () => CIDAggregateBeacon,
45997
45994
  Create: () => Create,
45995
+ DID_REGEX: () => DID_REGEX,
45996
+ Deactivate: () => Deactivate,
45998
45997
  DidBtcr2: () => DidBtcr2,
45999
45998
  DidDocument: () => DidDocument2,
45999
+ DidDocumentBuilder: () => DidDocumentBuilder,
46000
46000
  DidVerificationMethod: () => DidVerificationMethod,
46001
46001
  GeneralUtils: () => GeneralUtils,
46002
46002
  Identifier: () => Identifier,
@@ -48457,8 +48457,8 @@ var BTCR2 = (() => {
48457
48457
  *
48458
48458
  * The Broadcast CIDAggregate Beacon Signal algorithm involving two roles: a set of cohort participants and a Beacon
48459
48459
  * coordinator. The Beacon coordinator collects individual DID Update Payload Content Identifiers (CIDs) for specific
48460
- * did:btc1s and aggregates them into a DID Update Bundle, which is then published to a Content Addressable Storage
48461
- * (CAS). The CID for the DID Update Bundle is included in a Partially Signed Bitcoin Transaction (PSBT) transaction
48460
+ * did:btcr2 idntifiers and aggregates them into a DID Update Bundle, which is then published to a Content Addressable
48461
+ * Storage (CAS). The CID for the DID Update Bundle is included in a Partially Signed Bitcoin Transaction (PSBT) transaction
48462
48462
  * output spent from the Beacon’s n-of-n address. Each of the n cohort participants in the Beacon MUST sign the
48463
48463
  * transaction before it can be broadcast to the network. It is RECOMMENDED that cohort participants keep a copy of
48464
48464
  * the DID Update Bundle and separately pin it to the CAS.
@@ -57649,7 +57649,7 @@ var BTCR2 = (() => {
57649
57649
  // ../bitcoin/dist/esm/bitcoin.js
57650
57650
  var BitcoinNetworkConnection = class {
57651
57651
  network;
57652
- mainnet;
57652
+ bitcoin;
57653
57653
  testnet3;
57654
57654
  testnet4;
57655
57655
  signet;
@@ -57670,7 +57670,7 @@ var BTCR2 = (() => {
57670
57670
  throw new MethodError("Parsing failed: malformed BITCOIN_NETWORK_CONFIG", "MISSING_MALFORMED_BITCOIN_NETWORK_CONFIG", { BITCOIN_NETWORK_CONFIG });
57671
57671
  }
57672
57672
  const networkConfigs = JSON.parse(BITCOIN_NETWORK_CONFIG);
57673
- const networks2 = ["mainnet", "testnet3", "testnet4", "signet", "mutinynet", "regtest"];
57673
+ const networks2 = ["bitcoin", "testnet3", "testnet4", "signet", "mutinynet", "regtest"];
57674
57674
  for (const network of networks2) {
57675
57675
  const networkConfig = configs?.[network] ?? networkConfigs[network];
57676
57676
  if (networkConfig) {
@@ -57694,7 +57694,7 @@ var BTCR2 = (() => {
57694
57694
  }
57695
57695
  /**
57696
57696
  * Get the Bitcoin network configuration for a specific network.
57697
- * @param {keyof AvailableNetworks} network - The Bitcoin network (e.g., 'mainnet', 'testnet3', 'signet', 'regtest').
57697
+ * @param {keyof AvailableNetworks} network - The Bitcoin network (e.g., 'bitcoin', 'testnet3', 'signet', 'regtest').
57698
57698
  * @returns {Bitcoin} The Bitcoin object.
57699
57699
  */
57700
57700
  getNetworkConnection(network) {
@@ -57706,7 +57706,7 @@ var BTCR2 = (() => {
57706
57706
  }
57707
57707
  /**
57708
57708
  * Sets the active Bitcoin network.
57709
- * @param {keyof AvailableNetworks} active - The Bitcoin network to set as active (e.g., 'mainnet', 'testnet3', 'signet', 'regtest').
57709
+ * @param {keyof AvailableNetworks} active - The Bitcoin network to set as active (e.g., 'bitcoin', 'testnet3', 'signet', 'regtest').
57710
57710
  * @throws {MethodError} If no configuration is found for the specified network.
57711
57711
  */
57712
57712
  setActiveNetwork(active) {
@@ -57740,7 +57740,7 @@ var BTCR2 = (() => {
57740
57740
 
57741
57741
  // ../bitcoin/dist/esm/taproot.js
57742
57742
  init_shim();
57743
- var tinysecp2 = __toESM(require_dist2(), 1);
57743
+ var tinysecp3 = __toESM(require_dist2(), 1);
57744
57744
 
57745
57745
  // ../keypair/dist/esm/index.js
57746
57746
  init_shim();
@@ -57750,12 +57750,13 @@ var BTCR2 = (() => {
57750
57750
 
57751
57751
  // ../keypair/dist/esm/public.js
57752
57752
  init_shim();
57753
+ var tinysecp2 = __toESM(require_dist2(), 1);
57753
57754
 
57754
57755
  // ../keypair/dist/esm/secret.js
57755
57756
  init_shim();
57756
57757
  var import_crypto3 = __toESM(require_crypto_browserify(), 1);
57757
57758
  var tinysecp = __toESM(require_dist2(), 1);
57758
- var SecretKey = class _SecretKey {
57759
+ var Secp256k1SecretKey = class _Secp256k1SecretKey {
57759
57760
  /** @type {KeyBytes} The entropy for the secret key as a byte array */
57760
57761
  _bytes;
57761
57762
  /** @type {bigint} The entropy for the secret key as a bigint */
@@ -57763,7 +57764,7 @@ var BTCR2 = (() => {
57763
57764
  /** @type {string} The secret key as a secretKeyMultibase */
57764
57765
  _multibase;
57765
57766
  /**
57766
- * Instantiates an instance of SecretKey.
57767
+ * Instantiates an instance of Secp256k1SecretKey.
57767
57768
  * @param {Entropy} entropy bytes (Uint8Array) or secret (bigint)
57768
57769
  * @throws {SecretKeyError} If entropy is not provided, not a valid 32-byte secret key or not a valid bigint seed
57769
57770
  */
@@ -57775,10 +57776,10 @@ var BTCR2 = (() => {
57775
57776
  }
57776
57777
  if (isBytes9 && entropy.length === 32) {
57777
57778
  this._bytes = entropy;
57778
- this._seed = _SecretKey.toSecret(entropy);
57779
+ this._seed = _Secp256k1SecretKey.toSecret(entropy);
57779
57780
  }
57780
57781
  if (isSecret && !(entropy < 1n || entropy >= CURVE.n)) {
57781
- this._bytes = _SecretKey.toBytes(entropy);
57782
+ this._bytes = _Secp256k1SecretKey.toBytes(entropy);
57782
57783
  this._seed = entropy;
57783
57784
  }
57784
57785
  if (!this._bytes || this._bytes.length !== 32) {
@@ -57835,7 +57836,7 @@ var BTCR2 = (() => {
57835
57836
  }
57836
57837
  /**
57837
57838
  * Checks if this secret key is equal to another.
57838
- * @param {SecretKey} other The other secret key
57839
+ * @param {Secp256k1SecretKey} other The other secret key
57839
57840
  * @returns {boolean} True if the private keys are equal, false otherwise
57840
57841
  */
57841
57842
  equals(other) {
@@ -57875,14 +57876,15 @@ var BTCR2 = (() => {
57875
57876
  }
57876
57877
  /**
57877
57878
  * Checks if the public key is a valid secp256k1 point.
57878
- * @param {PublicKey} pk The public key to validate
57879
+ * @param {CompressedSecp256k1PublicKey} pk The public key to validate
57879
57880
  * @returns {boolean} True if the public key is valid, false otherwise
57880
57881
  */
57881
- isValidPair(pk) {
57882
+ hasValidPublicKey(pk) {
57882
57883
  if (!tinysecp.isPoint(pk.compressed)) {
57883
57884
  return false;
57884
57885
  }
57885
- return true;
57886
+ const computed = new CompressedSecp256k1PublicKey(this.computePublicKey());
57887
+ return computed.equals(pk);
57886
57888
  }
57887
57889
  /**
57888
57890
  * Decodes the multibase string to the 34-byte secret key (2 byte prefix + 32 byte key).
@@ -57902,21 +57904,21 @@ var BTCR2 = (() => {
57902
57904
  return decoded;
57903
57905
  }
57904
57906
  /**
57905
- * Creates a SecretKey object from a JSON object.
57907
+ * Creates a Secp256k1SecretKey object from a JSON object.
57906
57908
  * @param {SecretKeyObject} json The JSON object containing the secret key bytes
57907
- * @returns {SecretKey} A new SecretKey object
57909
+ * @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object
57908
57910
  */
57909
57911
  static fromJSON(json) {
57910
- return new _SecretKey(new Uint8Array(json.bytes));
57912
+ return new _Secp256k1SecretKey(new Uint8Array(json.bytes));
57911
57913
  }
57912
57914
  /**
57913
- * Converts a SecretKey or KeyBytes to a Pair.
57914
- * @param {KeyBytes} bytes
57915
+ * Converts a Secp256k1SecretKey or KeyBytes to a SchnorrKeyPair.
57916
+ * @param {KeyBytes} bytes The secret key bytes
57915
57917
  * @returns {SchnorrKeyPair} The SchnorrKeyPair object containing the public and private keys
57916
57918
  * @throws {SecretKeyError} If the secret key is not valid
57917
57919
  */
57918
57920
  static toKeyPair(bytes3) {
57919
- const secretKey = new _SecretKey(bytes3);
57921
+ const secretKey = new _Secp256k1SecretKey(bytes3);
57920
57922
  const publicKey2 = secretKey.computePublicKey();
57921
57923
  return new SchnorrKeyPair({ publicKey: publicKey2, secretKey });
57922
57924
  }
@@ -57941,14 +57943,14 @@ var BTCR2 = (() => {
57941
57943
  return new Uint8Array(bytes3);
57942
57944
  }
57943
57945
  /**
57944
- * Creates a new SecretKey object from a bigint secret.
57945
- * @param {bigint} secret The secret bigint
57946
- * @returns {SecretKey} A new SecretKey object
57946
+ * Creates a new Secp256k1SecretKey object from a bigint secret.
57947
+ * @param {bigint} entropy The secret bigint
57948
+ * @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object
57947
57949
  */
57948
- static fromSecret(secret) {
57949
- const hexsecret = secret.toString(16).padStart(64, "0");
57950
+ static fromEntropy(entropy) {
57951
+ const hexsecret = entropy.toString(16).padStart(64, "0");
57950
57952
  const privateKeyBytes = new Uint8Array(hexsecret.match(/.{2}/g).map((byte) => parseInt(byte, 16)));
57951
- return new _SecretKey(privateKeyBytes);
57953
+ return new _Secp256k1SecretKey(privateKeyBytes);
57952
57954
  }
57953
57955
  /**
57954
57956
  * Generates random secret key bytes.
@@ -57959,12 +57961,12 @@ var BTCR2 = (() => {
57959
57961
  return (0, import_crypto3.getRandomValues)(byteArray);
57960
57962
  }
57961
57963
  /**
57962
- * Creates a new SecretKey from random secret key bytes.
57963
- * @returns {SecretKey} A new SecretKey object
57964
+ * Creates a new Secp256k1SecretKey from random secret key bytes.
57965
+ * @returns {Secp256k1SecretKey} A new Secp256k1SecretKey object
57964
57966
  */
57965
57967
  static generate() {
57966
57968
  const randomBytes7 = this.random();
57967
- return new _SecretKey(randomBytes7);
57969
+ return new _Secp256k1SecretKey(randomBytes7);
57968
57970
  }
57969
57971
  /**
57970
57972
  * Generates a public key from the given secret key bytes.
@@ -57972,22 +57974,22 @@ var BTCR2 = (() => {
57972
57974
  * @returns {KeyBytes} The computed public key bytes
57973
57975
  */
57974
57976
  static getPublicKey(bytes3) {
57975
- return new _SecretKey(bytes3).computePublicKey();
57977
+ return new _Secp256k1SecretKey(bytes3).computePublicKey();
57976
57978
  }
57977
57979
  };
57978
57980
 
57979
57981
  // ../keypair/dist/esm/public.js
57980
- var PublicKey = class _PublicKey {
57982
+ var CompressedSecp256k1PublicKey = class _CompressedSecp256k1PublicKey {
57981
57983
  /** @type {KeyBytes} The public key bytes */
57982
57984
  _bytes;
57983
57985
  /** @type {MultibaseObject} The public key as a MultibaseObject */
57984
57986
  _multibase = {
57985
57987
  prefix: BIP340_PUBLIC_KEY_MULTIBASE_PREFIX,
57986
57988
  key: [],
57987
- address: ""
57989
+ encoded: ""
57988
57990
  };
57989
57991
  /**
57990
- * Creates a PublicKey instance.
57992
+ * Creates a CompressedSecp256k1PublicKey instance.
57991
57993
  * @param {KeyBytes} bytes The public key byte array.
57992
57994
  * @throws {PublicKeyError} if the byte length is not 32 (x-only) or 33 (compressed)
57993
57995
  */
@@ -57995,8 +57997,11 @@ var BTCR2 = (() => {
57995
57997
  if (bytes3.length !== 33) {
57996
57998
  throw new PublicKeyError("Invalid argument: byte length must be 33 (compressed)", "CONSTRUCTOR_ERROR", { bytes: bytes3 });
57997
57999
  }
58000
+ if (!tinysecp2.isPoint(bytes3)) {
58001
+ throw new PublicKeyError("Invalid argument: bytes are not a valid secp256k1 compressed point", "CONSTRUCTOR_ERROR", { bytes: bytes3 });
58002
+ }
57998
58003
  this._bytes = bytes3;
57999
- this._multibase.address = this.encode();
58004
+ this._multibase.encoded = this.encode();
58000
58005
  this._multibase.key = [...this._multibase.prefix, ...this.compressed];
58001
58006
  }
58002
58007
  /**
@@ -58016,12 +58021,24 @@ var BTCR2 = (() => {
58016
58021
  return uncompressed;
58017
58022
  }
58018
58023
  /**
58019
- * Get the parity byte of the public key.
58020
- * @returns {number} The parity byte of the public key.
58024
+ * X-only (32-byte) view of the public key per BIP-340.
58025
+ */
58026
+ get xOnly() {
58027
+ return this._bytes.slice(1);
58028
+ }
58029
+ /**
58030
+ * Parity of the SEC compressed public key.
58031
+ * @returns {0 | 1} The parity of the public key. 0 = even (0x02), 1 = odd (0x03).
58021
58032
  */
58022
58033
  get parity() {
58023
- const parity = this.compressed[0];
58024
- return parity;
58034
+ return this._bytes[0] & 1;
58035
+ }
58036
+ /**
58037
+ * Whether the SEC compressed public key has even Y.
58038
+ * @returns {boolean} True if the public key has even Y.
58039
+ */
58040
+ get isEven() {
58041
+ return this._bytes[0] === 2;
58025
58042
  }
58026
58043
  /**
58027
58044
  * Get the x-coordinate of the public key.
@@ -58065,6 +58082,13 @@ var BTCR2 = (() => {
58065
58082
  y: this.y
58066
58083
  };
58067
58084
  }
58085
+ /**
58086
+ * Returns the BIP-340 (x-only) representation of this key.
58087
+ * @returns {KeyBytes} The BIP-340 (x-only) representation of the public key.
58088
+ */
58089
+ bip340() {
58090
+ return this.xOnly;
58091
+ }
58068
58092
  /**
58069
58093
  * Returns the point of the public key.
58070
58094
  * @param {Hex} pk The public key in hex (Uint8Array or string) format.
@@ -58073,11 +58097,11 @@ var BTCR2 = (() => {
58073
58097
  */
58074
58098
  static point(pk) {
58075
58099
  if (typeof pk === "string" && /^[0-9a-fA-F]+$/.test(pk)) {
58076
- const publicKey2 = new _PublicKey(import_buffer.Buffer.fromHex(pk));
58100
+ const publicKey2 = new _CompressedSecp256k1PublicKey(import_buffer.Buffer.fromHex(pk));
58077
58101
  return publicKey2.point;
58078
58102
  }
58079
58103
  if (pk instanceof Uint8Array || ArrayBuffer.isView(pk)) {
58080
- const publicKey2 = new _PublicKey(pk);
58104
+ const publicKey2 = new _CompressedSecp256k1PublicKey(pk);
58081
58105
  return publicKey2.point;
58082
58106
  }
58083
58107
  throw new PublicKeyError("Invalid publicKey: must be a hex string or byte array", "POINT_ERROR", { publicKey: pk });
@@ -58087,7 +58111,7 @@ var BTCR2 = (() => {
58087
58111
  * @returns {KeyBytes} The decoded public key: prefix and public key bytes
58088
58112
  */
58089
58113
  decode() {
58090
- const decoded = base58btc.decode(this.multibase.address);
58114
+ const decoded = base58btc.decode(this.multibase.encoded);
58091
58115
  if (decoded.length !== 35) {
58092
58116
  throw new PublicKeyError("Invalid argument: must be 35 byte publicKeyMultibase", "DECODE_MULTIBASE_ERROR");
58093
58117
  }
@@ -58113,15 +58137,15 @@ var BTCR2 = (() => {
58113
58137
  }
58114
58138
  /**
58115
58139
  * Compares this public key to another public key.
58116
- * @param {PublicKey} other The other public key to compare
58140
+ * @param {CompressedSecp256k1PublicKey} other The other public key to compare
58117
58141
  * @returns {boolean} True if the public keys are equal, false otherwise.
58118
58142
  */
58119
58143
  equals(other) {
58120
58144
  return this.hex === other.hex;
58121
58145
  }
58122
58146
  /**
58123
- * JSON representation of a PublicKey object.
58124
- * @returns {PublicKeyObject} The PublicKey as a JSON object.
58147
+ * JSON representation of a CompressedSecp256k1PublicKey object.
58148
+ * @returns {PublicKeyObject} The CompressedSecp256k1PublicKey as a JSON object.
58125
58149
  */
58126
58150
  json() {
58127
58151
  return {
@@ -58135,26 +58159,26 @@ var BTCR2 = (() => {
58135
58159
  };
58136
58160
  }
58137
58161
  /**
58138
- * Creates a PublicKey object from a JSON representation.
58139
- * @param {PublicKeyObject} json The JSON object to initialize the PublicKey.
58140
- * @returns {PublicKey} The initialized PublicKey object.
58162
+ * Creates a CompressedSecp256k1PublicKey object from a JSON representation.
58163
+ * @param {PublicKeyObject} json The JSON object to initialize the CompressedSecp256k1PublicKey.
58164
+ * @returns {CompressedSecp256k1PublicKey} The initialized CompressedSecp256k1PublicKey object.
58141
58165
  */
58142
58166
  static fromJSON(json) {
58143
58167
  json.x.unshift(json.parity);
58144
- return new _PublicKey(json.x.toUint8Array());
58168
+ return new _CompressedSecp256k1PublicKey(json.x.toUint8Array());
58145
58169
  }
58146
58170
  /**
58147
- * Computes the deterministic public key for a given private key.
58148
- * @param {PrivateKey | KeyBytes} sk The PrivateKey object or the private key bytes
58149
- * @returns {PublicKey} A new PublicKey object
58171
+ * Computes the deterministic public key for a given secret key.
58172
+ * @param {Secp256k1SecretKey | KeyBytes} sk The Secp256k1SecretKey object or the secret key bytes
58173
+ * @returns {CompressedSecp256k1PublicKey} A new CompressedSecp256k1PublicKey object
58150
58174
  */
58151
58175
  static fromSecretKey(sk) {
58152
- const bytes3 = sk instanceof SecretKey ? sk.bytes : sk;
58176
+ const bytes3 = sk instanceof Secp256k1SecretKey ? sk.bytes : sk;
58153
58177
  if (bytes3.length !== 32) {
58154
- throw new PublicKeyError("Invalid arg: must be 32 byte private key", "FROM_PRIVATE_KEY_ERROR");
58178
+ throw new PublicKeyError("Invalid arg: must be 32 byte secret key", "FROM_SECRET_KEY_ERROR");
58155
58179
  }
58156
- const privateKey = sk instanceof SecretKey ? sk : new SecretKey(sk);
58157
- return new _PublicKey(privateKey.computePublicKey());
58180
+ const secret = sk instanceof Secp256k1SecretKey ? sk : new Secp256k1SecretKey(sk);
58181
+ return new _CompressedSecp256k1PublicKey(secret.computePublicKey());
58158
58182
  }
58159
58183
  /**
58160
58184
  * Computes modular exponentiation: (base^exp) % mod.
@@ -58202,23 +58226,11 @@ var BTCR2 = (() => {
58202
58226
  const yBytes = import_buffer.Buffer.fromHex(y.toString(16).padStart(64, "0"));
58203
58227
  return new Uint8Array(import_buffer.Buffer.concat([import_buffer.Buffer.from([4]), import_buffer.Buffer.from(this.x), yBytes]));
58204
58228
  }
58205
- /**
58206
- * Static version of liftX method.
58207
- * @param {KeyBytes} x The 32-byte x-coordinate to lift.
58208
- * @returns {Uint8Array} The 65-byte uncompressed public key (0x04, x, y).
58209
- */
58210
- static xOnly(x) {
58211
- if (x.length !== 32) {
58212
- throw new PublicKeyError("Invalid argument: x-coordinate length must be 32 bytes", "LIFT_X_ERROR");
58213
- }
58214
- const publicKey2 = new _PublicKey(x);
58215
- return publicKey2.x;
58216
- }
58217
58229
  };
58218
58230
 
58219
58231
  // ../keypair/dist/esm/pair.js
58220
58232
  var SchnorrKeyPair = class _SchnorrKeyPair {
58221
- /** @type {SecretKey} The secret key object */
58233
+ /** @type {Secp256k1SecretKey} The secret key object */
58222
58234
  _secretKey;
58223
58235
  _publicKey;
58224
58236
  /** @type {string} The public key in multibase format */
@@ -58227,31 +58239,35 @@ var BTCR2 = (() => {
58227
58239
  _secretKeyMultibase;
58228
58240
  /**
58229
58241
  * Creates an instance of Keys. Must provide a at least a secret key.
58230
- * Can optionally provide both a private and public key, but must be a valid pair.
58231
- * @param {SecretKey} secretKey The secret key object
58242
+ * Can optionally provide both a secret and public key, but must be a valid pair.
58243
+ * @param {SchnorrKeyPairParams} params The parameters to initialize the Keys object.
58244
+ * @param {CompressedSecp256k1PublicKey | KeyBytes} params.publicKey The public key object or bytes
58245
+ * @param {Secp256k1SecretKey | KeyBytes} [params.secret] The secret key object or bytes
58246
+ * @throws {KeyPairError} If neither a public key or secret key is provided.
58247
+ * @throws {KeyPairError} If the public key is not a valid pair with the secret key.
58232
58248
  */
58233
- constructor({ secretKey, publicKey: publicKey2 } = {}) {
58234
- if (!publicKey2 && !secretKey) {
58249
+ constructor(params = {}) {
58250
+ if (!params.publicKey && !params.secretKey) {
58235
58251
  throw new KeyPairError("Argument missing: must at least provide a publicKey", "CONSTRUCTOR_ERROR");
58236
58252
  }
58237
- if (secretKey instanceof Uint8Array) {
58238
- this._secretKey = new SecretKey(secretKey);
58239
- } else if (secretKey instanceof SecretKey) {
58240
- this._secretKey = secretKey;
58253
+ if (params.secretKey instanceof Uint8Array) {
58254
+ this._secretKey = new Secp256k1SecretKey(params.secretKey);
58255
+ } else if (params.secretKey instanceof Secp256k1SecretKey) {
58256
+ this._secretKey = params.secretKey;
58241
58257
  }
58242
- if (publicKey2 instanceof PublicKey) {
58243
- this._publicKey = publicKey2;
58244
- } else if (publicKey2 instanceof Uint8Array) {
58245
- this._publicKey = new PublicKey(publicKey2);
58258
+ if (params.publicKey instanceof CompressedSecp256k1PublicKey) {
58259
+ this._publicKey = params.publicKey;
58260
+ } else if (params.publicKey instanceof Uint8Array) {
58261
+ this._publicKey = new CompressedSecp256k1PublicKey(params.publicKey);
58246
58262
  } else {
58247
- this._publicKey = new PublicKey(this._secretKey.computePublicKey());
58263
+ this._publicKey = new CompressedSecp256k1PublicKey(this._secretKey.computePublicKey());
58248
58264
  }
58249
- this._publicKeyMultibase = this._publicKey.multibase.address;
58265
+ this._publicKeyMultibase = this._publicKey.multibase.encoded;
58250
58266
  this._secretKeyMultibase = this._secretKey ? this._secretKey.multibase : "";
58251
58267
  }
58252
58268
  /**
58253
- * Get the SecretKey.
58254
- * @returns {SecretKey} The SecretKey object
58269
+ * Get the Secp256k1SecretKey.
58270
+ * @returns {Secp256k1SecretKey} The Secp256k1SecretKey object
58255
58271
  * @throws {KeyPairError} If the secret key is not available
58256
58272
  */
58257
58273
  get secretKey() {
@@ -58261,33 +58277,33 @@ var BTCR2 = (() => {
58261
58277
  if (!this._secretKey.isValid()) {
58262
58278
  throw new KeyPairError("Secret key is not valid", "SECRET_KEY_ERROR");
58263
58279
  }
58264
- const secretKey = this._secretKey;
58265
- return secretKey;
58280
+ const secret = this._secretKey;
58281
+ return secret;
58266
58282
  }
58267
58283
  /**
58268
- * Set the PublicKey.
58269
- * @param {PublicKey} publicKey The PublicKey object
58284
+ * Set the CompressedSecp256k1PublicKey.
58285
+ * @param {CompressedSecp256k1PublicKey} publicKey The CompressedSecp256k1PublicKey object
58270
58286
  * @throws {KeyPairError} If the public key is not a valid pair with the secret key.
58271
58287
  */
58272
58288
  set publicKey(publicKey2) {
58273
- if (this.secretKey && !this.secretKey.isValidPair(publicKey2)) {
58289
+ if (this.secretKey && !this.secretKey.hasValidPublicKey(publicKey2)) {
58274
58290
  throw new KeyPairError("Public key is not a valid pair with the secret key", "PUBLIC_KEY_ERROR");
58275
58291
  }
58276
58292
  this._publicKey = publicKey2;
58277
- this._publicKeyMultibase = publicKey2.multibase.address;
58293
+ this._publicKeyMultibase = publicKey2.multibase.encoded;
58278
58294
  this._secretKeyMultibase = this._secretKey ? this._secretKey.multibase : "";
58279
58295
  }
58280
58296
  /**
58281
- * Get the PublicKey.
58282
- * @returns {PublicKey} The PublicKey object
58297
+ * Get the CompressedSecp256k1PublicKey.
58298
+ * @returns {CompressedSecp256k1PublicKey} The CompressedSecp256k1PublicKey object
58283
58299
  */
58284
58300
  get publicKey() {
58285
58301
  const publicKey2 = this._publicKey;
58286
58302
  return publicKey2;
58287
58303
  }
58288
58304
  /**
58289
- * Get the Keys as a raw key pair.
58290
- * @returns {RawKeyPair} The Keys as a raw key pair
58305
+ * Get the raw bytes of each key in the SchnorrKeyPair.
58306
+ * @returns {RawSchnorrKeyPair} JSON object with the SchnorrKeyPair raw bytes.
58291
58307
  */
58292
58308
  get raw() {
58293
58309
  return {
@@ -58297,7 +58313,7 @@ var BTCR2 = (() => {
58297
58313
  }
58298
58314
  /**
58299
58315
  * Get the Keys in multibase format.
58300
- * @returns {MultibaseKeys} The SecretKey in multibase format
58316
+ * @returns {MultibaseKeys} The Secp256k1SecretKey in multibase format
58301
58317
  */
58302
58318
  get multibase() {
58303
58319
  return {
@@ -58321,37 +58337,40 @@ var BTCR2 = (() => {
58321
58337
  * @returns {SchnorrKeyPair} The initialized Keys object.
58322
58338
  */
58323
58339
  static fromJSON(keys) {
58324
- const secretKey = SecretKey.fromJSON(keys.secretKey);
58325
- const publicKey2 = PublicKey.fromJSON(keys.publicKey);
58326
- return new _SchnorrKeyPair({ secretKey, publicKey: publicKey2 });
58340
+ return new _SchnorrKeyPair({
58341
+ secretKey: Secp256k1SecretKey.fromJSON(keys.secretKey),
58342
+ publicKey: CompressedSecp256k1PublicKey.fromJSON(keys.publicKey)
58343
+ });
58327
58344
  }
58328
58345
  /**
58329
- * Static method creates a new SchnorrKeyPair from a SecretKey object or secret key bytes.
58330
- * @param {SecretKey | KeyBytes} data The secret key bytes
58346
+ * Static method creates a new SchnorrKeyPair from a Secp256k1SecretKey object or secret key bytes.
58347
+ * @param {Secp256k1SecretKey | KeyBytes} data The secret key bytes
58331
58348
  * @returns {SchnorrKeyPair} A new SchnorrKeyPair object
58332
58349
  */
58333
58350
  static fromPrivateKey(data) {
58334
- const bytes3 = data instanceof SecretKey ? data.bytes : data;
58351
+ const bytes3 = data instanceof Secp256k1SecretKey ? data.bytes : data;
58335
58352
  if (bytes3.length !== 32) {
58336
58353
  throw new KeyPairError("Invalid arg: must be 32 byte secret key", "FROM_PRIVATE_KEY_ERROR");
58337
58354
  }
58338
- const secretKey = data instanceof Uint8Array ? new SecretKey(data) : data;
58339
- const publicKey2 = secretKey.computePublicKey();
58340
- return new _SchnorrKeyPair({ secretKey, publicKey: publicKey2 });
58355
+ const secret = data instanceof Uint8Array ? new Secp256k1SecretKey(data) : data;
58356
+ return new _SchnorrKeyPair({
58357
+ secretKey: data instanceof Uint8Array ? new Secp256k1SecretKey(data) : data,
58358
+ publicKey: secret.computePublicKey()
58359
+ });
58341
58360
  }
58342
58361
  /**
58343
- * Static method creates a new Keys (SecretKey/PublicKey) bigint secret.
58344
- * @param {bigint} secret The secret key secret
58345
- * @returns {Keys} A new Keys object
58362
+ * Static method creates a new Keys (Secp256k1SecretKey/CompressedSecp256k1PublicKey) from bigint entropy.
58363
+ * @param {bigint} entropy The entropy in bigint form
58364
+ * @returns {SchnorrKeyPair} A new SchnorrKeyPair object
58346
58365
  */
58347
- static fromSecret(secret) {
58348
- const secretKey = SecretKey.fromSecret(secret);
58366
+ static fromEntropy(entropy) {
58367
+ const secretKey = Secp256k1SecretKey.fromEntropy(entropy);
58349
58368
  const publicKey2 = secretKey.computePublicKey();
58350
58369
  return new _SchnorrKeyPair({ secretKey, publicKey: publicKey2 });
58351
58370
  }
58352
58371
  /**
58353
58372
  * Converts key bytes to a hex string.
58354
- * @param {KeyBytes} keyBytes The key bytes (private or public).
58373
+ * @param {KeyBytes} keyBytes The key bytes (secret or public).
58355
58374
  * @returns {Hex} The key bytes as a hex string.
58356
58375
  */
58357
58376
  static toHex(keyBytes) {
@@ -58359,18 +58378,18 @@ var BTCR2 = (() => {
58359
58378
  }
58360
58379
  /**
58361
58380
  * Compares two Keys objects for equality.
58362
- * @param {SchnorrKeyPair} keys The main keys.
58363
- * @param {SchnorrKeyPair} otherKeys The other keys to compare.
58381
+ * @param {SchnorrKeyPair} kp The main keys.
58382
+ * @param {SchnorrKeyPair} otherKp The other keys to compare.
58364
58383
  * @returns {boolean} True if the public key and secret key are equal, false otherwise.
58365
58384
  */
58366
- static equals(keys, otherKeys) {
58367
- const pk = keys.publicKey;
58368
- const otherPk = otherKeys.publicKey;
58385
+ static equals(kp, otherKp) {
58386
+ const pk = kp.publicKey;
58387
+ const otherPk = otherKp.publicKey;
58369
58388
  if (pk && otherPk) {
58370
58389
  return pk.hex === otherPk.hex;
58371
58390
  }
58372
- const sk = keys.secretKey;
58373
- const otherSk = otherKeys.secretKey;
58391
+ const sk = kp.secretKey;
58392
+ const otherSk = otherKp.secretKey;
58374
58393
  if (sk && otherSk) {
58375
58394
  return sk.hex === otherSk.hex;
58376
58395
  }
@@ -58378,16 +58397,19 @@ var BTCR2 = (() => {
58378
58397
  }
58379
58398
  /**
58380
58399
  * Static method to generate a new random SchnorrKeyPair instance.
58381
- * @returns {SchnorrKeyPair} A new SecretKey object.
58400
+ * @returns {SchnorrKeyPair} A new Secp256k1SecretKey object.
58382
58401
  */
58383
58402
  static generate() {
58384
- const skBytes = SecretKey.random();
58385
- const secretKey = new SecretKey(skBytes);
58403
+ const sk = Secp256k1SecretKey.random();
58404
+ const secretKey = new Secp256k1SecretKey(sk);
58386
58405
  const publicKey2 = secretKey.computePublicKey();
58387
58406
  return new _SchnorrKeyPair({ secretKey, publicKey: publicKey2 });
58388
58407
  }
58389
58408
  };
58390
58409
 
58410
+ // ../keypair/dist/esm/types.js
58411
+ init_shim();
58412
+
58391
58413
  // src/utils/appendix.ts
58392
58414
  init_shim();
58393
58415
 
@@ -65708,7 +65730,7 @@ var BTCR2 = (() => {
65708
65730
  return n3 === _0n6 ? n3 : assertInRange(n3, CURVE_ORDER);
65709
65731
  }
65710
65732
  const pointPrecomputes2 = /* @__PURE__ */ new Map();
65711
- function isPoint3(other) {
65733
+ function isPoint4(other) {
65712
65734
  if (!(other instanceof Point4))
65713
65735
  throw new Error("ExtendedPoint expected");
65714
65736
  }
@@ -65773,7 +65795,7 @@ var BTCR2 = (() => {
65773
65795
  }
65774
65796
  // Compare one point to another.
65775
65797
  equals(other) {
65776
- isPoint3(other);
65798
+ isPoint4(other);
65777
65799
  const { ex: X1, ey: Y1, ez: Z1 } = this;
65778
65800
  const { ex: X2, ey: Y2, ez: Z2 } = other;
65779
65801
  const X1Z2 = modP(X1 * Z2);
@@ -65813,7 +65835,7 @@ var BTCR2 = (() => {
65813
65835
  // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd
65814
65836
  // Cost: 9M + 1*a + 1*d + 7add.
65815
65837
  add(other) {
65816
- isPoint3(other);
65838
+ isPoint4(other);
65817
65839
  const { a: a3, d: d2 } = CURVE2;
65818
65840
  const { ex: X1, ey: Y1, ez: Z1, et: T1 } = this;
65819
65841
  const { ex: X2, ey: Y2, ez: Z2, et: T2 } = other;
@@ -86869,10 +86891,10 @@ var BTCR2 = (() => {
86869
86891
  return enumeration(__KeyTypeValues);
86870
86892
  };
86871
86893
  })(KeyType || (KeyType = {}));
86872
- var PublicKey2;
86873
- (function(PublicKey4) {
86894
+ var PublicKey;
86895
+ (function(PublicKey3) {
86874
86896
  let _codec;
86875
- PublicKey4.codec = () => {
86897
+ PublicKey3.codec = () => {
86876
86898
  if (_codec == null) {
86877
86899
  _codec = message((obj, w, opts = {}) => {
86878
86900
  if (opts.lengthDelimited !== false) {
@@ -86914,13 +86936,13 @@ var BTCR2 = (() => {
86914
86936
  }
86915
86937
  return _codec;
86916
86938
  };
86917
- PublicKey4.encode = (obj) => {
86918
- return encodeMessage(obj, PublicKey4.codec());
86939
+ PublicKey3.encode = (obj) => {
86940
+ return encodeMessage(obj, PublicKey3.codec());
86919
86941
  };
86920
- PublicKey4.decode = (buf2, opts) => {
86921
- return decodeMessage(buf2, PublicKey4.codec(), opts);
86942
+ PublicKey3.decode = (buf2, opts) => {
86943
+ return decodeMessage(buf2, PublicKey3.codec(), opts);
86922
86944
  };
86923
- })(PublicKey2 || (PublicKey2 = {}));
86945
+ })(PublicKey || (PublicKey = {}));
86924
86946
  var PrivateKey;
86925
86947
  (function(PrivateKey3) {
86926
86948
  let _codec;
@@ -87171,7 +87193,7 @@ var BTCR2 = (() => {
87171
87193
  function pkixMessageToRSAPublicKey(message2, bytes3, digest2) {
87172
87194
  const jwk = pkixMessageToJwk(message2);
87173
87195
  if (digest2 == null) {
87174
- const hash2 = sha2562(PublicKey2.encode({
87196
+ const hash2 = sha2562(PublicKey.encode({
87175
87197
  Type: KeyType.RSA,
87176
87198
  Data: bytes3
87177
87199
  }));
@@ -87184,7 +87206,7 @@ var BTCR2 = (() => {
87184
87206
  throw new InvalidParametersError("Key size is too large");
87185
87207
  }
87186
87208
  const keys = jwkToJWKKeyPair(jwk);
87187
- const hash2 = sha2562(PublicKey2.encode({
87209
+ const hash2 = sha2562(PublicKey.encode({
87188
87210
  Type: KeyType.RSA,
87189
87211
  Data: jwkToPkix(keys.publicKey)
87190
87212
  }));
@@ -87196,7 +87218,7 @@ var BTCR2 = (() => {
87196
87218
  throw new InvalidParametersError("Key size is too large");
87197
87219
  }
87198
87220
  const keys = await generateRSAKey(bits);
87199
- const hash2 = sha2562(PublicKey2.encode({
87221
+ const hash2 = sha2562(PublicKey.encode({
87200
87222
  Type: KeyType.RSA,
87201
87223
  Data: jwkToPkix(keys.publicKey)
87202
87224
  }));
@@ -88687,7 +88709,7 @@ var BTCR2 = (() => {
88687
88709
  throw new UnsupportedKeyTypeError();
88688
88710
  }
88689
88711
  function publicKeyFromProtobuf(buf2, digest2) {
88690
- const { Type: Type2, Data } = PublicKey2.decode(buf2);
88712
+ const { Type: Type2, Data } = PublicKey.decode(buf2);
88691
88713
  const data = Data ?? new Uint8Array();
88692
88714
  switch (Type2) {
88693
88715
  case KeyType.RSA:
@@ -88703,7 +88725,7 @@ var BTCR2 = (() => {
88703
88725
  }
88704
88726
  }
88705
88727
  function publicKeyFromMultihash(digest2) {
88706
- const { Type: Type2, Data } = PublicKey2.decode(digest2.digest);
88728
+ const { Type: Type2, Data } = PublicKey.decode(digest2.digest);
88707
88729
  const data = Data ?? new Uint8Array();
88708
88730
  switch (Type2) {
88709
88731
  case KeyType.Ed25519:
@@ -88717,7 +88739,7 @@ var BTCR2 = (() => {
88717
88739
  }
88718
88740
  }
88719
88741
  function publicKeyToProtobuf(key) {
88720
- return PublicKey2.encode({
88742
+ return PublicKey.encode({
88721
88743
  Type: KeyType[key.type],
88722
88744
  Data: key.raw
88723
88745
  });
@@ -142602,7 +142624,7 @@ ${values.join("\n")}` : `${blockName} :`;
142602
142624
  }
142603
142625
  }
142604
142626
  };
142605
- var PublicKey3 = class _PublicKey extends PemData {
142627
+ var PublicKey2 = class _PublicKey extends PemData {
142606
142628
  static async create(data, crypto6 = cryptoProvider.get()) {
142607
142629
  if (data instanceof _PublicKey) {
142608
142630
  return data;
@@ -142718,7 +142740,7 @@ ${values.join("\n")}` : `${blockName} :`;
142718
142740
  if ("name" in param && "serialNumber" in param) {
142719
142741
  return new _AuthorityKeyIdentifierExtension(param, critical);
142720
142742
  }
142721
- const key = await PublicKey3.create(param, crypto6);
142743
+ const key = await PublicKey2.create(param, crypto6);
142722
142744
  const id = await key.getKeyIdentifier(crypto6);
142723
142745
  return new _AuthorityKeyIdentifierExtension(import_pvtsutils6.Convert.ToHex(id), critical);
142724
142746
  }
@@ -142858,7 +142880,7 @@ ${values.join("\n")}` : `${blockName} :`;
142858
142880
  KeyUsagesExtension.NAME = "Key Usages";
142859
142881
  var SubjectKeyIdentifierExtension = class _SubjectKeyIdentifierExtension extends Extension2 {
142860
142882
  static async create(publicKey2, critical = false, crypto6 = cryptoProvider.get()) {
142861
- const key = await PublicKey3.create(publicKey2, crypto6);
142883
+ const key = await PublicKey2.create(publicKey2, crypto6);
142862
142884
  const id = await key.getKeyIdentifier(crypto6);
142863
142885
  return new _SubjectKeyIdentifierExtension(import_pvtsutils6.Convert.ToHex(id), critical);
142864
142886
  }
@@ -143500,7 +143522,7 @@ ${values.join("\n")}` : `${blockName} :`;
143500
143522
  }
143501
143523
  get publicKey() {
143502
143524
  if (!__classPrivateFieldGet(this, _Pkcs10CertificateRequest_publicKey, "f")) {
143503
- __classPrivateFieldSet(this, _Pkcs10CertificateRequest_publicKey, new PublicKey3(this.asn.certificationRequestInfo.subjectPKInfo), "f");
143525
+ __classPrivateFieldSet(this, _Pkcs10CertificateRequest_publicKey, new PublicKey2(this.asn.certificationRequestInfo.subjectPKInfo), "f");
143504
143526
  }
143505
143527
  return __classPrivateFieldGet(this, _Pkcs10CertificateRequest_publicKey, "f");
143506
143528
  }
@@ -143622,7 +143644,7 @@ ${values.join("\n")}` : `${blockName} :`;
143622
143644
  var X509Certificate = class extends PemData {
143623
143645
  get publicKey() {
143624
143646
  if (!__classPrivateFieldGet(this, _X509Certificate_publicKey, "f")) {
143625
- __classPrivateFieldSet(this, _X509Certificate_publicKey, new PublicKey3(this.asn.tbsCertificate.subjectPublicKeyInfo), "f");
143647
+ __classPrivateFieldSet(this, _X509Certificate_publicKey, new PublicKey2(this.asn.tbsCertificate.subjectPublicKeyInfo), "f");
143626
143648
  }
143627
143649
  return __classPrivateFieldGet(this, _X509Certificate_publicKey, "f");
143628
143650
  }
@@ -143762,11 +143784,11 @@ ${values.join("\n")}` : `${blockName} :`;
143762
143784
  } else if ("publicKey" in paramsKey) {
143763
143785
  keyAlgorithm = { ...paramsKey.publicKey.algorithm, ...this.signatureAlgorithm };
143764
143786
  publicKey2 = await paramsKey.publicKey.export(keyAlgorithm, ["verify"], crypto6);
143765
- } else if (paramsKey instanceof PublicKey3) {
143787
+ } else if (paramsKey instanceof PublicKey2) {
143766
143788
  keyAlgorithm = { ...paramsKey.algorithm, ...this.signatureAlgorithm };
143767
143789
  publicKey2 = await paramsKey.export(keyAlgorithm, ["verify"], crypto6);
143768
143790
  } else if (import_pvtsutils6.BufferSourceConverter.isBufferSource(paramsKey)) {
143769
- const key = new PublicKey3(paramsKey);
143791
+ const key = new PublicKey2(paramsKey);
143770
143792
  keyAlgorithm = { ...key.algorithm, ...this.signatureAlgorithm };
143771
143793
  publicKey2 = await key.export(keyAlgorithm, ["verify"], crypto6);
143772
143794
  } else {
@@ -143895,7 +143917,7 @@ ${values.join("\n")}` : `${blockName} :`;
143895
143917
  static async create(params, crypto6 = cryptoProvider.get()) {
143896
143918
  var _a3;
143897
143919
  let spki;
143898
- if (params.publicKey instanceof PublicKey3) {
143920
+ if (params.publicKey instanceof PublicKey2) {
143899
143921
  spki = params.publicKey.rawData;
143900
143922
  } else if ("publicKey" in params.publicKey) {
143901
143923
  spki = params.publicKey.publicKey.rawData;
@@ -145202,7 +145224,7 @@ a=end-of-candidates
145202
145224
  return verificationMethods;
145203
145225
  }
145204
145226
  /**
145205
- * Implements {@link https://dcdpr.github.io/did-btcr2/#derive-root-capability-from-didbtc1-identifier | 9.4.1 Derive Root Capability from did:btcr2 Identifier}.
145227
+ * Implements {@link https://dcdpr.github.io/did-btcr2/#derive-root-capability-from-didbtcr2-identifier | 9.4.1 Derive Root Capability from did:btcr2 Identifier }.
145206
145228
  *
145207
145229
  * The Derive Root Capability algorithm deterministically generates a ZCAP-LD root capability from a given did:btcr2
145208
145230
  * identifier. Each root capability is unique to the identifier. This root capability is defined and understood by the
@@ -145210,7 +145232,7 @@ a=end-of-candidates
145210
145232
  * document. It takes in a did:btcr2 identifier and returns a rootCapability object. It returns the root capability.
145211
145233
  *
145212
145234
  * @param {string} identifier The did-btcr2 identifier to derive the root capability from
145213
- * @returns {Btc1RootCapability} The root capability object
145235
+ * @returns {RootCapability} The root capability object
145214
145236
  * @example Root capability for updating the DID document for
145215
145237
  * did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u
145216
145238
  * ```
@@ -145238,7 +145260,7 @@ a=end-of-candidates
145238
145260
  * capability object.
145239
145261
  *
145240
145262
  * @param {string} capabilityId The root capability identifier to dereference.
145241
- * @returns {Btc1RootCapability} The root capability object.
145263
+ * @returns {RootCapability} The root capability object.
145242
145264
  * @example a didUpdatePayload with an invoked ZCAP-LD capability containing a patch defining how the DID document
145243
145265
  * for did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u SHOULD be mutated.
145244
145266
  * ```
@@ -145264,7 +145286,7 @@ a=end-of-candidates
145264
145286
  * "cryptosuite": "schnorr-secp256k1-jcs-2025",
145265
145287
  * "verificationMethod": "did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u#initialKey",
145266
145288
  * "invocationTarget": "did:btcr2:k1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u",
145267
- * "capability": "urn:zcap:root:did%3Abtc1%3Ak1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u",
145289
+ * "capability": "urn:zcap:root:did%3Abtcr2%3Ak1q0rnnwf657vuu8trztlczvlmphjgc6q598h79cm6sp7c4fgqh0fkc0vzd9u",
145268
145290
  * "capabilityAction": "Write",
145269
145291
  * "proofPurpose": "assertionMethod",
145270
145292
  * "proofValue": "z381yXYmxU8NudZ4HXY56DfMN6zfD8syvWcRXzT9xD9uYoQToo8QsXD7ahM3gXTzuay5WJbqTswt2BKaGWYn2hHhVFKJLXaDz"
@@ -145595,8 +145617,8 @@ a=end-of-candidates
145595
145617
  * @param {string} params.id The id of the multikey (required)
145596
145618
  * @param {string} params.controller The controller of the multikey (required)
145597
145619
  * @param {Keys} params.keys The Keys of the multikey (optional, required if no publicKey)
145598
- * @param {PublicKey} params.keys.publicKey The public key of the multikey (optional, required if no privateKey)
145599
- * @param {SecretKey} params.keys.privateKey The private key of the multikey (optional)
145620
+ * @param {CompressedSecp256k1PublicKey} params.keys.publicKey The public key of the multikey (optional, required if no privateKey)
145621
+ * @param {Secp256k1SecretKey} params.keys.privateKey The private key of the multikey (optional)
145600
145622
  * @throws {MultikeyError} if neither a publicKey nor a privateKey is provided
145601
145623
  */
145602
145624
  constructor({ id, controller, keys }) {
@@ -145615,7 +145637,7 @@ a=end-of-candidates
145615
145637
  const keys = this._keys;
145616
145638
  return keys;
145617
145639
  }
145618
- /** @type {PublicKey} @readonly Get the Multikey PublicKey. */
145640
+ /** @type {CompressedSecp256k1PublicKey} @readonly Get the Multikey CompressedSecp256k1PublicKey. */
145619
145641
  get publicKey() {
145620
145642
  const publicKey2 = this._keys.publicKey;
145621
145643
  return publicKey2;
@@ -145691,7 +145713,7 @@ a=end-of-candidates
145691
145713
  id: this.id,
145692
145714
  type: _SchnorrMultikey.type,
145693
145715
  controller: this.controller,
145694
- publicKeyMultibase: this.publicKey.multibase.address
145716
+ publicKeyMultibase: this.publicKey.multibase.encoded
145695
145717
  };
145696
145718
  }
145697
145719
  /**
@@ -145719,10 +145741,10 @@ a=end-of-candidates
145719
145741
  }
145720
145742
  const decoded = this.publicKey.decode();
145721
145743
  const publicKey2 = decoded.slice(2, decoded.length);
145722
- const keys = new SchnorrKeyPair({ publicKey: new PublicKey(publicKey2) });
145744
+ const keys = new SchnorrKeyPair({ publicKey: new CompressedSecp256k1PublicKey(publicKey2) });
145723
145745
  return new _SchnorrMultikey({ id, controller, keys });
145724
145746
  }
145725
- /** @type {boolean} @readonly Get signing ability of the Multikey (i.e. is there a valid SecretKey). */
145747
+ /** @type {boolean} @readonly Get signing ability of the Multikey (i.e. is there a valid Secp256k1SecretKey). */
145726
145748
  get signer() {
145727
145749
  return !!this.keys.secretKey;
145728
145750
  }
@@ -145763,7 +145785,7 @@ a=end-of-candidates
145763
145785
  * @returns {SchnorrMultikey} The new multikey instance
145764
145786
  */
145765
145787
  static fromPrivateKey({ id, controller, entropy }) {
145766
- const secretKey = new SecretKey(entropy);
145788
+ const secretKey = new Secp256k1SecretKey(entropy);
145767
145789
  const publicKey2 = secretKey.computePublicKey();
145768
145790
  const keys = new SchnorrKeyPair({ publicKey: publicKey2, secretKey });
145769
145791
  return new _SchnorrMultikey({ id, controller, keys });
@@ -145777,7 +145799,7 @@ a=end-of-candidates
145777
145799
  * @returns {Multikey} The new multikey instance
145778
145800
  */
145779
145801
  static fromPublicKey({ id, controller, publicKeyBytes }) {
145780
- const keys = new SchnorrKeyPair({ publicKey: new PublicKey(publicKeyBytes) });
145802
+ const keys = new SchnorrKeyPair({ publicKey: new CompressedSecp256k1PublicKey(publicKeyBytes) });
145781
145803
  return new _SchnorrMultikey({ id, controller, keys });
145782
145804
  }
145783
145805
  /**
@@ -145868,9 +145890,9 @@ a=end-of-candidates
145868
145890
  throw new Error("Method not implemented." + txHex + keyUri);
145869
145891
  }
145870
145892
  /**
145871
- * Gets the key pair from the key store and returns a PublicKey.
145893
+ * Gets the key pair from the key store and returns a CompressedSecp256k1PublicKey.
145872
145894
  * @param {KeyIdentifier} keyUri The URI of the key to get the public key for.
145873
- * @returns {Promise<PublicKey>} The public key associated with the key URI.
145895
+ * @returns {Promise<CompressedSecp256k1PublicKey>} The public key associated with the key URI.
145874
145896
  */
145875
145897
  async getPublicKey(keyUri) {
145876
145898
  const key = await this.getKey(keyUri);
@@ -145987,11 +146009,11 @@ a=end-of-candidates
145987
146009
  }
145988
146010
  /**
145989
146011
  * Computes a multibase-compliant URI from a key.
145990
- * @param key A SchnorrKeyPair, PublicKey, or multibase string
146012
+ * @param key A SchnorrKeyPair, CompressedSecp256k1PublicKey, or multibase string
145991
146013
  * @returns {string} A multibase URI (e.g. 'urn:mb:zQ3s...')
145992
146014
  */
145993
146015
  static toMultibaseUri(data) {
145994
- const multibase = data instanceof SchnorrKeyPair ? data.publicKey.multibase : data instanceof PublicKey ? data.multibase : data;
146016
+ const multibase = data instanceof SchnorrKeyPair ? data.publicKey.multibase : data instanceof CompressedSecp256k1PublicKey ? data.multibase : data;
145995
146017
  return `${MULTIBASE_URI_PREFIX}${multibase}`;
145996
146018
  }
145997
146019
  /**
@@ -146134,7 +146156,7 @@ a=end-of-candidates
146134
146156
  const hashBytes = JSON.canonicalization.encode(import_buffer.Buffer.fromHex(UPDATE_PAYLOAD_HASH), "base58");
146135
146157
  const signalsMetadataMap = new Map(Object.entries(signalsMetadata));
146136
146158
  if (signalsMetadata) {
146137
- didUpdatePayload = signalsMetadataMap.get(signal.txid)?.btc1Update;
146159
+ didUpdatePayload = signalsMetadataMap.get(signal.txid)?.didUpdate;
146138
146160
  if (!didUpdatePayload) {
146139
146161
  throw new SingletonBeaconError("Update Payload not found in signal metadata.", "PROCESS_SIGNAL_ERROR");
146140
146162
  }
@@ -146213,7 +146235,7 @@ a=end-of-candidates
146213
146235
  if (!spentTx) {
146214
146236
  throw new SingletonBeaconError("Failed to send raw transaction.", "SEND_FAILED", { spentTx });
146215
146237
  }
146216
- return { [spentTx]: { btc1Update: didUpdatePayload } };
146238
+ return { [spentTx]: { didUpdate: didUpdatePayload } };
146217
146239
  }
146218
146240
  };
146219
146241
 
@@ -146932,7 +146954,7 @@ a=end-of-candidates
146932
146954
  // src/utils/identifier.ts
146933
146955
  var Identifier = class {
146934
146956
  /**
146935
- * Implements {@link https://dcdpr.github.io/did-btcr2/#didbtc1-identifier-encoding | 3.2 did:btcr2 Identifier Encoding}.
146957
+ * Implements {@link https://dcdpr.github.io/did-btcr2/#didbtcr2-identifier-encoding | 3.2 did:btcr2 Identifier Encoding}.
146936
146958
  *
146937
146959
  * A did:btcr2 DID consists of a did:btcr2 prefix, followed by an id-bech32 value, which is a Bech32m encoding of:
146938
146960
  * - the specification version;
@@ -146963,7 +146985,7 @@ a=end-of-candidates
146963
146985
  }
146964
146986
  if (idType === "KEY") {
146965
146987
  try {
146966
- new PublicKey(genesisBytes);
146988
+ new CompressedSecp256k1PublicKey(genesisBytes);
146967
146989
  } catch {
146968
146990
  throw new MethodError(
146969
146991
  'Expected "genesisBytes" to be a valid compressed secp256k1 public key',
@@ -146996,7 +147018,7 @@ a=end-of-candidates
146996
147018
  return `did:btcr2:${bech32m3.encodeFromBytes(hrp, dataBytes)}`;
146997
147019
  }
146998
147020
  /**
146999
- * Implements {@link https://dcdpr.github.io/did-btcr2/#didbtc1-identifier-decoding | 3.3 did:btcr2 Identifier Decoding}.
147021
+ * Implements {@link https://dcdpr.github.io/did-btcr2/#didbtcr2-identifier-decoding | 3.3 did:btcr2 Identifier Decoding}.
147000
147022
  * @param {string} identifier The BTCR2 DID to be parsed
147001
147023
  * @returns {DidComponents} The parsed identifier components. See {@link DidComponents} for details.
147002
147024
  * @throws {DidError} if an error occurs while parsing the identifier
@@ -147065,7 +147087,7 @@ a=end-of-candidates
147065
147087
  const genesisBytes = dataBytes.slice(byteIndex + 1);
147066
147088
  if (idType === "KEY") {
147067
147089
  try {
147068
- new PublicKey(genesisBytes);
147090
+ new CompressedSecp256k1PublicKey(genesisBytes);
147069
147091
  } catch {
147070
147092
  throw new MethodError(`Invalid genesisBytes: ${genesisBytes}`, INVALID_DID, { identifier });
147071
147093
  }
@@ -147090,7 +147112,7 @@ a=end-of-candidates
147090
147112
 
147091
147113
  // src/utils/did-document.ts
147092
147114
  var BECH32M_CHARS = "";
147093
- var BTC1_DID_REGEX = /did:btcr2:(x1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]*)/g;
147115
+ var DID_REGEX = /did:btcr2:(x1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]*)/g;
147094
147116
  var DidVerificationMethod = class {
147095
147117
  id;
147096
147118
  type;
@@ -147373,7 +147395,7 @@ a=end-of-candidates
147373
147395
  };
147374
147396
  var IntermediateDidDocument = class _IntermediateDidDocument extends DidDocument2 {
147375
147397
  constructor(document2) {
147376
- const intermediateDocument = JSON.cloneReplace(document2, BTC1_DID_REGEX, ID_PLACEHOLDER_VALUE);
147398
+ const intermediateDocument = JSON.cloneReplace(document2, DID_REGEX, ID_PLACEHOLDER_VALUE);
147377
147399
  super(intermediateDocument);
147378
147400
  }
147379
147401
  /**
@@ -147426,7 +147448,7 @@ a=end-of-candidates
147426
147448
  const { version: version3 = 1, network = "bitcoin" } = options2;
147427
147449
  const idType = IdentifierTypes.KEY;
147428
147450
  const identifier = Identifier.encode({ version: version3, network, idType, genesisBytes: pubKeyBytes });
147429
- const { compressed: publicKey2, multibase: publicKeyMultibase } = new PublicKey(pubKeyBytes);
147451
+ const { compressed: publicKey2, multibase: publicKeyMultibase } = new CompressedSecp256k1PublicKey(pubKeyBytes);
147430
147452
  const service = BeaconUtils.generateBeaconServices({
147431
147453
  identifier,
147432
147454
  publicKey: publicKey2,
@@ -147440,7 +147462,7 @@ a=end-of-candidates
147440
147462
  id: `${identifier}#initialKey`,
147441
147463
  type: "Multikey",
147442
147464
  controller: identifier,
147443
- publicKeyMultibase: publicKeyMultibase.address
147465
+ publicKeyMultibase: publicKeyMultibase.encoded
147444
147466
  }],
147445
147467
  service
147446
147468
  });
@@ -147480,7 +147502,7 @@ a=end-of-candidates
147480
147502
 
147481
147503
  // src/did-btcr2.ts
147482
147504
  init_shim();
147483
- var tinysecp3 = __toESM(require_dist2(), 1);
147505
+ var tinysecp4 = __toESM(require_dist2(), 1);
147484
147506
 
147485
147507
  // src/core/crud/read.ts
147486
147508
  init_shim();
@@ -147500,7 +147522,7 @@ a=end-of-candidates
147500
147522
  */
147501
147523
  static deterministic({ identifier, identifierComponents }) {
147502
147524
  const { network, genesisBytes } = identifierComponents;
147503
- const { compressed: publicKey2, multibase: publicKeyMultibase } = new PublicKey(genesisBytes);
147525
+ const { compressed: publicKey2, multibase: publicKeyMultibase } = new CompressedSecp256k1PublicKey(genesisBytes);
147504
147526
  const service = BeaconUtils.generateBeaconServices({
147505
147527
  identifier,
147506
147528
  publicKey: publicKey2,
@@ -147514,7 +147536,7 @@ a=end-of-candidates
147514
147536
  id: `${identifier}#initialKey`,
147515
147537
  type: "Multikey",
147516
147538
  controller: identifier,
147517
- publicKeyMultibase: publicKeyMultibase.address
147539
+ publicKeyMultibase: publicKeyMultibase.encoded
147518
147540
  }],
147519
147541
  service
147520
147542
  });
@@ -147650,7 +147672,7 @@ a=end-of-candidates
147650
147672
  targetVersionId,
147651
147673
  targetTime,
147652
147674
  didDocumentHistory: new Array(),
147653
- btc1UpdateHashHistory: new Array(),
147675
+ updateHashHistory: new Array(),
147654
147676
  signalsMetadata,
147655
147677
  network
147656
147678
  });
@@ -147682,7 +147704,7 @@ a=end-of-candidates
147682
147704
  * @param {UnixTimestamp} params.targetTime The timestamp used to target specific historical states of a DID document.
147683
147705
  * Only Beacon Signals included in the Bitcoin blockchain before the targetTime are processed.
147684
147706
  * @param {boolean} params.didDocumentHistory An array of DID documents ordered ascensing by version (1...N).
147685
- * @param {boolean} params.btc1UpdateHashHistory An array of SHA256 hashes of BTCR2 Updates ordered by version that are
147707
+ * @param {boolean} params.updateHashHistory An array of SHA256 hashes of BTCR2 Updates ordered by version that are
147686
147708
  * applied to the DID document in order to construct the contemporaryDIDDocument.
147687
147709
  * @param {SignalsMetadata} params.signalsMetadata See {@link SignalsMetadata} for details.
147688
147710
  * @param {string} params.network The bitcoin network to connect to (mainnet, signet, testnet, regtest).
@@ -147695,7 +147717,7 @@ a=end-of-candidates
147695
147717
  targetVersionId,
147696
147718
  targetTime,
147697
147719
  didDocumentHistory,
147698
- btc1UpdateHashHistory,
147720
+ updateHashHistory,
147699
147721
  signalsMetadata,
147700
147722
  network
147701
147723
  }) {
@@ -147718,8 +147740,8 @@ a=end-of-candidates
147718
147740
  for (let update of orderedUpdates) {
147719
147741
  const updateTargetVersionId = update.targetVersionId;
147720
147742
  if (updateTargetVersionId <= currentVersionId) {
147721
- btc1UpdateHashHistory.push(contemporaryHash);
147722
- await this.confirmDuplicateUpdate({ update, updateHashHistory: btc1UpdateHashHistory });
147743
+ updateHashHistory.push(contemporaryHash);
147744
+ await this.confirmDuplicateUpdate({ update, updateHashHistory });
147723
147745
  } else if (updateTargetVersionId === currentVersionId + 1) {
147724
147746
  const sourceHash = update.sourceHash.startsWith("z") ? update.sourceHash : `z${update.sourceHash}`;
147725
147747
  if (sourceHash !== contemporaryHash) {
@@ -147735,7 +147757,7 @@ a=end-of-candidates
147735
147757
  const unsecuredUpdate = update;
147736
147758
  delete unsecuredUpdate.proof;
147737
147759
  const updateHash = await JSON.canonicalization.process(update, "base58");
147738
- btc1UpdateHashHistory.push(updateHash);
147760
+ updateHashHistory.push(updateHash);
147739
147761
  contemporaryHash = await JSON.canonicalization.process(contemporaryDidDocument, "base58");
147740
147762
  } else if (update.targetVersionId > currentVersionId + 1) {
147741
147763
  throw new ResolveError(
@@ -147921,12 +147943,12 @@ a=end-of-candidates
147921
147943
  const sidecar = { signalsMetadata };
147922
147944
  const service = { id, type, serviceEndpoint: `bitcoin:${address}` };
147923
147945
  const beacon = BeaconFactory.establish(service, sidecar);
147924
- const btc1Update = await beacon.processSignal(signalTx, signalsMetadata) ?? null;
147925
- if (!btc1Update) {
147926
- throw new MethodError("No btc1Update for beacon", "PROCESS_BEACON_SIGNALS_ERROR", { tx, signalsMetadata });
147946
+ const didUpdate = await beacon.processSignal(signalTx, signalsMetadata) ?? null;
147947
+ if (!didUpdate) {
147948
+ throw new MethodError("No didUpdate for beacon", "PROCESS_BEACON_SIGNALS_ERROR", { tx, signalsMetadata });
147927
147949
  }
147928
- updates.push(btc1Update);
147929
- return btc1Update;
147950
+ updates.push(didUpdate);
147951
+ return didUpdate;
147930
147952
  }
147931
147953
  /**
147932
147954
  * Implements {@link https://dcdpr.github.io/did-btcr2/#confirm-duplicate-update | 7.2.2.4 Confirm Duplicate Update}.
@@ -147941,7 +147963,7 @@ a=end-of-candidates
147941
147963
  * @param {DidUpdatePayload} params.update The DID Update Payload to confirm.
147942
147964
  * @param {Array<string>} params.updateHashHistory The history of hashes for previously applied updates.
147943
147965
  * @returns {Promise<void>} A promise that resolves if the update is a duplicate, otherwise throws an error.
147944
- * @throws {DidBtc1Error} if the update hash does not match the historical hash.
147966
+ * @throws {ResolveError} if the update hash does not match the historical hash.
147945
147967
  */
147946
147968
  static async confirmDuplicateUpdate({ update, updateHashHistory }) {
147947
147969
  const unsecuredUpdate = update;
@@ -148089,7 +148111,7 @@ a=end-of-candidates
148089
148111
  id,
148090
148112
  controller,
148091
148113
  keys: new SchnorrKeyPair({
148092
- secretKey: SecretKey.decode(secretKeyMultibase)
148114
+ secretKey: Secp256k1SecretKey.decode(secretKeyMultibase)
148093
148115
  })
148094
148116
  });
148095
148117
  if (!multikey) {
@@ -148158,7 +148180,7 @@ a=end-of-candidates
148158
148180
  };
148159
148181
 
148160
148182
  // src/did-btcr2.ts
148161
- initEccLib(tinysecp3);
148183
+ initEccLib(tinysecp4);
148162
148184
  var DidBtcr2 = class {
148163
148185
  /** @type {string} Name of the DID method, as defined in the DID BTCR2 specification */
148164
148186
  static methodName = "btcr2";
@@ -148263,7 +148285,7 @@ a=end-of-candidates
148263
148285
  * @param {string} params.identifier The btcr2 identifier to be updated.
148264
148286
  * @param {DidDocument} params.sourceDocument The DID document being updated.
148265
148287
  * @param {string} params.sourceVersionId The versionId of the source document.
148266
- * @param {Btc1DocumentPatch} params.documentPatch The JSON patch to be applied to the source document.
148288
+ * @param {PatchOperation} params.documentPatch The JSON patch to be applied to the source document.
148267
148289
  * @param {string} params.verificationMethodId The verificationMethod ID to sign the update
148268
148290
  * @param {string[]} params.beaconIds The beacon IDs to announce the update
148269
148291
  * @returns {Promise<void>} Promise resolving to void
@@ -148331,7 +148353,7 @@ a=end-of-candidates
148331
148353
  };
148332
148354
 
148333
148355
  // src/core/crud/deactivate.ts
148334
- var Btc1Deactivate = class extends DidBtcr2 {
148356
+ var Deactivate = class extends DidBtcr2 {
148335
148357
  };
148336
148358
 
148337
148359
  // src/core/key-manager/interface.ts
@@ -148348,7 +148370,7 @@ a=end-of-candidates
148348
148370
 
148349
148371
  // src/utils/did-document-builder.ts
148350
148372
  init_shim();
148351
- var Btc1DidDocumentBuilder = class {
148373
+ var DidDocumentBuilder = class {
148352
148374
  document = {};
148353
148375
  constructor(initialDocument) {
148354
148376
  if (!initialDocument.id) {