@bsv/sdk 1.1.15 → 1.1.16

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 (53) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/primitives/Point.js +28 -8
  3. package/dist/cjs/src/primitives/Point.js.map +1 -1
  4. package/dist/cjs/src/primitives/PublicKey.js +19 -3
  5. package/dist/cjs/src/primitives/PublicKey.js.map +1 -1
  6. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  7. package/dist/esm/src/primitives/Point.js +28 -8
  8. package/dist/esm/src/primitives/Point.js.map +1 -1
  9. package/dist/esm/src/primitives/PublicKey.js +19 -3
  10. package/dist/esm/src/primitives/PublicKey.js.map +1 -1
  11. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  12. package/dist/types/src/primitives/Point.d.ts +19 -1
  13. package/dist/types/src/primitives/Point.d.ts.map +1 -1
  14. package/dist/types/src/primitives/PublicKey.d.ts +15 -2
  15. package/dist/types/src/primitives/PublicKey.d.ts.map +1 -1
  16. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  17. package/docs/primitives.md +8 -3
  18. package/package.json +1 -1
  19. package/src/primitives/PublicKey.ts +5 -3
  20. package/dist/cjs/src/compat/BIP39.js +0 -272
  21. package/dist/cjs/src/compat/BIP39.js.map +0 -1
  22. package/dist/cjs/src/index.js +0 -5
  23. package/dist/cjs/src/index.js.map +0 -1
  24. package/dist/cjs/src/script/templates/P2PKHT.js +0 -99
  25. package/dist/cjs/src/script/templates/P2PKHT.js.map +0 -1
  26. package/dist/cjs/src/totp/converters.js +0 -14
  27. package/dist/cjs/src/totp/converters.js.map +0 -1
  28. package/dist/cjs/src/totp/pike-totp.js +0 -75
  29. package/dist/cjs/src/totp/pike-totp.js.map +0 -1
  30. package/dist/cjs/src/totp/types.js +0 -3
  31. package/dist/cjs/src/totp/types.js.map +0 -1
  32. package/dist/cjs/src/transaction/broadcasters/BRC22.js +0 -25
  33. package/dist/cjs/src/transaction/broadcasters/BRC22.js.map +0 -1
  34. package/dist/esm/src/compat/BIP39.js +0 -272
  35. package/dist/esm/src/compat/BIP39.js.map +0 -1
  36. package/dist/esm/src/script/templates/P2PKHT.js +0 -96
  37. package/dist/esm/src/script/templates/P2PKHT.js.map +0 -1
  38. package/dist/esm/src/totp/converters.js +0 -9
  39. package/dist/esm/src/totp/converters.js.map +0 -1
  40. package/dist/esm/src/totp/pike-totp.js +0 -67
  41. package/dist/esm/src/totp/pike-totp.js.map +0 -1
  42. package/dist/esm/src/totp/types.js +0 -2
  43. package/dist/esm/src/totp/types.js.map +0 -1
  44. package/dist/types/src/compat/BIP39.d.ts +0 -132
  45. package/dist/types/src/compat/BIP39.d.ts.map +0 -1
  46. package/dist/types/src/script/templates/P2PKHT.d.ts +0 -37
  47. package/dist/types/src/script/templates/P2PKHT.d.ts.map +0 -1
  48. package/dist/types/src/totp/converters.d.ts +0 -3
  49. package/dist/types/src/totp/converters.d.ts.map +0 -1
  50. package/dist/types/src/totp/pike-totp.d.ts +0 -25
  51. package/dist/types/src/totp/pike-totp.d.ts.map +0 -1
  52. package/dist/types/src/totp/types.d.ts +0 -11
  53. package/dist/types/src/totp/types.d.ts.map +0 -1
@@ -1,272 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const bip_39_wordlist_en_js_1 = require("./bip-39-wordlist-en.js");
4
- const utils_js_1 = require("../primitives/utils.js");
5
- const Hash = require("../primitives/Hash.js");
6
- const Random_js_1 = require("../primitives/Random.js");
7
- /**
8
- * @class BIP39
9
- *
10
- * @description
11
- * Class representing BIP39 functionality.
12
- * This class provides methods for generating, converting, and validating mnemonic phrases
13
- * according to the BIP39 standard. It supports creating mnemonics from random entropy,
14
- * converting mnemonics to seeds, and validating mnemonic phrases.
15
- */
16
- class BIP39 {
17
- /**
18
- * Constructs a BIP39 object.
19
- * @param {string} [mnemonic] - An optional mnemonic phrase.
20
- * @param {number[]} [seed] - An optional seed derived from the mnemonic.
21
- * @param {object} [wordlist=wordList] - An object containing a list of words and space character used in the mnemonic.
22
- */
23
- constructor(mnemonic, seed, wordlist = bip_39_wordlist_en_js_1.wordList) {
24
- this.mnemonic = mnemonic;
25
- this.seed = seed;
26
- this.Wordlist = wordlist;
27
- }
28
- /**
29
- * Converts the mnemonic and seed into a binary representation.
30
- * @returns {number[]} The binary representation of the mnemonic and seed.
31
- */
32
- toBinary() {
33
- const bw = new utils_js_1.Writer();
34
- if (this.mnemonic) {
35
- const buf = (0, utils_js_1.toArray)(this.mnemonic, 'utf8');
36
- bw.writeVarIntNum(buf.length);
37
- bw.write(buf);
38
- }
39
- else {
40
- bw.writeVarIntNum(0);
41
- }
42
- if (this.seed) {
43
- bw.writeVarIntNum(this.seed.length);
44
- bw.write(this.seed);
45
- }
46
- else {
47
- bw.writeVarIntNum(0);
48
- }
49
- return bw.toArray();
50
- }
51
- /**
52
- * Loads a mnemonic and seed from a binary representation.
53
- * @param {number[]} bin - The binary representation of a mnemonic and seed.
54
- * @returns {this} The BIP39 instance with loaded mnemonic and seed.
55
- */
56
- fromBinary(bin) {
57
- const br = new utils_js_1.Reader(bin);
58
- const mnemoniclen = br.readVarIntNum();
59
- if (mnemoniclen > 0) {
60
- this.mnemonic = (0, utils_js_1.encode)(br.read(mnemoniclen), 'utf8');
61
- }
62
- const seedlen = br.readVarIntNum();
63
- if (seedlen > 0) {
64
- this.seed = br.read(seedlen);
65
- }
66
- return this;
67
- }
68
- /**
69
- * Generates a random mnemonic from a given bit length.
70
- * @param {number} [bits=128] - The bit length for the random mnemonic (must be a multiple of 32 and at least 128).
71
- * @returns {this} The BIP39 instance with the new random mnemonic.
72
- * @throws {Error} If the bit length is not a multiple of 32 or is less than 128.
73
- */
74
- fromRandom(bits) {
75
- if (!bits) {
76
- bits = 128;
77
- }
78
- if (bits % 32 !== 0) {
79
- throw new Error('bits must be multiple of 32');
80
- }
81
- if (bits < 128) {
82
- throw new Error('bits must be at least 128');
83
- }
84
- const buf = (0, Random_js_1.default)(bits / 8);
85
- this.entropy2Mnemonic(buf);
86
- this.mnemonic2Seed();
87
- return this;
88
- }
89
- /**
90
- * Static method to generate a BIP39 instance with a random mnemonic.
91
- * @param {number} [bits=128] - The bit length for the random mnemonic.
92
- * @returns {BIP39} A new BIP39 instance.
93
- */
94
- static fromRandom(bits) {
95
- return new this().fromRandom(bits);
96
- }
97
- /**
98
- * Converts given entropy into a mnemonic phrase.
99
- * This method is used to generate a mnemonic from a specific entropy source.
100
- * @param {number[]} buf - The entropy buffer, must be at least 128 bits.
101
- * @returns {this} The BIP39 instance with the mnemonic set from the given entropy.
102
- * @throws {Error} If the entropy is less than 128 bits.
103
- */
104
- fromEntropy(buf) {
105
- this.entropy2Mnemonic(buf);
106
- return this;
107
- }
108
- /**
109
- * Static method to create a BIP39 instance from a given entropy.
110
- * @param {number[]} buf - The entropy buffer.
111
- * @returns {BIP39} A new BIP39 instance.
112
- */
113
- static fromEntropy(buf) {
114
- return new this().fromEntropy(buf);
115
- }
116
- /**
117
- * Sets the mnemonic for the instance from a string.
118
- * @param {string} mnemonic - The mnemonic phrase as a string.
119
- * @returns {this} The BIP39 instance with the set mnemonic.
120
- */
121
- fromString(mnemonic) {
122
- this.mnemonic = mnemonic;
123
- return this;
124
- }
125
- /**
126
- * Static method to create a BIP39 instance from a mnemonic string.
127
- * @param {string} str - The mnemonic phrase.
128
- * @returns {BIP39} A new BIP39 instance.
129
- */
130
- static fromString(str) {
131
- return new this().fromString(str);
132
- }
133
- /**
134
- * Converts the instance's mnemonic to a string representation.
135
- * @returns {string} The mnemonic phrase as a string.
136
- */
137
- toString() {
138
- return this.mnemonic;
139
- }
140
- /**
141
- * Converts the mnemonic to a seed.
142
- * The mnemonic must pass the validity check before conversion.
143
- * @param {string} [passphrase=''] - An optional passphrase for additional security.
144
- * @returns {number[]} The generated seed.
145
- * @throws {Error} If the mnemonic is invalid.
146
- */
147
- toSeed(passphrase) {
148
- this.mnemonic2Seed(passphrase);
149
- return this.seed;
150
- }
151
- /**
152
- * Converts entropy to a mnemonic phrase.
153
- * This method takes a buffer of entropy and converts it into a corresponding
154
- * mnemonic phrase based on the BIP39 wordlist. The entropy should be at least 128 bits.
155
- * The method applies a checksum and maps the entropy to words in the wordlist.
156
- * @param {number[]} buf - The entropy buffer to convert. Must be at least 128 bits.
157
- * @returns {this} The BIP39 instance with the mnemonic set from the entropy.
158
- * @throws {Error} If the entropy is less than 128 bits or if it's not an even multiple of 11 bits.
159
- */
160
- entropy2Mnemonic(buf) {
161
- if (buf.length < 128 / 8) {
162
- throw new Error('Entropy is less than 128 bits. It must be 128 bits or more.');
163
- }
164
- const hash = Hash.sha256(buf);
165
- let bin = '';
166
- const bits = buf.length * 8;
167
- for (let i = 0; i < buf.length; i++) {
168
- bin = bin + ('00000000' + buf[i].toString(2)).slice(-8);
169
- }
170
- let hashbits = hash[0].toString(2);
171
- hashbits = ('00000000' + hashbits).slice(-8).slice(0, bits / 32);
172
- bin = bin + hashbits;
173
- if (bin.length % 11 !== 0) {
174
- throw new Error('internal error - entropy not an even multiple of 11 bits - ' + bin.length);
175
- }
176
- let mnemonic = '';
177
- for (let i = 0; i < bin.length / 11; i++) {
178
- if (mnemonic !== '') {
179
- mnemonic = mnemonic + this.Wordlist.space;
180
- }
181
- const wi = parseInt(bin.slice(i * 11, (i + 1) * 11), 2);
182
- mnemonic = mnemonic + this.Wordlist.value[wi];
183
- }
184
- this.mnemonic = mnemonic;
185
- return this;
186
- }
187
- /**
188
- * Validates the mnemonic phrase.
189
- * Checks for correct length, absence of invalid words, and proper checksum.
190
- * @returns {boolean} True if the mnemonic is valid, false otherwise.
191
- * @throws {Error} If the mnemonic is not an even multiple of 11 bits.
192
- */
193
- check() {
194
- const mnemonic = this.mnemonic;
195
- // confirm no invalid words
196
- const words = mnemonic.split(this.Wordlist.space);
197
- let bin = '';
198
- for (let i = 0; i < words.length; i++) {
199
- const ind = this.Wordlist.value.indexOf(words[i]);
200
- if (ind < 0) {
201
- return false;
202
- }
203
- bin = bin + ('00000000000' + ind.toString(2)).slice(-11);
204
- }
205
- if (bin.length % 11 !== 0) {
206
- throw new Error('internal error - entropy not an even multiple of 11 bits - ' + bin.length);
207
- }
208
- // confirm checksum
209
- const cs = bin.length / 33;
210
- const hashBits = bin.slice(-cs);
211
- const nonhashBits = bin.slice(0, bin.length - cs);
212
- const buf = [];
213
- for (let i = 0; i < nonhashBits.length / 8; i++) {
214
- buf.push(parseInt(bin.slice(i * 8, (i + 1) * 8), 2));
215
- }
216
- const hash = Hash.sha256(buf.slice(0, nonhashBits.length / 8));
217
- let expectedHashBits = hash[0].toString(2);
218
- expectedHashBits = ('00000000' + expectedHashBits).slice(-8).slice(0, cs);
219
- return expectedHashBits === hashBits;
220
- }
221
- /**
222
- * Converts a mnemonic to a seed.
223
- * This method takes the instance's mnemonic phrase, combines it with a passphrase (if provided),
224
- * and uses PBKDF2 to generate a seed. It also validates the mnemonic before conversion.
225
- * This seed can then be used for generating deterministic keys.
226
- * @param {string} [passphrase=''] - An optional passphrase for added security.
227
- * @returns {this} The BIP39 instance with the seed generated from the mnemonic.
228
- * @throws {Error} If the mnemonic does not pass validation or if the passphrase is not a string.
229
- */
230
- mnemonic2Seed(passphrase = '') {
231
- let mnemonic = this.mnemonic;
232
- if (!this.check()) {
233
- throw new Error('Mnemonic does not pass the check - was the mnemonic typed incorrectly? Are there extra spaces?');
234
- }
235
- if (typeof passphrase !== 'string') {
236
- throw new Error('passphrase must be a string or undefined');
237
- }
238
- mnemonic = mnemonic.normalize('NFKD');
239
- passphrase = passphrase.normalize('NFKD');
240
- const mbuf = (0, utils_js_1.toArray)(mnemonic, 'utf8');
241
- const pbuf = [...(0, utils_js_1.toArray)('mnemonic', 'utf8'), ...(0, utils_js_1.toArray)(passphrase, 'utf8')];
242
- this.seed = Hash.pbkdf2(mbuf, pbuf, 2048, 64, 'sha512');
243
- return this;
244
- }
245
- /**
246
- * Determines the validity of a given passphrase with the mnemonic.
247
- * This method is useful for checking if a passphrase matches with the mnemonic.
248
- * @param {string} [passphrase=''] - The passphrase to validate.
249
- * @returns {boolean} True if the mnemonic and passphrase combination is valid, false otherwise.
250
- */
251
- isValid(passphrase = '') {
252
- let isValid;
253
- try {
254
- isValid = !!this.mnemonic2Seed(passphrase);
255
- }
256
- catch (err) {
257
- isValid = false;
258
- }
259
- return isValid;
260
- }
261
- /**
262
- * Static method to check the validity of a given mnemonic and passphrase combination.
263
- * @param {string} mnemonic - The mnemonic phrase.
264
- * @param {string} [passphrase=''] - The passphrase to validate.
265
- * @returns {boolean} True if the combination is valid, false otherwise.
266
- */
267
- static isValid(mnemonic, passphrase = '') {
268
- return new BIP39(mnemonic).isValid(passphrase);
269
- }
270
- }
271
- exports.default = BIP39;
272
- //# sourceMappingURL=BIP39.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BIP39.js","sourceRoot":"","sources":["../../../../src/compat/BIP39.ts"],"names":[],"mappings":";;AAAA,mEAAkD;AAClD,qDAAwE;AACxE,8CAA6C;AAC7C,uDAA4C;AAE5C;;;;;;;;GAQG;AACH,MAAqB,KAAK;IAKtB;;;;;OAKG;IACH,YAAY,QAAiB,EAAE,IAAe,EAAE,QAAQ,GAAG,gCAAQ;QAC/D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC5B,CAAC;IAED;;;OAGG;IACI,QAAQ;QACX,MAAM,EAAE,GAAG,IAAI,iBAAM,EAAE,CAAA;QACvB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,MAAM,GAAG,GAAG,IAAA,kBAAO,EAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;YAC1C,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YAC7B,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAA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AG,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QACzC,MAAM,IAAI,GAAG,IAAA,kBAAO,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QACtC,MAAM,IAAI,GAAG,CAAC,GAAG,IAAA,kBAAO,EAAC,UAAU,EAAE,MAAM,CAAC,EAAE,GAAG,IAAA,kBAAO,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAA;QAC7E,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAA;QACvD,OAAO,IAAI,CAAA;IACf,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,UAAU,GAAG,EAAE;QAC1B,IAAI,OAAO,CAAA;QACX,IAAI,CAAC;YACD,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;QAC9C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,OAAO,GAAG,KAAK,CAAA;QACnB,CAAC;QACD,OAAO,OAAO,CAAA;IAClB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,OAAO,CAAC,QAAgB,EAAE,UAAU,GAAG,EAAE;QACnD,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAClD,CAAC;CACJ;AAxRD,wBAwRC"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.primitives = void 0;
4
- exports.primitives = require("./primitives/index.js");
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;AAAA,sDAAmD"}
@@ -1,99 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const OP_js_1 = require("../OP.js");
4
- const LockingScript_js_1 = require("../LockingScript.js");
5
- const UnlockingScript_js_1 = require("../UnlockingScript.js");
6
- const TransactionSignature_js_1 = require("../../primitives/TransactionSignature.js");
7
- const Hash_js_1 = require("../../primitives/Hash.js");
8
- const utils_js_1 = require("../../primitives/utils.js");
9
- /**
10
- * P2PKH (Pay To Public Key Hash) class implementing ScriptTemplate.
11
- *
12
- * This class provides methods to create Pay To Public Key Hash locking and unlocking scripts, including the unlocking of P2PKH UTXOs with the private key.
13
- */
14
- class P2PKHT {
15
- /**
16
- * Creates a P2PKH locking script for a given public key hash.
17
- *
18
- * @param {number[]} pubkeyhash - An array representing the public key hash.
19
- * @returns {LockingScript} - A P2PKH locking script.
20
- */
21
- lock(pubkeyhash) {
22
- const time = (0, utils_js_1.toArray)(Date.now().toString());
23
- return new LockingScript_js_1.default([
24
- { op: time.length, data: time },
25
- { op: OP_js_1.default.OP_DROP },
26
- { op: OP_js_1.default.OP_DUP },
27
- { op: OP_js_1.default.OP_HASH160 },
28
- { op: pubkeyhash.length, data: pubkeyhash },
29
- { op: OP_js_1.default.OP_EQUALVERIFY },
30
- { op: OP_js_1.default.OP_CHECKSIG }
31
- ]);
32
- }
33
- /**
34
- * Creates a function that generates a P2PKH unlocking script along with its signature and length estimation.
35
- *
36
- * The returned object contains:
37
- * 1. `sign` - A function that, when invoked with a transaction and an input index,
38
- * produces an unlocking script suitable for a P2PKH locked output.
39
- * 2. `estimateLength` - A function that returns the estimated length of the unlocking script in bytes.
40
- *
41
- * @param {PrivateKey} privateKey - The private key used for signing the transaction.
42
- * @param {'all'|'none'|'single'} signOutputs - The signature scope for outputs.
43
- * @param {boolean} anyoneCanPay - Flag indicating if the signature allows for other inputs to be added later.
44
- * @returns {Object} - An object containing the `sign` and `estimateLength` functions.
45
- */
46
- unlock(privateKey, signOutputs = 'all', anyoneCanPay = false) {
47
- return {
48
- sign: async (tx, inputIndex) => {
49
- let signatureScope = TransactionSignature_js_1.default.SIGHASH_FORKID;
50
- if (signOutputs === 'all') {
51
- signatureScope |= TransactionSignature_js_1.default.SIGHASH_ALL;
52
- }
53
- if (signOutputs === 'none') {
54
- signatureScope |= TransactionSignature_js_1.default.SIGHASH_NONE;
55
- }
56
- if (signOutputs === 'single') {
57
- signatureScope |= TransactionSignature_js_1.default.SIGHASH_SINGLE;
58
- }
59
- if (anyoneCanPay) {
60
- signatureScope |= TransactionSignature_js_1.default.SIGHASH_ANYONECANPAY;
61
- }
62
- const otherInputs = [...tx.inputs];
63
- const [input] = otherInputs.splice(inputIndex, 1);
64
- if (typeof input.sourceTransaction !== 'object') {
65
- // Question: Should the library support use-cases where the source transaction is not provided? This is to say, is it ever acceptable for someone to sign an input spending some output from a transaction they have not provided? Some elements (such as the satoshi value and output script) are always required. A merkle proof is also always required, and verifying it (while also verifying that the claimed output is contained within the claimed transaction) is also always required. This seems to require the entire input transaction.
66
- throw new Error('The source transaction is needed for transaction signing.');
67
- }
68
- const preimage = TransactionSignature_js_1.default.format({
69
- sourceTXID: input.sourceTransaction.id('hex'),
70
- sourceOutputIndex: input.sourceOutputIndex,
71
- sourceSatoshis: input.sourceTransaction.outputs[input.sourceOutputIndex].satoshis,
72
- transactionVersion: tx.version,
73
- otherInputs,
74
- inputIndex,
75
- outputs: tx.outputs,
76
- inputSequence: input.sequence,
77
- subscript: input.sourceTransaction.outputs[input.sourceOutputIndex].lockingScript,
78
- lockTime: tx.lockTime,
79
- scope: signatureScope
80
- });
81
- const rawSignature = privateKey.sign((0, Hash_js_1.sha256)(preimage));
82
- const sig = new TransactionSignature_js_1.default(rawSignature.r, rawSignature.s, signatureScope);
83
- const sigForScript = sig.toChecksigFormat();
84
- const pubkeyForScript = privateKey.toPublicKey().encode(true);
85
- return new UnlockingScript_js_1.default([
86
- { op: sigForScript.length, data: sigForScript },
87
- { op: pubkeyForScript.length, data: pubkeyForScript }
88
- ]);
89
- },
90
- estimateLength: async () => {
91
- // public key (1+33) + signature (1+71)
92
- // Note: We add 1 to each element's length because of the associated OP_PUSH
93
- return 106;
94
- }
95
- };
96
- }
97
- }
98
- exports.default = P2PKHT;
99
- //# sourceMappingURL=P2PKHT.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"P2PKHT.js","sourceRoot":"","sources":["../../../../../src/script/templates/P2PKHT.ts"],"names":[],"mappings":";;AAAA,oCAAyB;AAEzB,0DAA+C;AAC/C,8DAAmD;AAGnD,sFAA2E;AAC3E,sDAAiD;AACjD,wDAAmD;AAEnD;;;;GAIG;AACH,MAAqB,MAAM;IACzB;;;;;OAKG;IACH,IAAI,CAAE,UAAoB;QACxB,MAAM,IAAI,GAAG,IAAA,kBAAO,EAAC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC3C,OAAO,IAAI,0BAAa,CAAC;YACvB,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;YAC/B,EAAE,EAAE,EAAE,eAAE,CAAC,OAAO,EAAE;YAClB,EAAE,EAAE,EAAE,eAAE,CAAC,MAAM,EAAE;YACjB,EAAE,EAAE,EAAE,eAAE,CAAC,UAAU,EAAE;YACrB,EAAE,EAAE,EAAE,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE;YAC3C,EAAE,EAAE,EAAE,eAAE,CAAC,cAAc,EAAE;YACzB,EAAE,EAAE,EAAE,eAAE,CAAC,WAAW,EAAE;SACvB,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CACJ,UAAsB,EACtB,cAAyC,KAAK,EAC9C,eAAwB,KAAK;QAK7B,OAAO;YACL,IAAI,EAAE,KAAK,EAAE,EAAe,EAAE,UAAkB,EAAE,EAAE;gBAClD,IAAI,cAAc,GAAG,iCAAoB,CAAC,cAAc,CAAA;gBACxD,IAAI,WAAW,KAAK,KAAK,EAAE,CAAC;oBAC1B,cAAc,IAAI,iCAAoB,CAAC,WAAW,CAAA;gBACpD,CAAC;gBACD,IAAI,WAAW,KAAK,MAAM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,CAAC,CAAC,CAAA;gBACtD,MAAM,GAAG,GAAG,IAAI,iCAAoB,CAClC,YAAY,CAAC,CAAC,EACd,YAAY,CAAC,CAAC,EACd,cAAc,CACf,CAAA;gBACD,MAAM,YAAY,GAAG,GAAG,CAAC,gBAAgB,EAAE,CAAA;gBAC3C,MAAM,eAAe,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAa,CAAA;gBACzE,OAAO,IAAI,4BAAe,CAAC;oBACzB,EAAE,EAAE,EAAE,YAAY,CAAC,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE;oBAC/C,EAAE,EAAE,EAAE,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE;iBACtD,CAAC,CAAA;YACJ,CAAC;YACD,cAAc,EAAE,KAAK,IAAI,EAAE;gBACzB,uCAAuC;gBACvC,4EAA4E;gBAC5E,OAAO,GAAG,CAAA;YACZ,CAAC;SACF,CAAA;IACH,CAAC;CACF;AAjGD,yBAiGC"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dec2hex = exports.hex2dec = void 0;
4
- const hex2dec = (hex) => {
5
- return parseInt(hex, 16);
6
- };
7
- exports.hex2dec = hex2dec;
8
- const dec2hex = (dec) => {
9
- const rounded = Math.round(dec);
10
- const prefix = rounded <= 0xf ? '0' : ''; // ensure that single-digit numbers are padded with a leading zero
11
- return prefix + rounded.toString(16);
12
- };
13
- exports.dec2hex = dec2hex;
14
- //# sourceMappingURL=converters.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"converters.js","sourceRoot":"","sources":["../../../../src/totp/converters.ts"],"names":[],"mappings":";;;AAAO,MAAM,OAAO,GAAG,CAAC,GAAW,EAAU,EAAE;IAC7C,OAAO,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AAC1B,CAAC,CAAA;AAFY,QAAA,OAAO,WAEnB;AAEM,MAAM,OAAO,GAAG,CAAC,GAAW,EAAU,EAAE;IAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC/B,MAAM,MAAM,GAAG,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA,CAAC,kEAAkE;IAC3G,OAAO,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;AACtC,CAAC,CAAA;AAJY,QAAA,OAAO,WAInB"}
@@ -1,75 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateTotpForContact = exports.generateTotpForContact = void 0;
7
- const HD_js_1 = __importDefault(require("../compat/HD.js"));
8
- const PublicKey_js_1 = __importDefault(require("../primitives/PublicKey.js"));
9
- const totp_js_1 = require("./totp.js");
10
- const converters_js_1 = require("./converters.js");
11
- /*
12
- Basic flow:
13
- Alice generates passcodeForBob with (sharedSecret+(contact.Paymail as bobPaymail))
14
- Alice sends passcodeForBob to Bob (e.g. via email)
15
- Bob validates passcodeForBob with (sharedSecret+(requesterPaymail as bobPaymail))
16
- The (sharedSecret+paymail) is a "directedSecret". This ensures that passcodeForBob-from-Alice != passcodeForAlice-from-Bob.
17
- The flow looks the same for Bob generating passcodeForAlice.
18
- */
19
- /**
20
- * Generates a TOTP for a given contact
21
- *
22
- * @param clientXPriv - The client xpriv
23
- * @param contact - The Contact
24
- * @param period - The TOTP period (default: 30)
25
- * @param digits - The number of TOTP digits (default: 2)
26
- * @returns The generated TOTP as a string
27
- */
28
- const generateTotpForContact = (clientXPriv, contact, period, digits) => {
29
- const sharedSecret = makeSharedSecret(contact, clientXPriv);
30
- const secret = directedSecret(sharedSecret, contact.paymail);
31
- return totp_js_1.TOTP.generate(secret, getTotpOps(period, digits));
32
- };
33
- exports.generateTotpForContact = generateTotpForContact;
34
- /**
35
- * Validates a TOTP for a given contact
36
- *
37
- * @param clientXPriv - The client xpriv
38
- * @param contact - The Contact
39
- * @param passcode - The TOTP passcode to validate
40
- * @param requesterPaymail - The paymail of the requester
41
- * @param period - The TOTP period (default: 30)
42
- * @param digits - The number of TOTP digits (default: 2)
43
- * @returns A boolean indicating whether the TOTP is valid
44
- */
45
- const validateTotpForContact = (clientXPriv, contact, passcode, requesterPaymail, period, digits) => {
46
- const sharedSecret = makeSharedSecret(contact, clientXPriv);
47
- const secret = directedSecret(sharedSecret, requesterPaymail);
48
- return totp_js_1.TOTP.validate(secret, passcode, getTotpOps(period, digits));
49
- };
50
- exports.validateTotpForContact = validateTotpForContact;
51
- const getTotpOps = (period, digits) => ({
52
- digits,
53
- period,
54
- algorithm: 'SHA-1'
55
- });
56
- const makeSharedSecret = (contact, clientXPriv) => {
57
- const xprivKey = HD_js_1.default.fromString(clientXPriv.toString());
58
- const pubKey = PublicKey_js_1.default.fromString(contact.pubKey);
59
- // PKI derivation path: m/0/0/0
60
- // NOTICE: we currently do not support PKI rotation; however, adjustments will be made if and when we decide to implement it
61
- const hd = xprivKey.derive('m/0/0/0');
62
- const privKey = hd.privKey;
63
- const ss = privKey.deriveSharedSecret(pubKey);
64
- return ss.getX().toHex(32);
65
- };
66
- const directedSecret = (sharedSecret, paymail) => {
67
- const paymailEncoded = Uint8Array.from(paymail, (c) => c.charCodeAt(0));
68
- const sharedSecretEncoded = (0, converters_js_1.hexToUint8Array)(sharedSecret);
69
- // Concatenate sharedSecretEncoded and paymailEncoded
70
- const concatenated = new Uint8Array(sharedSecretEncoded.length + paymailEncoded.length);
71
- concatenated.set(sharedSecretEncoded, 0);
72
- concatenated.set(paymailEncoded, sharedSecretEncoded.length);
73
- return concatenated;
74
- };
75
- //# sourceMappingURL=pike-totp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pike-totp.js","sourceRoot":"","sources":["../../../../src/totp/pike-totp.ts"],"names":[],"mappings":";;;;;;AAAA,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AC,OAAO,CAAC,MAAM,CAAC,CAAA;IAEnD,+BAA+B;IAC/B,4HAA4H;IAC5H,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IACrC,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAA;IAC1B,MAAM,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;IAC7C,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,YAAoB,EAAE,OAAe,EAAc,EAAE;IAC3E,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IACvE,MAAM,mBAAmB,GAAG,IAAA,+BAAe,EAAC,YAAY,CAAC,CAAA;IAEzD,qDAAqD;IACrD,MAAM,YAAY,GAAG,IAAI,UAAU,CACjC,mBAAmB,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM,CACnD,CAAA;IACD,YAAY,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAA;IACxC,YAAY,CAAC,GAAG,CAAC,cAAc,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAA;IAE5D,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/totp/types.ts"],"names":[],"mappings":""}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class ARC {
4
- constructor(URL) {
5
- this.URL = URL;
6
- }
7
- async broadcast(tx) {
8
- const metadata = tx.metadata;
9
- if (!Array.isArray(metadata.topics)) {
10
- return {
11
- status: 'error',
12
- code: 'ERR_NO_TOPICS',
13
- description: 'The BRC-22 transaction broadcaster requires an array of topics in the transaction metadata.'
14
- };
15
- }
16
- const txHex = tx.toHex();
17
- return {
18
- status: 'success',
19
- txid: tx.id('hex'),
20
- message: 'OK'
21
- };
22
- }
23
- }
24
- exports.default = ARC;
25
- //# sourceMappingURL=BRC22.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BRC22.js","sourceRoot":"","sources":["../../../../../src/transaction/broadcasters/BRC22.ts"],"names":[],"mappings":";;AAGA,MAAqB,GAAG;IAGtB,YAAa,GAAW;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,KAAK,CAAC,SAAS,CAAE,EAAe;QAC9B,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAA;QAC5B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACpC,OAAO;gBACL,MAAM,EAAE,OAAO;gBACf,IAAI,EAAE,eAAe;gBACrB,WAAW,EAAE,6FAA6F;aAC3G,CAAA;QACH,CAAC;QACD,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,EAAE,CAAA;QACxB,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAW;YAC5B,OAAO,EAAE,IAAI;SACd,CAAA;IACH,CAAC;CACF;AAvBD,sBAuBC"}