@did-btcr2/method 0.23.0 → 0.25.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 (160) hide show
  1. package/README.md +96 -50
  2. package/dist/browser.js +36332 -37280
  3. package/dist/browser.mjs +36331 -37279
  4. package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js +1 -1
  5. package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -1
  6. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +1 -1
  7. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
  8. package/dist/cjs/core/beacon/aggregation/coordinator.js +40 -44
  9. package/dist/cjs/core/beacon/aggregation/coordinator.js.map +1 -1
  10. package/dist/cjs/core/beacon/aggregation/participant.js +35 -38
  11. package/dist/cjs/core/beacon/aggregation/participant.js.map +1 -1
  12. package/dist/cjs/core/beacon/aggregation/session/index.js +3 -4
  13. package/dist/cjs/core/beacon/aggregation/session/index.js.map +1 -1
  14. package/dist/cjs/core/beacon/beacon.js.map +1 -1
  15. package/dist/cjs/core/beacon/cas-beacon.js +119 -7
  16. package/dist/cjs/core/beacon/cas-beacon.js.map +1 -1
  17. package/dist/cjs/core/beacon/factory.js +1 -1
  18. package/dist/cjs/core/beacon/factory.js.map +1 -1
  19. package/dist/cjs/core/beacon/{singleton.js → singleton-beacon.js} +19 -27
  20. package/dist/cjs/core/beacon/singleton-beacon.js.map +1 -0
  21. package/dist/cjs/core/beacon/smt-beacon.js +1 -1
  22. package/dist/cjs/core/beacon/smt-beacon.js.map +1 -1
  23. package/dist/cjs/core/identifier.js +1 -1
  24. package/dist/cjs/core/identifier.js.map +1 -1
  25. package/dist/{esm/core/resolve.js → cjs/core/resolver.js} +244 -92
  26. package/dist/cjs/core/resolver.js.map +1 -0
  27. package/dist/cjs/core/update.js +7 -7
  28. package/dist/cjs/core/update.js.map +1 -1
  29. package/dist/cjs/did-btcr2.js +34 -94
  30. package/dist/cjs/did-btcr2.js.map +1 -1
  31. package/dist/cjs/index.js +2 -3
  32. package/dist/cjs/index.js.map +1 -1
  33. package/dist/cjs/utils/did-document.js +9 -19
  34. package/dist/cjs/utils/did-document.js.map +1 -1
  35. package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js +1 -1
  36. package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -1
  37. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +1 -1
  38. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
  39. package/dist/esm/core/beacon/aggregation/coordinator.js +40 -44
  40. package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
  41. package/dist/esm/core/beacon/aggregation/participant.js +35 -38
  42. package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
  43. package/dist/esm/core/beacon/aggregation/session/index.js +3 -4
  44. package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -1
  45. package/dist/esm/core/beacon/beacon.js.map +1 -1
  46. package/dist/esm/core/beacon/cas-beacon.js +119 -7
  47. package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
  48. package/dist/esm/core/beacon/factory.js +1 -1
  49. package/dist/esm/core/beacon/factory.js.map +1 -1
  50. package/dist/esm/core/beacon/{singleton.js → singleton-beacon.js} +19 -27
  51. package/dist/esm/core/beacon/singleton-beacon.js.map +1 -0
  52. package/dist/esm/core/beacon/smt-beacon.js +1 -1
  53. package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
  54. package/dist/esm/core/identifier.js +1 -1
  55. package/dist/esm/core/identifier.js.map +1 -1
  56. package/dist/{cjs/core/resolve.js → esm/core/resolver.js} +244 -92
  57. package/dist/esm/core/resolver.js.map +1 -0
  58. package/dist/esm/core/update.js +7 -7
  59. package/dist/esm/core/update.js.map +1 -1
  60. package/dist/esm/did-btcr2.js +34 -94
  61. package/dist/esm/did-btcr2.js.map +1 -1
  62. package/dist/esm/index.js +2 -3
  63. package/dist/esm/index.js.map +1 -1
  64. package/dist/esm/utils/did-document.js +9 -19
  65. package/dist/esm/utils/did-document.js.map +1 -1
  66. package/dist/types/core/beacon/aggregation/cohort/index.d.ts +1 -0
  67. package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts +1 -0
  68. package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts +1 -0
  69. package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts +1 -0
  70. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts +1 -0
  71. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts +2 -2
  72. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -1
  73. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts +1 -0
  74. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts +1 -0
  75. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts +1 -0
  76. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts +1 -0
  77. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts +1 -0
  78. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts +1 -0
  79. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts +1 -0
  80. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts +1 -0
  81. package/dist/types/core/beacon/aggregation/cohort/status.d.ts +1 -0
  82. package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts +4 -3
  83. package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts.map +1 -1
  84. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +5 -3
  85. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -1
  86. package/dist/types/core/beacon/aggregation/communication/error.d.ts +1 -0
  87. package/dist/types/core/beacon/aggregation/communication/factory.d.ts +1 -0
  88. package/dist/types/core/beacon/aggregation/communication/service.d.ts +3 -2
  89. package/dist/types/core/beacon/aggregation/communication/service.d.ts.map +1 -1
  90. package/dist/types/core/beacon/aggregation/coordinator.d.ts +1 -0
  91. package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
  92. package/dist/types/core/beacon/aggregation/participant.d.ts +1 -0
  93. package/dist/types/core/beacon/aggregation/participant.d.ts.map +1 -1
  94. package/dist/types/core/beacon/aggregation/session/index.d.ts +1 -0
  95. package/dist/types/core/beacon/aggregation/session/index.d.ts.map +1 -1
  96. package/dist/types/core/beacon/aggregation/session/status.d.ts +1 -0
  97. package/dist/types/core/beacon/beacon.d.ts +10 -4
  98. package/dist/types/core/beacon/beacon.d.ts.map +1 -1
  99. package/dist/types/core/beacon/cas-beacon.d.ts +27 -7
  100. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
  101. package/dist/types/core/beacon/error.d.ts +1 -0
  102. package/dist/types/core/beacon/factory.d.ts +1 -0
  103. package/dist/types/core/beacon/interfaces.d.ts +1 -0
  104. package/dist/types/core/beacon/signal-discovery.d.ts +1 -0
  105. package/dist/types/core/beacon/{singleton.d.ts → singleton-beacon.d.ts} +7 -5
  106. package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -0
  107. package/dist/types/core/beacon/smt-beacon.d.ts +5 -3
  108. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
  109. package/dist/types/core/beacon/utils.d.ts +1 -0
  110. package/dist/types/core/identifier.d.ts +1 -0
  111. package/dist/types/core/interfaces.d.ts +6 -15
  112. package/dist/types/core/interfaces.d.ts.map +1 -1
  113. package/dist/types/core/resolver.d.ts +167 -0
  114. package/dist/types/core/resolver.d.ts.map +1 -0
  115. package/dist/types/core/types.d.ts +1 -0
  116. package/dist/types/core/update.d.ts +4 -3
  117. package/dist/types/core/update.d.ts.map +1 -1
  118. package/dist/types/did-btcr2.d.ts +17 -16
  119. package/dist/types/did-btcr2.d.ts.map +1 -1
  120. package/dist/types/index.d.ts +3 -3
  121. package/dist/types/index.d.ts.map +1 -1
  122. package/dist/types/utils/appendix.d.ts +1 -0
  123. package/dist/types/utils/did-document-builder.d.ts +1 -0
  124. package/dist/types/utils/did-document.d.ts +2 -6
  125. package/dist/types/utils/did-document.d.ts.map +1 -1
  126. package/package.json +5 -5
  127. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +1 -1
  128. package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +4 -3
  129. package/src/core/beacon/aggregation/communication/adapter/nostr.ts +4 -3
  130. package/src/core/beacon/aggregation/communication/service.ts +2 -2
  131. package/src/core/beacon/aggregation/coordinator.ts +40 -44
  132. package/src/core/beacon/aggregation/participant.ts +38 -40
  133. package/src/core/beacon/aggregation/session/index.ts +3 -4
  134. package/src/core/beacon/beacon.ts +9 -5
  135. package/src/core/beacon/cas-beacon.ts +156 -10
  136. package/src/core/beacon/factory.ts +1 -1
  137. package/src/core/beacon/{singleton.ts → singleton-beacon.ts} +20 -36
  138. package/src/core/beacon/smt-beacon.ts +4 -3
  139. package/src/core/identifier.ts +1 -1
  140. package/src/core/interfaces.ts +5 -16
  141. package/src/core/resolver.ts +706 -0
  142. package/src/core/update.ts +9 -9
  143. package/src/did-btcr2.ts +37 -130
  144. package/src/index.ts +2 -3
  145. package/src/utils/did-document.ts +10 -18
  146. package/dist/cjs/core/beacon/singleton.js.map +0 -1
  147. package/dist/cjs/core/resolve.js.map +0 -1
  148. package/dist/cjs/utils/general.js +0 -195
  149. package/dist/cjs/utils/general.js.map +0 -1
  150. package/dist/esm/core/beacon/singleton.js.map +0 -1
  151. package/dist/esm/core/resolve.js.map +0 -1
  152. package/dist/esm/utils/general.js +0 -195
  153. package/dist/esm/utils/general.js.map +0 -1
  154. package/dist/types/core/beacon/singleton.d.ts.map +0 -1
  155. package/dist/types/core/resolve.d.ts +0 -92
  156. package/dist/types/core/resolve.d.ts.map +0 -1
  157. package/dist/types/utils/general.d.ts +0 -85
  158. package/dist/types/utils/general.d.ts.map +0 -1
  159. package/src/core/resolve.ts +0 -474
  160. package/src/utils/general.ts +0 -204
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../src/core/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,EAGhB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAiB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAiB5D;;;;;;;;GAQG;AACH,MAAM,OAAO,OAAO;IAClB;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,aAA4B;QAC/C,kDAAkD;QAClD,MAAM,EAAE,YAAY,EAAE,GAAG,aAAa,CAAC;QAEvC,wCAAwC;QACxC,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;QA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3C,8DAA8D;QAC9D,IAAI,MAAM,CAAC,UAAU,KAAK,mBAAmB,EAAE,CAAC;YAC9C,wDAAwD;YACxD,MAAM,IAAI,YAAY,CACpB,2DAA2D,EAC3D,kBAAkB,EAAE,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,CAC9D,CAAC;QACJ,CAAC;QAED,iCAAiC;QACjC,OAAO,eAAe,CAAC;IACzB,CAAC;CACF"}
@@ -1,195 +0,0 @@
1
- import { BIP340_PUBLIC_KEY_MULTIBASE_PREFIX } from '@did-btcr2/common';
2
- import { sha256 } from '@noble/hashes/sha2';
3
- import { CURVE, getPublicKey, utils } from '@noble/secp256k1';
4
- import { HDKey } from '@scure/bip32';
5
- import { generateMnemonic, mnemonicToSeed } from '@scure/bip39';
6
- import { wordlist } from '@scure/bip39/wordlists/english';
7
- import { base58btc } from 'multiformats/bases/base58';
8
- /**
9
- * Static class of general utility functions for the did-btcr2 spec implementation
10
- * @class GeneralUtils
11
- * @type {GeneralUtils}
12
- */
13
- export class GeneralUtils {
14
- /**
15
- * Helper function to encode a secp256k1 key in SchnorrSecp256k1 Multikey Format
16
- * @param {KeyBytes} xOnlyKeyBytes
17
- * @returns {PublicKeyMultibase}
18
- */
19
- static encode(xOnlyKeyBytes) {
20
- if (xOnlyKeyBytes.length !== 32) {
21
- throw new Error('x-only public key must be 32 bytes');
22
- }
23
- const prefix = Array.from(BIP340_PUBLIC_KEY_MULTIBASE_PREFIX);
24
- const x = Array.from(xOnlyKeyBytes);
25
- // Set the prefix and the public key bytes
26
- const multikeyBytes = new Uint8Array([...prefix, ...x]);
27
- // Encode the public key as a multibase base58btc string
28
- return base58btc.encode(multikeyBytes);
29
- }
30
- /**
31
- * Converts a bigint to a buffer
32
- * @param {bigint} value The bigint to convert
33
- * @returns {Buffer} The buffer representation of the bigint
34
- */
35
- static bigintToBuffer(value) {
36
- const hex = value.toString(16).padStart(64, '0');
37
- return Buffer.from(hex, 'hex');
38
- }
39
- /**
40
- * Generates a new mnemonic phrase and HD wallet
41
- * @returns {HdWallet} Promise resolving to a new hdwallet object w/ mnemonic and hdkey
42
- * @throws {Error} if the public key bytes cannot be derived
43
- */
44
- static async generateHdWallet() {
45
- // Generate random mnemonic phrase.
46
- const mnemonic = generateMnemonic(wordlist, 128);
47
- // Generate seed from random mnemonic phrase.
48
- const seed = await mnemonicToSeed(mnemonic);
49
- // Generate HDKey from seed.
50
- const hdkey = HDKey.fromMasterSeed(seed);
51
- // Ensure HDKey returns valid
52
- if (!hdkey) {
53
- throw new Error('Failed to derive hd wallet');
54
- }
55
- return { mnemonic, hdkey };
56
- }
57
- static generateCompressedSecp256k1KeyPair() {
58
- const privateKey = utils.randomPrivateKey();
59
- if (!utils.isValidPrivateKey(privateKey)) {
60
- throw new Error('Invalid private key');
61
- }
62
- return { privateKey, publicKey: getPublicKey(privateKey, true) };
63
- }
64
- ;
65
- /**
66
- * Recovers an HDKey from a mnemonic phrase
67
- * @param {string} mnemonic The mnemonic phrase to recover the HDKey from
68
- * @param {Uint8Array} seed Optional seed to recover the HDKey from
69
- * @returns {HDKey} Promise resolving to the recovered HDKey
70
- * @throws Error if the HDKey cannot be recovered
71
- */
72
- static async recoverHdWallet(mnemonic, seed) {
73
- seed ??= await mnemonicToSeed(mnemonic);
74
- // Generate HDKey from seed.
75
- const hdkey = HDKey.fromMasterSeed(seed);
76
- // Ensure HDKey returns valid
77
- if (!hdkey) {
78
- throw new Error('Failed to recover hdkey');
79
- }
80
- // Return the HDKey
81
- return hdkey;
82
- }
83
- /**
84
- * Recovers a secp256k1 privateKey from its original entropy
85
- * @param {Uint8Array} xorEntropy The original entropy to recover the privateKey from
86
- * @param {Uint8Array} salt The salt used to tweak the privateKey
87
- * @returns {Uint8Array} The recovered privateKey
88
- * @throws {Error} if the privateKey cannot be recovered
89
- */
90
- static recoverTweakedRawPrivateKey(xorEntropy, salt) {
91
- // If entropy is not 32 bytes, hash it to get a deterministic 32-byte private key
92
- if (xorEntropy.length !== 32) {
93
- xorEntropy = sha256(xorEntropy);
94
- }
95
- const entropy = this.XNOR(xorEntropy, salt);
96
- // Convert entropy to hex
97
- const hexEntropy = Buffer.from(entropy).toString('hex');
98
- // Convert hexEntropy to BigInt
99
- const privateKey = BigInt(`0x${hexEntropy}`);
100
- // Ensure private key is in valid secp256k1 range1
101
- if (privateKey < BigInt(1) || privateKey >= CURVE.n) {
102
- throw new Error('Invalid private key derived from entropy');
103
- }
104
- // The valid 32-byte private key
105
- return entropy;
106
- }
107
- /**
108
- * Recovers a secp256k1 privateKey from its original entropy
109
- * @param {Uint8Array} entropy The entropy to recover the privateKey from
110
- * @returns {Uint8Array} The recovered privateKey
111
- * @throws {Error} if the privateKey cannot be recovered
112
- */
113
- static recoverRawPrivateKey(entropy) {
114
- // If entropy is not 32 bytes, hash it to get a deterministic 32-byte private key
115
- if (entropy.length !== 32) {
116
- entropy = sha256(entropy);
117
- }
118
- // Convert entropy to hex
119
- const hexEntropy = Buffer.from(entropy).toString('hex');
120
- // Convert hexEntropy to BigInt
121
- const privateKey = BigInt(`0x${hexEntropy}`);
122
- // Ensure private key is in valid secp256k1 range1
123
- if (privateKey < BigInt(1) || privateKey >= CURVE.n) {
124
- throw new Error('Invalid private key derived from entropy');
125
- }
126
- // The valid 32-byte private key
127
- return entropy;
128
- }
129
- /**
130
- * Tweak the entropy with a salt using XOR
131
- * @param {Uint8Array} entropy The entropy to tweak
132
- * @param {Uint8Array} salt The salt to tweak the entropy with
133
- * @returns {Uint8Array} The tweaked entropy
134
- */
135
- static XOR(entropy, salt) {
136
- const tweaked = new Uint8Array(entropy.length);
137
- for (let i = 0; i < entropy.length; i++) {
138
- tweaked[i] = entropy[i] ^ salt[i % salt.length]; // XOR with repeating salt
139
- }
140
- return tweaked;
141
- }
142
- /**
143
- * Untweak the entropy with a salt using XNOR
144
- *
145
- * @param {Uint8Array} tweakedEntropy The tweaked entropy to untweak
146
- * @param {Uint8Array} salt The salt to untweak the entropy with
147
- * @returns {Uint8Array} The original entropy
148
- */
149
- static XNOR(tweakedEntropy, salt) {
150
- const originalEntropy = new Uint8Array(tweakedEntropy.length);
151
- for (let i = 0; i < tweakedEntropy.length; i++) {
152
- originalEntropy[i] = tweakedEntropy[i] ^ salt[i % salt.length]; // XOR with salt again
153
- }
154
- return originalEntropy;
155
- }
156
- /**
157
- * Recovers an HDKey from a mnemonic phrase
158
- * @param {string} mnemonic The mnemonic phrase to recover the HDKey from
159
- * @param {string} path The path to derive the child key from
160
- * @returns {Uint8Array} Promise resolving to the recovered private key bytes
161
- * @throws {Error} if the HDKey cannot be recovered
162
- */
163
- static async recoverHdChildFromMnemonic(mnemonic, path) {
164
- // Generate HDKey from seed.
165
- const hdkey = await this.recoverHdWallet(mnemonic);
166
- // Ensure HDKey returns valid
167
- if (!hdkey) {
168
- throw new Error('Failed to recover hdkey');
169
- }
170
- // Return the privateKey of the derived childKey
171
- const childPrivKeyBytes = hdkey.derive(path).privateKey;
172
- if (!childPrivKeyBytes) {
173
- throw new Error('Failed to recover child private key');
174
- }
175
- return childPrivKeyBytes;
176
- }
177
- /**
178
- * Derives a child key from an HDKey
179
- * @param {HDKey} hdkey The HDKey to derive the child key from
180
- * @param {string} path The path to derive the child key from
181
- * @returns {HDKey} A Promise resolving to the child key
182
- * @throws {Error} Error if the child key cannot be derived
183
- */
184
- static deriveChildKey(hdkey, path) {
185
- // Derive child key from HDKey.
186
- const childKey = hdkey.derive(path);
187
- // Ensure child key returns valid
188
- if (!childKey) {
189
- throw new Error(`Failed to derive child key`);
190
- }
191
- // Return the child key
192
- return childKey;
193
- }
194
- }
195
- //# sourceMappingURL=general.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"general.js","sourceRoot":"","sources":["../../../src/utils/general.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,kCAAkC,EAAY,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EA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C,+BAA+B;QAC/B,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpC,iCAAiC;QACjC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QACD,uBAAuB;QACvB,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/singleton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAA0C,QAAQ,EAAuB,MAAM,mBAAmB,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAI3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE7E;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,MAAM;IAEzC;;;;OAIG;gBACS,OAAO,EAAE,aAAa;IAIlC;;;;OAIG;IACG,cAAc,CAClB,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,EAC5B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC,CAAC;IA0CrD;;;;;;;OAOG;IACG,eAAe,CACnB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,QAAQ,EACnB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,iBAAiB,CAAC;CAsE9B"}
@@ -1,92 +0,0 @@
1
- import { BitcoinConnection } from '@did-btcr2/bitcoin';
2
- import { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
3
- import { DidDocument } from '../utils/did-document.js';
4
- import { BeaconService, BlockMetadata } from './beacon/interfaces.js';
5
- import { DidComponents } from './identifier.js';
6
- import { Sidecar, SidecarData } from './types.js';
7
- /**
8
- * The response object for DID Resolution.
9
- */
10
- export interface DidResolutionResponse {
11
- didDocument: DidDocument;
12
- metadata: {
13
- confirmations?: number;
14
- versionId: string;
15
- updated?: string;
16
- deactivated?: boolean;
17
- };
18
- }
19
- /**
20
- * Implements {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html | 7.2 Resolve}.
21
- * Resolving a did:btcr2 identifier iteratively builds a DID document by applying BTCR2 Updates
22
- * to an Initial DID Document that have been committed to the Bitcoin blockchain by Authorized
23
- * Beacon Signals. The Initial DID Document is either deterministically created from the DID or
24
- * provided by Sidecar Data.
25
- * @class Resolve
26
- * @type {Resolve}
27
- */
28
- export declare class Resolve {
29
- /**
30
- * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#if-genesis_bytes-is-a-secp256k1-public-key | 7.2.d.1 if genesis bytes is a secp256k1 Public Key}.
31
- * @param {DidComponents} didComponents The decoded components of the did.
32
- * @returns {DidDocument} The resolved DID Document object.
33
- */
34
- static deterministic(didComponents: DidComponents): DidDocument;
35
- /**
36
- * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#if-genesis_bytes-is-a-sha-256-hash | 7.2.d.2 if genesis_bytes is a SHA-256 Hash}.
37
- * @param {DidComponents} didComponents BTCR2 DID components used to resolve the DID Document
38
- * @param {GenesisDocument} genesisDocument The genesis document for resolving the DID Document.
39
- * @returns {Promise<DidDocument>} The resolved DID Document object
40
- * @throws {ResolveError} InvalidDidDocument if not conformant to DID Core v1.1
41
- */
42
- static external(didComponents: DidComponents, genesisDocument: object): Promise<DidDocument>;
43
- /**
44
- * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-sidecar-data | Process Sidecar Data}
45
- * @param {Sidecar} sidecar The sidecar data to process.
46
- * @returns {ProcessedSidecar} The processed sidecar data containing maps of updates, CAS announcements, and SMT proofs.
47
- */
48
- static sidecarData(sidecar?: Sidecar): SidecarData;
49
- /**
50
- * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#establish-current-document | 7.2.d Establish current_document}.
51
- * Resolution begins by creating an Initial Did Document called current_document (Current DID Document).
52
- * The current_document is iteratively patched with BTCR2 Signed Updates announced by Authorized Beacon Signals.
53
- * @param {DidComponents} didComponents The decoded components of the did.
54
- * @param {GenesisDocument} genesisDocument The genesis document for resolving the DID Document.
55
- * @returns {Promise<DidDocument>} The resolved DID Document object.
56
- * @throws {ResolveError} if the DID hrp is invalid, no sidecarData passed and hrp = "x".
57
- */
58
- static currentDocument(didComponents: DidComponents, genesisDocument?: object): Promise<DidDocument>;
59
- /**
60
- * Finds uses the beacon services in the currentDocument to scan for onchain Beacon Signals (transactions) containing
61
- * Signal Bytes (last output in OP_RETURN transaction).
62
- * @param {Array<BeaconService>} beaconServices The array of BeaconService objects to search for signals.
63
- * @param {SidecarData} sidecarData The sidecar data containing maps of updates, CAS announcements, and SMT proofs.
64
- * @param {BitcoinConnection} bitcoin The bitcoin network connection used to fetch beacon signals
65
- * @returns {Promise<Array<[SignedBTCR2Update, BlockMetadata]>>} The array of BTCR2 Signed Updates announced by the Beacon Signals.
66
- */
67
- static beaconSignals(beaconServices: Array<BeaconService>, sidecarData: SidecarData, bitcoin: BitcoinConnection): Promise<Array<[SignedBTCR2Update, BlockMetadata]>>;
68
- /**
69
- * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-updates | 7.2.f Process updates Array}.
70
- * @param {DidDocument} currentDocument The current DID Document to apply the updates to.
71
- * @param {Array<[SignedBTCR2Update, BlockMetadata]>} unsortedUpdates The unsorted array of BTCR2 Signed Updates and their associated Block Metadata.
72
- * @param {string} [versionTime] The optional version time to limit updates to.
73
- * @param {string} [versionId] The optional version id to limit updates to.
74
- * @returns {Promise<DidResolutionResponse>} The updated DID Document, number of confirmations, and version id.
75
- */
76
- static updates(currentDocument: DidDocument, unsortedUpdates: Array<[SignedBTCR2Update, BlockMetadata]>, versionTime?: string, versionId?: string): Promise<DidResolutionResponse>;
77
- /**
78
- * Implements subsection {@link https://dcdpr.github.io/did-btcr2/#confirm-duplicate-update | 7.2.f.1 Confirm Duplicate Update}.
79
- * This step confirms that an update with a lower-than-expected targetVersionId is a true duplicate.
80
- * @param {SignedBTCR2Update} update The BTCR2 Signed Update to confirm as a duplicate.
81
- * @returns {void} Does not return a value, but throws an error if the update is not a valid duplicate.
82
- */
83
- static confirmDuplicate(update: SignedBTCR2Update, updateHashHistory: string[]): void;
84
- /**
85
- * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#apply-update | 7.2.f.3 Apply Update}.
86
- * @param {DidDocument} currentDocument The current DID Document to apply the update to.
87
- * @param {SignedBTCR2Update} update The BTCR2 Signed Update to apply.
88
- * @returns {Promise<DidDocument>} The updated DID Document after applying the update.
89
- * @throws {ResolveError} If the update is invalid or cannot be applied.
90
- */
91
- static applyUpdate(currentDocument: DidDocument, update: SignedBTCR2Update): Promise<DidDocument>;
92
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/core/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAc5B,OAAO,EAIL,iBAAiB,EAElB,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EAAE,WAAW,EAAwB,MAAM,0BAA0B,CAAC;AAE7E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGtE,OAAO,EAAE,aAAa,EAAc,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EAAmB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE;QACR,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,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Wallet } from '@did-btcr2/common';
2
- import { HDKey } from '@scure/bip32';
3
- /**
4
- * Static class of general utility functions for the did-btcr2 spec implementation
5
- * @class GeneralUtils
6
- * @type {GeneralUtils}
7
- */
8
- export declare class GeneralUtils {
9
- /**
10
- * Helper function to encode a secp256k1 key in SchnorrSecp256k1 Multikey Format
11
- * @param {KeyBytes} xOnlyKeyBytes
12
- * @returns {PublicKeyMultibase}
13
- */
14
- static encode(xOnlyKeyBytes: KeyBytes): string;
15
- /**
16
- * Converts a bigint to a buffer
17
- * @param {bigint} value The bigint to convert
18
- * @returns {Buffer} The buffer representation of the bigint
19
- */
20
- static bigintToBuffer(value: bigint): Buffer;
21
- /**
22
- * Generates a new mnemonic phrase and HD wallet
23
- * @returns {HdWallet} Promise resolving to a new hdwallet object w/ mnemonic and hdkey
24
- * @throws {Error} if the public key bytes cannot be derived
25
- */
26
- static generateHdWallet(): Promise<HdWallet>;
27
- static generateCompressedSecp256k1KeyPair(): {
28
- privateKey: import("@noble/secp256k1").Bytes;
29
- publicKey: import("@noble/secp256k1").Bytes;
30
- };
31
- /**
32
- * Recovers an HDKey from a mnemonic phrase
33
- * @param {string} mnemonic The mnemonic phrase to recover the HDKey from
34
- * @param {Uint8Array} seed Optional seed to recover the HDKey from
35
- * @returns {HDKey} Promise resolving to the recovered HDKey
36
- * @throws Error if the HDKey cannot be recovered
37
- */
38
- static recoverHdWallet(mnemonic: string, seed?: Uint8Array): Promise<HDKey>;
39
- /**
40
- * Recovers a secp256k1 privateKey from its original entropy
41
- * @param {Uint8Array} xorEntropy The original entropy to recover the privateKey from
42
- * @param {Uint8Array} salt The salt used to tweak the privateKey
43
- * @returns {Uint8Array} The recovered privateKey
44
- * @throws {Error} if the privateKey cannot be recovered
45
- */
46
- static recoverTweakedRawPrivateKey(xorEntropy: Uint8Array, salt: Uint8Array): Uint8Array;
47
- /**
48
- * Recovers a secp256k1 privateKey from its original entropy
49
- * @param {Uint8Array} entropy The entropy to recover the privateKey from
50
- * @returns {Uint8Array} The recovered privateKey
51
- * @throws {Error} if the privateKey cannot be recovered
52
- */
53
- static recoverRawPrivateKey(entropy: Uint8Array): Uint8Array;
54
- /**
55
- * Tweak the entropy with a salt using XOR
56
- * @param {Uint8Array} entropy The entropy to tweak
57
- * @param {Uint8Array} salt The salt to tweak the entropy with
58
- * @returns {Uint8Array} The tweaked entropy
59
- */
60
- static XOR(entropy: Uint8Array, salt: Uint8Array): Uint8Array;
61
- /**
62
- * Untweak the entropy with a salt using XNOR
63
- *
64
- * @param {Uint8Array} tweakedEntropy The tweaked entropy to untweak
65
- * @param {Uint8Array} salt The salt to untweak the entropy with
66
- * @returns {Uint8Array} The original entropy
67
- */
68
- static XNOR(tweakedEntropy: Uint8Array, salt: Uint8Array): Uint8Array;
69
- /**
70
- * Recovers an HDKey from a mnemonic phrase
71
- * @param {string} mnemonic The mnemonic phrase to recover the HDKey from
72
- * @param {string} path The path to derive the child key from
73
- * @returns {Uint8Array} Promise resolving to the recovered private key bytes
74
- * @throws {Error} if the HDKey cannot be recovered
75
- */
76
- static recoverHdChildFromMnemonic(mnemonic: string, path: string): Promise<Uint8Array>;
77
- /**
78
- * Derives a child key from an HDKey
79
- * @param {HDKey} hdkey The HDKey to derive the child key from
80
- * @param {string} path The path to derive the child key from
81
- * @returns {HDKey} A Promise resolving to the child key
82
- * @throws {Error} Error if the child key cannot be derived
83
- */
84
- static deriveChildKey(hdkey: HDKey, path: string): HDKey;
85
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../src/utils/general.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsC,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG3F,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAKrC;;;;GAIG;AACH,qBAAa,YAAY;IACvB;;;;OAIG;WACW,MAAM,CAAC,aAAa,EAAE,QAAQ,GAAG,MAAM;IAYrD;;;;OAIG;IACH,MAAM,CAAC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