quantumcoin 6.14.1 → 6.14.2

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 (141) hide show
  1. package/README.md +2 -0
  2. package/dist/quantumcoin.js +2697 -7812
  3. package/dist/quantumcoin.js.map +1 -1
  4. package/dist/quantumcoin.min.js +1 -1
  5. package/dist/quantumcoin.min.js'.gz' +0 -0
  6. package/dist/quantumcoin.umd.js +2698 -7835
  7. package/dist/quantumcoin.umd.js.map +1 -1
  8. package/dist/quantumcoin.umd.min.js +1 -1
  9. package/dist/quantumcoin.umd.min.js'.gz' +0 -0
  10. package/dist/wordlists-extra.min.js'.gz' +0 -0
  11. package/lib.commonjs/address/address.d.ts +1 -21
  12. package/lib.commonjs/address/address.d.ts.map +1 -1
  13. package/lib.commonjs/address/address.js +2 -30
  14. package/lib.commonjs/address/address.js.map +1 -1
  15. package/lib.commonjs/address/index.d.ts +1 -1
  16. package/lib.commonjs/address/index.d.ts.map +1 -1
  17. package/lib.commonjs/address/index.js +1 -2
  18. package/lib.commonjs/address/index.js.map +1 -1
  19. package/lib.commonjs/crypto/signature.d.ts +4 -17
  20. package/lib.commonjs/crypto/signature.d.ts.map +1 -1
  21. package/lib.commonjs/crypto/signature.js +57 -60
  22. package/lib.commonjs/crypto/signature.js.map +1 -1
  23. package/lib.commonjs/crypto/signing-key.d.ts +5 -64
  24. package/lib.commonjs/crypto/signing-key.d.ts.map +1 -1
  25. package/lib.commonjs/crypto/signing-key.js +27 -101
  26. package/lib.commonjs/crypto/signing-key.js.map +1 -1
  27. package/lib.commonjs/providers/default-provider.d.ts +0 -8
  28. package/lib.commonjs/providers/default-provider.d.ts.map +1 -1
  29. package/lib.commonjs/providers/default-provider.js +0 -108
  30. package/lib.commonjs/providers/default-provider.js.map +1 -1
  31. package/lib.commonjs/providers/index.d.ts +0 -9
  32. package/lib.commonjs/providers/index.d.ts.map +1 -1
  33. package/lib.commonjs/providers/index.js +1 -21
  34. package/lib.commonjs/providers/index.js.map +1 -1
  35. package/lib.commonjs/providers/network.js +1 -99
  36. package/lib.commonjs/providers/network.js.map +1 -1
  37. package/lib.commonjs/quantumcoin.d.ts +4 -4
  38. package/lib.commonjs/quantumcoin.d.ts.map +1 -1
  39. package/lib.commonjs/quantumcoin.js +4 -26
  40. package/lib.commonjs/quantumcoin.js.map +1 -1
  41. package/lib.commonjs/transaction/address.d.ts +1 -1
  42. package/lib.commonjs/transaction/address.d.ts.map +1 -1
  43. package/lib.commonjs/transaction/address.js +9 -5
  44. package/lib.commonjs/transaction/address.js.map +1 -1
  45. package/lib.commonjs/wallet/hdwallet.d.ts.map +1 -1
  46. package/lib.commonjs/wallet/hdwallet.js +4 -5
  47. package/lib.commonjs/wallet/hdwallet.js.map +1 -1
  48. package/lib.commonjs/wallet/index.d.ts +2 -6
  49. package/lib.commonjs/wallet/index.d.ts.map +1 -1
  50. package/lib.commonjs/wallet/index.js +1 -14
  51. package/lib.commonjs/wallet/index.js.map +1 -1
  52. package/lib.commonjs/wallet/json-keystore.d.ts +3 -52
  53. package/lib.commonjs/wallet/json-keystore.d.ts.map +1 -1
  54. package/lib.commonjs/wallet/json-keystore.js +41 -246
  55. package/lib.commonjs/wallet/json-keystore.js.map +1 -1
  56. package/lib.commonjs/wallet/seedwallet.d.ts +4 -0
  57. package/lib.commonjs/wallet/seedwallet.d.ts.map +1 -0
  58. package/lib.commonjs/wallet/seedwallet.js +8 -0
  59. package/lib.commonjs/wallet/seedwallet.js.map +1 -0
  60. package/lib.commonjs/wallet/wallet.d.ts +5 -14
  61. package/lib.commonjs/wallet/wallet.d.ts.map +1 -1
  62. package/lib.commonjs/wallet/wallet.js +12 -51
  63. package/lib.commonjs/wallet/wallet.js.map +1 -1
  64. package/lib.esm/address/address.d.ts +1 -21
  65. package/lib.esm/address/address.d.ts.map +1 -1
  66. package/lib.esm/address/address.js +1 -28
  67. package/lib.esm/address/address.js.map +1 -1
  68. package/lib.esm/address/index.d.ts +1 -1
  69. package/lib.esm/address/index.d.ts.map +1 -1
  70. package/lib.esm/address/index.js +1 -1
  71. package/lib.esm/address/index.js.map +1 -1
  72. package/lib.esm/crypto/signature.d.ts +4 -17
  73. package/lib.esm/crypto/signature.d.ts.map +1 -1
  74. package/lib.esm/crypto/signature.js +45 -46
  75. package/lib.esm/crypto/signature.js.map +1 -1
  76. package/lib.esm/crypto/signing-key.d.ts +5 -64
  77. package/lib.esm/crypto/signing-key.d.ts.map +1 -1
  78. package/lib.esm/crypto/signing-key.js +26 -102
  79. package/lib.esm/crypto/signing-key.js.map +1 -1
  80. package/lib.esm/providers/default-provider.d.ts +0 -8
  81. package/lib.esm/providers/default-provider.d.ts.map +1 -1
  82. package/lib.esm/providers/default-provider.js +0 -108
  83. package/lib.esm/providers/default-provider.js.map +1 -1
  84. package/lib.esm/providers/index.d.ts +0 -9
  85. package/lib.esm/providers/index.d.ts.map +1 -1
  86. package/lib.esm/providers/index.js +0 -9
  87. package/lib.esm/providers/index.js.map +1 -1
  88. package/lib.esm/providers/network.js +3 -101
  89. package/lib.esm/providers/network.js.map +1 -1
  90. package/lib.esm/quantumcoin.d.ts +4 -4
  91. package/lib.esm/quantumcoin.d.ts.map +1 -1
  92. package/lib.esm/quantumcoin.js +3 -3
  93. package/lib.esm/quantumcoin.js.map +1 -1
  94. package/lib.esm/transaction/address.d.ts +1 -1
  95. package/lib.esm/transaction/address.d.ts.map +1 -1
  96. package/lib.esm/transaction/address.js +7 -4
  97. package/lib.esm/transaction/address.js.map +1 -1
  98. package/lib.esm/wallet/hdwallet.d.ts.map +1 -1
  99. package/lib.esm/wallet/hdwallet.js +4 -5
  100. package/lib.esm/wallet/hdwallet.js.map +1 -1
  101. package/lib.esm/wallet/index.d.ts +2 -6
  102. package/lib.esm/wallet/index.d.ts.map +1 -1
  103. package/lib.esm/wallet/index.js +1 -4
  104. package/lib.esm/wallet/index.js.map +1 -1
  105. package/lib.esm/wallet/json-keystore.d.ts +3 -52
  106. package/lib.esm/wallet/json-keystore.d.ts.map +1 -1
  107. package/lib.esm/wallet/json-keystore.js +32 -241
  108. package/lib.esm/wallet/json-keystore.js.map +1 -1
  109. package/lib.esm/wallet/seedwallet.d.ts +4 -0
  110. package/lib.esm/wallet/seedwallet.d.ts.map +1 -0
  111. package/lib.esm/wallet/seedwallet.js +4 -0
  112. package/lib.esm/wallet/seedwallet.js.map +1 -0
  113. package/lib.esm/wallet/wallet.d.ts +5 -14
  114. package/lib.esm/wallet/wallet.d.ts.map +1 -1
  115. package/lib.esm/wallet/wallet.js +12 -53
  116. package/lib.esm/wallet/wallet.js.map +1 -1
  117. package/package.json +5 -2
  118. package/src.ts/address/address.ts +2 -27
  119. package/src.ts/address/index.ts +1 -1
  120. package/src.ts/crypto/signature.ts +31 -45
  121. package/src.ts/crypto/signing-key.ts +31 -109
  122. package/src.ts/providers/default-provider.ts +0 -106
  123. package/src.ts/providers/index.ts +0 -10
  124. package/src.ts/providers/network.ts +3 -111
  125. package/src.ts/quantumcoin.ts +7 -17
  126. package/src.ts/transaction/address.ts +8 -5
  127. package/src.ts/wallet/index.ts +2 -17
  128. package/src.ts/wallet/json-keystore.ts +42 -325
  129. package/src.ts/wallet/wallet.ts +23 -47
  130. package/src.ts/providers/provider-alchemy.ts +0 -166
  131. package/src.ts/providers/provider-ankr.ts +0 -153
  132. package/src.ts/providers/provider-blockscout.ts +0 -167
  133. package/src.ts/providers/provider-chainstack.ts +0 -113
  134. package/src.ts/providers/provider-cloudflare.ts +0 -24
  135. package/src.ts/providers/provider-etherscan.ts +0 -671
  136. package/src.ts/providers/provider-infura.ts +0 -220
  137. package/src.ts/providers/provider-pocket.ts +0 -121
  138. package/src.ts/providers/provider-quicknode.ts +0 -177
  139. package/src.ts/wallet/hdwallet.ts +0 -586
  140. package/src.ts/wallet/json-crowdsale.ts +0 -74
  141. package/src.ts/wallet/mnemonic.ts +0 -203
@@ -1,21 +1,21 @@
1
1
 
2
2
  import { ZeroHash } from "../constants/index.js";
3
3
  import {
4
- concat, dataLength, getBigInt, getBytes, getNumber, hexlify,
5
- toBeArray, isHexString, zeroPadValue,
4
+ //isHexString, toBeArray, zeroPadValue,
5
+ concat, getBigInt, getBytes, getNumber, hexlify,
6
6
  assertArgument, assertPrivate
7
7
  } from "../utils/index.js";
8
8
 
9
9
  import type {
10
- BigNumberish, BytesLike, Numeric
10
+ //Numeric
11
+ BigNumberish, BytesLike,
11
12
  } from "../utils/index.js";
12
13
 
13
14
 
14
15
  // Constants
15
16
  const BN_0 = BigInt(0);
16
- const BN_1 = BigInt(1);
17
+ //const BN_1 = BigInt(1);
17
18
  const BN_2 = BigInt(2);
18
- const BN_27 = BigInt(27);
19
19
  const BN_28 = BigInt(28);
20
20
  const BN_35 = BigInt(35);
21
21
 
@@ -33,25 +33,19 @@ export type SignatureLike = Signature | string | {
33
33
  r: string;
34
34
  s: string;
35
35
  v: BigNumberish;
36
- yParity?: 0 | 1;
37
- yParityAndS?: string;
38
36
  } | {
39
37
  r: string;
40
- yParityAndS: string;
41
- yParity?: 0 | 1;
42
38
  s?: string;
43
39
  v?: number;
44
40
  } | {
45
41
  r: string;
46
42
  s: string;
47
- yParity: 0 | 1;
48
43
  v?: BigNumberish;
49
- yParityAndS?: string;
50
44
  };
51
-
45
+ /*
52
46
  function toUint256(value: BigNumberish): string {
53
47
  return zeroPadValue(toBeArray(value), 32);
54
- }
48
+ }*/
55
49
 
56
50
  /**
57
51
  * A Signature @TODO
@@ -62,7 +56,7 @@ function toUint256(value: BigNumberish): string {
62
56
  export class Signature {
63
57
  #r: string;
64
58
  #s: string;
65
- #v: 27 | 28;
59
+ #v: 28;
66
60
  #networkV: null | bigint;
67
61
 
68
62
  /**
@@ -73,7 +67,6 @@ export class Signature {
73
67
  */
74
68
  get r(): string { return this.#r; }
75
69
  set r(value: BytesLike) {
76
- assertArgument(dataLength(value) === 32, "invalid r", "value", value);
77
70
  this.#r = hexlify(value);
78
71
  }
79
72
 
@@ -82,9 +75,7 @@ export class Signature {
82
75
  */
83
76
  get s(): string { return this.#s; }
84
77
  set s(_value: BytesLike) {
85
- assertArgument(dataLength(_value) === 32, "invalid s", "value", _value);
86
78
  const value = hexlify(_value);
87
- assertArgument(parseInt(value.substring(0, 3)) < 8, "non-canonical s", "value", value);
88
79
  this.#s = value;
89
80
  }
90
81
 
@@ -95,13 +86,13 @@ export class Signature {
95
86
  * its correspondin ``y``, the ``v`` indicates which of the two ``y``
96
87
  * values to use.
97
88
  *
98
- * It is normalized to the values ``27`` or ``28`` for legacy
89
+ * It is normalized to the values ``28`` or ``28`` for legacy
99
90
  * purposes.
100
91
  */
101
- get v(): 27 | 28 { return this.#v; }
92
+ get v(): 28 | 28 { return this.#v; }
102
93
  set v(value: BigNumberish) {
103
94
  const v = getNumber(value, "value");
104
- assertArgument(v === 27 || v === 28, "invalid v", "v", value);
95
+ assertArgument(v === 28, "invalid v", "v", value);
105
96
  this.#v = v;
106
97
  }
107
98
 
@@ -127,7 +118,7 @@ export class Signature {
127
118
  * See ``v`` for more details on how this value is used.
128
119
  */
129
120
  get yParity(): 0 | 1 {
130
- return (this.v === 27) ? 0: 1;
121
+ return (this.v === 28) ? 0: 1;
131
122
  }
132
123
 
133
124
  /**
@@ -158,7 +149,7 @@ export class Signature {
158
149
  /**
159
150
  * @private
160
151
  */
161
- constructor(guard: any, r: string, s: string, v: 27 | 28) {
152
+ constructor(guard: any, r: string, s: string, v: 28) {
162
153
  assertPrivate(guard, _guard, "Signature");
163
154
  this.#r = r;
164
155
  this.#s = s;
@@ -205,7 +196,7 @@ export class Signature {
205
196
  const bv = getBigInt(v, "v");
206
197
 
207
198
  // The v is not an EIP-155 v, so it is the unspecified chain ID
208
- if ((bv == BN_27) || (bv == BN_28)) { return BN_0; }
199
+ if ((bv == BN_28) || (bv == BN_28)) { return BN_0; }
209
200
 
210
201
  // Bad value for an EIP-155 v
211
202
  assertArgument(bv >= BN_35, "invalid EIP-155 v", "v", v);
@@ -220,15 +211,13 @@ export class Signature {
220
211
  * property to include the chain ID.
221
212
  *
222
213
  * @example:
223
- * Signature.getChainIdV(5, 27)
224
- * //_result:
225
214
  *
226
215
  * Signature.getChainIdV(5, 28)
227
216
  * //_result:
228
217
  *
229
218
  */
230
- static getChainIdV(chainId: BigNumberish, v: 27 | 28): bigint {
231
- return (getBigInt(chainId) * BN_2) + BigInt(35 + v - 27);
219
+ static getChainIdV(chainId: BigNumberish, v: 28): bigint {
220
+ return (getBigInt(chainId) * BN_2) + BigInt(35 + v - 28);
232
221
  }
233
222
 
234
223
  /**
@@ -240,10 +229,6 @@ export class Signature {
240
229
  * Signature.getNormalizedV(0)
241
230
  * //_result:
242
231
  *
243
- * // Legacy non-EIP-1559 transaction (i.e. 27 or 28)
244
- * Signature.getNormalizedV(27)
245
- * //_result:
246
- *
247
232
  * // Legacy EIP-155 transaction (i.e. >= 35)
248
233
  * Signature.getNormalizedV(46)
249
234
  * //_result:
@@ -252,17 +237,16 @@ export class Signature {
252
237
  * Signature.getNormalizedV(5)
253
238
  * //_error:
254
239
  */
255
- static getNormalizedV(v: BigNumberish): 27 | 28 {
240
+ /*static getNormalizedV(v: BigNumberish): 28 {
256
241
  const bv = getBigInt(v);
257
242
 
258
- if (bv === BN_0 || bv === BN_27) { return 27; }
259
243
  if (bv === BN_1 || bv === BN_28) { return 28; }
260
244
 
261
245
  assertArgument(bv >= BN_35, "invalid v", "v", v);
262
246
 
263
- // Otherwise, EIP-155 v means odd is 27 and even is 28
264
- return (bv & BN_1) ? 27: 28;
265
- }
247
+ // Otherwise, EIP-155 v means odd is 28 and even is 28
248
+ return (bv & BN_1) ? 28: 28;
249
+ }*/
266
250
 
267
251
  /**
268
252
  * Creates a new [[Signature]].
@@ -278,15 +262,15 @@ export class Signature {
278
262
  };
279
263
 
280
264
  if (sig == null) {
281
- return new Signature(_guard, ZeroHash, ZeroHash, 27);
265
+ return new Signature(_guard, ZeroHash, ZeroHash, 28);
282
266
  }
283
267
 
284
268
  if (typeof(sig) === "string") {
285
- const bytes = getBytes(sig, "signature");
269
+ /*const bytes = getBytes(sig, "signature");
286
270
  if (bytes.length === 64) {
287
271
  const r = hexlify(bytes.slice(0, 32));
288
272
  const s = bytes.slice(32, 64);
289
- const v = (s[0] & 0x80) ? 28: 27;
273
+ const v = (s[0] & 0x80) ? 28: 28;
290
274
  s[0] &= 0x7f;
291
275
  return new Signature(_guard, r, hexlify(s), v);
292
276
  }
@@ -297,14 +281,16 @@ export class Signature {
297
281
  assertError((s[0] & 0x80) === 0, "non-canonical s");
298
282
  const v = Signature.getNormalizedV(bytes[64]);
299
283
  return new Signature(_guard, r, hexlify(s), v);
300
- }
284
+ }*/
301
285
 
302
286
  assertError(false, "invalid raw signature length");
303
287
  }
304
288
 
305
289
  if (sig instanceof Signature) { return sig.clone(); }
306
290
 
307
- // Get r
291
+ return new Signature(_guard, ZeroHash, ZeroHash, 28); //todo
292
+
293
+ /*// Get r
308
294
  const _r = sig.r;
309
295
  assertError(_r != null, "missing r");
310
296
  const r = toUint256(_r);
@@ -325,7 +311,7 @@ export class Signature {
325
311
  assertError((getBytes(s)[0] & 0x80) == 0, "non-canonical s");
326
312
 
327
313
  // Get v; by any means necessary (we check consistency below)
328
- const { networkV, v } = (function(_v?: BigNumberish, yParityAndS?: string, yParity?: Numeric): { networkV?: bigint, v: 27 | 28 } {
314
+ const { networkV, v } = (function(_v?: BigNumberish, yParityAndS?: string, yParity?: Numeric): { networkV?: bigint, v: 28 | 28 } {
329
315
  if (_v != null) {
330
316
  const v = getBigInt(_v);
331
317
  return {
@@ -336,12 +322,12 @@ export class Signature {
336
322
 
337
323
  if (yParityAndS != null) {
338
324
  assertError(isHexString(yParityAndS, 32), "invalid yParityAndS");
339
- return { v: ((getBytes(yParityAndS)[0] & 0x80) ? 28: 27) };
325
+ return { v: ((getBytes(yParityAndS)[0] & 0x80) ? 28: 28) };
340
326
  }
341
327
 
342
328
  if (yParity != null) {
343
329
  switch (getNumber(yParity, "sig.yParity")) {
344
- case 0: return { v: 27 };
330
+ case 0: return { v: 28 };
345
331
  case 1: return { v: 28 };
346
332
  }
347
333
  assertError(false, "invalid yParity");
@@ -357,7 +343,7 @@ export class Signature {
357
343
  assertError(sig.yParity == null || getNumber(sig.yParity, "sig.yParity") === result.yParity, "yParity mismatch");
358
344
  assertError(sig.yParityAndS == null || sig.yParityAndS === result.yParityAndS, "yParityAndS mismatch");
359
345
 
360
- return result;
346
+ return result;*/
361
347
  }
362
348
  }
363
349
 
@@ -4,10 +4,12 @@
4
4
  * @_subsection: api/crypto:Signing [about-signing]
5
5
  */
6
6
 
7
- import { secp256k1 } from "@noble/curves/secp256k1";
7
+ import pqc = require('quantum-coin-pqc-js-sdk');
8
+ import qcsdk = require('quantum-coin-js-sdk');
8
9
 
9
10
  import {
10
- concat, dataLength, getBytes, getBytesCopy, hexlify, toBeHex,
11
+ getBytes,
12
+ dataLength, getBytesCopy, hexlify,
11
13
  assertArgument
12
14
  } from "../utils/index.js";
13
15
 
@@ -17,10 +19,12 @@ import type { BytesLike } from "../utils/index.js";
17
19
 
18
20
  import type { SignatureLike } from "./index.js";
19
21
 
22
+ const CRYPTO_MESSAGE_LENGTH = 32;
23
+ const CRYPTO_SECRETKEY_BYTES = 64 + 2560 + 1312 + 128;
24
+ //const CRYPTO_PUBLICKEY_BYTES = 32 + 1312 + 64;
20
25
 
21
26
  /**
22
- * A **SigningKey** provides high-level access to the elliptic curve
23
- * cryptography (ECC) operations and key management.
27
+ * A **SigningKey** provides high-level access to cryptography operations and key management.
24
28
  */
25
29
  export class SigningKey {
26
30
  #privateKey: string;
@@ -29,7 +33,7 @@ export class SigningKey {
29
33
  * Creates a new **SigningKey** for %%privateKey%%.
30
34
  */
31
35
  constructor(privateKey: BytesLike) {
32
- assertArgument(dataLength(privateKey) === 32, "invalid private key", "privateKey", "[REDACTED]");
36
+ assertArgument(dataLength(privateKey) === CRYPTO_SECRETKEY_BYTES, "invalid private key", "privateKey", "[REDACTED]");
33
37
  this.#privateKey = hexlify(privateKey);
34
38
  }
35
39
 
@@ -39,110 +43,46 @@ export class SigningKey {
39
43
  get privateKey(): string { return this.#privateKey; }
40
44
 
41
45
  /**
42
- * The uncompressed public key.
46
+ * The public key.
43
47
  *
44
- * This will always begin with the prefix ``0x04`` and be 132
45
- * characters long (the ``0x`` prefix and 130 hexadecimal nibbles).
46
48
  */
47
49
  get publicKey(): string { return SigningKey.computePublicKey(this.#privateKey); }
48
50
 
49
- /**
50
- * The compressed public key.
51
- *
52
- * This will always begin with either the prefix ``0x02`` or ``0x03``
53
- * and be 68 characters long (the ``0x`` prefix and 33 hexadecimal
54
- * nibbles)
55
- */
56
- get compressedPublicKey(): string { return SigningKey.computePublicKey(this.#privateKey, true); }
57
-
58
51
  /**
59
52
  * Return the signature of the signed %%digest%%.
60
53
  */
61
54
  sign(digest: BytesLike): Signature {
62
- assertArgument(dataLength(digest) === 32, "invalid digest length", "digest", digest);
55
+ assertArgument(dataLength(digest) === CRYPTO_MESSAGE_LENGTH, "invalid digest length", "digest", digest);
63
56
 
64
- const sig = secp256k1.sign(getBytesCopy(digest), getBytesCopy(this.#privateKey), {
65
- lowS: true
66
- });
57
+ const sig: any = pqc.cryptoSign(getBytesCopy(digest), getBytesCopy(this.#privateKey));
58
+ const pubBytes: any = getBytes(this.publicKey);
59
+ const combinedSig = qcsdk.combinePublicKeySignature(pubBytes, sig);
67
60
 
68
61
  return Signature.from({
69
- r: toBeHex(sig.r, 32),
70
- s: toBeHex(sig.s, 32),
71
- v: (sig.recovery ? 0x1c: 0x1b)
62
+ r: this.publicKey,
63
+ s: combinedSig,
64
+ v: 0x1
72
65
  });
73
66
  }
74
67
 
75
68
  /**
76
- * Returns the [[link-wiki-ecdh]] shared secret between this
77
- * private key and the %%other%% key.
78
- *
79
- * The %%other%% key may be any type of key, a raw public key,
80
- * a compressed/uncompressed pubic key or aprivate key.
81
- *
82
- * Best practice is usually to use a cryptographic hash on the
83
- * returned value before using it as a symetric secret.
84
- *
85
- * @example:
86
- * sign1 = new SigningKey(id("some-secret-1"))
87
- * sign2 = new SigningKey(id("some-secret-2"))
88
- *
89
- * // Notice that privA.computeSharedSecret(pubB)...
90
- * sign1.computeSharedSecret(sign2.publicKey)
91
- * //_result:
92
- *
93
- * // ...is equal to privB.computeSharedSecret(pubA).
94
- * sign2.computeSharedSecret(sign1.publicKey)
95
- * //_result:
96
- */
97
- computeSharedSecret(other: BytesLike): string {
98
- const pubKey = SigningKey.computePublicKey(other);
99
- return hexlify(secp256k1.getSharedSecret(getBytesCopy(this.#privateKey), getBytes(pubKey), false));
100
- }
101
-
102
- /**
103
- * Compute the public key for %%key%%, optionally %%compressed%%.
69
+ * Compute the public key for a private %%key%%.
104
70
  *
105
- * The %%key%% may be any type of key, a raw public key, a
106
- * compressed/uncompressed public key or private key.
107
71
  *
108
72
  * @example:
109
73
  * sign = new SigningKey(id("some-secret"));
110
74
  *
111
- * // Compute the uncompressed public key for a private key
75
+ * // Compute the public key for a private key
112
76
  * SigningKey.computePublicKey(sign.privateKey)
113
77
  * //_result:
114
- *
115
- * // Compute the compressed public key for a private key
116
- * SigningKey.computePublicKey(sign.privateKey, true)
117
- * //_result:
118
- *
119
- * // Compute the uncompressed public key
120
- * SigningKey.computePublicKey(sign.publicKey, false);
121
- * //_result:
122
- *
123
- * // Compute the Compressed a public key
124
- * SigningKey.computePublicKey(sign.publicKey, true);
125
- * //_result:
126
78
  */
127
- static computePublicKey(key: BytesLike, compressed?: boolean): string {
128
- let bytes = getBytes(key, "key");
129
-
130
- // private key
131
- if (bytes.length === 32) {
132
- const pubKey = secp256k1.getPublicKey(bytes, !!compressed);
133
- return hexlify(pubKey);
134
- }
135
-
136
- // raw public key; use uncompressed key with 0x04 prefix
137
- if (bytes.length === 64) {
138
- const pub = new Uint8Array(65);
139
- pub[0] = 0x04;
140
- pub.set(bytes, 1);
141
- bytes = pub;
142
- }
143
-
144
- const point = secp256k1.ProjectivePoint.fromHex(bytes);
145
- return hexlify(point.toRawBytes(compressed));
79
+ static computePublicKey(key: BytesLike): string {
80
+ assertArgument(dataLength(key) === CRYPTO_SECRETKEY_BYTES, "invalid private key", "privateKey", "[REDACTED]");
81
+ let priBytes: any = getBytes(key, "key");
82
+
83
+ let pubKey = qcsdk.publicKeyFromPrivateKey(priBytes);
84
+
85
+ return pubKey;
146
86
  }
147
87
 
148
88
  /**
@@ -164,33 +104,15 @@ export class SigningKey {
164
104
  *
165
105
  */
166
106
  static recoverPublicKey(digest: BytesLike, signature: SignatureLike): string {
167
- assertArgument(dataLength(digest) === 32, "invalid digest length", "digest", digest);
107
+ assertArgument(dataLength(digest) === CRYPTO_MESSAGE_LENGTH, "invalid digest length", "digest", digest);
168
108
 
169
109
  const sig = Signature.from(signature);
110
+ let sigBytes: any = getBytes(sig.s);
111
+ let digestBytes: any = digest;
170
112
 
171
- let secpSig = secp256k1.Signature.fromCompact(getBytesCopy(concat([ sig.r, sig.s ])));
172
- secpSig = secpSig.addRecoveryBit(sig.yParity);
173
-
174
- const pubKey = secpSig.recoverPublicKey(getBytesCopy(digest));
175
- assertArgument(pubKey != null, "invalid signature for digest", "signature", signature);
176
-
177
- return "0x" + pubKey.toHex(false);
178
- }
113
+ let publicKey = qcsdk.publicKeyFromSignature(digestBytes, sigBytes);
179
114
 
180
- /**
181
- * Returns the point resulting from adding the ellipic curve points
182
- * %%p0%% and %%p1%%.
183
- *
184
- * This is not a common function most developers should require, but
185
- * can be useful for certain privacy-specific techniques.
186
- *
187
- * For example, it is used by [[HDNodeWallet]] to compute child
188
- * addresses from parent public keys and chain codes.
189
- */
190
- static addPoints(p0: BytesLike, p1: BytesLike, compressed?: boolean): string {
191
- const pub0 = secp256k1.ProjectivePoint.fromHex(SigningKey.computePublicKey(p0).substring(2));
192
- const pub1 = secp256k1.ProjectivePoint.fromHex(SigningKey.computePublicKey(p1).substring(2));
193
- return "0x" + pub0.add(pub1).toHex(!!compressed)
115
+ return publicKey;
194
116
  }
195
117
  }
196
118
 
@@ -1,16 +1,6 @@
1
1
 
2
2
  import { assert } from "../utils/index.js";
3
3
 
4
- import { AnkrProvider } from "./provider-ankr.js";
5
- import { AlchemyProvider } from "./provider-alchemy.js";
6
- //import { BlockscoutProvider } from "./provider-blockscout.js";
7
- import { ChainstackProvider } from "./provider-chainstack.js";
8
- import { CloudflareProvider } from "./provider-cloudflare.js";
9
- import { EtherscanProvider } from "./provider-etherscan.js";
10
- import { InfuraProvider } from "./provider-infura.js";
11
- //import { PocketProvider } from "./provider-pocket.js";
12
- import { QuickNodeProvider } from "./provider-quicknode.js";
13
-
14
4
  import { FallbackProvider } from "./provider-fallback.js";
15
5
  import { JsonRpcProvider } from "./provider-jsonrpc.js";
16
6
  import { Network } from "./network.js";
@@ -47,14 +37,6 @@ const Testnets = "goerli kovan sepolia classicKotti optimism-goerli arbitrum-goe
47
37
  * will whitelist **only** those backends.
48
38
  *
49
39
  * Current backend strings supported are:
50
- * - ``"alchemy"``
51
- * - ``"ankr"``
52
- * - ``"cloudflare"``
53
- * - ``"chainstack"``
54
- * - ``"etherscan"``
55
- * - ``"infura"``
56
- * - ``"publicPolygon"``
57
- * - ``"quicknode"``
58
40
  *
59
41
  * @example:
60
42
  * // Connect to a local Geth node
@@ -74,17 +56,6 @@ const Testnets = "goerli kovan sepolia classicKotti optimism-goerli arbitrum-goe
74
56
  export function getDefaultProvider(network?: string | Networkish | WebSocketLike, options?: any): AbstractProvider {
75
57
  if (options == null) { options = { }; }
76
58
 
77
- const allowService = (name: string) => {
78
- if (options[name] === "-") { return false; }
79
- if (typeof(options.exclusive) === "string") {
80
- return (name === options.exclusive);
81
- }
82
- if (Array.isArray(options.exclusive)) {
83
- return (options.exclusive.indexOf(name) !== -1);
84
- }
85
- return true;
86
- };
87
-
88
59
  if (typeof(network) === "string" && network.match(/^https?:/)) {
89
60
  return new JsonRpcProvider(network);
90
61
  }
@@ -102,83 +73,6 @@ export function getDefaultProvider(network?: string | Networkish | WebSocketLike
102
73
 
103
74
  const providers: Array<AbstractProvider> = [ ];
104
75
 
105
- if (allowService("publicPolygon") && staticNetwork) {
106
- if (staticNetwork.name === "matic") {
107
- providers.push(new JsonRpcProvider("https:/\/polygon-rpc.com/", staticNetwork, { staticNetwork }));
108
- } else if (staticNetwork.name === "matic-amoy") {
109
- providers.push(new JsonRpcProvider("https:/\/rpc-amoy.polygon.technology/", staticNetwork, { staticNetwork }));
110
- }
111
- }
112
-
113
- if (allowService("alchemy")) {
114
- try {
115
- providers.push(new AlchemyProvider(network, options.alchemy));
116
- } catch (error) { }
117
- }
118
-
119
- if (allowService("ankr") && options.ankr != null) {
120
- try {
121
- providers.push(new AnkrProvider(network, options.ankr));
122
- } catch (error) { }
123
- }
124
- /* Temporarily remove until custom error issue is fixed
125
- if (allowService("blockscout")) {
126
- try {
127
- providers.push(new BlockscoutProvider(network, options.blockscout));
128
- } catch (error) { }
129
- }
130
- */
131
- if (allowService("chainstack")) {
132
- try {
133
- providers.push(new ChainstackProvider(network, options.chainstack));
134
- } catch (error) { }
135
- }
136
-
137
- if (allowService("cloudflare")) {
138
- try {
139
- providers.push(new CloudflareProvider(network));
140
- } catch (error) { }
141
- }
142
-
143
- if (allowService("etherscan")) {
144
- try {
145
- providers.push(new EtherscanProvider(network, options.etherscan));
146
- } catch (error) { }
147
- }
148
-
149
- if (allowService("infura")) {
150
- try {
151
- let projectId = options.infura;
152
- let projectSecret: undefined | string = undefined;
153
- if (typeof(projectId) === "object") {
154
- projectSecret = projectId.projectSecret;
155
- projectId = projectId.projectId;
156
- }
157
- providers.push(new InfuraProvider(network, projectId, projectSecret));
158
- } catch (error) { }
159
- }
160
- /*
161
- if (options.pocket !== "-") {
162
- try {
163
- let appId = options.pocket;
164
- let secretKey: undefined | string = undefined;
165
- let loadBalancer: undefined | boolean = undefined;
166
- if (typeof(appId) === "object") {
167
- loadBalancer = !!appId.loadBalancer;
168
- secretKey = appId.secretKey;
169
- appId = appId.appId;
170
- }
171
- providers.push(new PocketProvider(network, appId, secretKey, loadBalancer));
172
- } catch (error) { console.log(error); }
173
- }
174
- */
175
- if (allowService("quicknode")) {
176
- try {
177
- let token = options.quicknode;
178
- providers.push(new QuickNodeProvider(network, token));
179
- } catch (error) { }
180
- }
181
-
182
76
  assert(providers.length, "unsupported default network", "UNSUPPORTED_OPERATION", {
183
77
  operation: "getDefaultProvider"
184
78
  });
@@ -59,16 +59,6 @@ export { JsonRpcApiProvider, JsonRpcProvider, JsonRpcSigner } from "./provider-j
59
59
 
60
60
  export { BrowserProvider } from "./provider-browser.js";
61
61
 
62
- export { AlchemyProvider } from "./provider-alchemy.js";
63
- export { BlockscoutProvider } from "./provider-blockscout.js";
64
- export { AnkrProvider } from "./provider-ankr.js";
65
- export { CloudflareProvider } from "./provider-cloudflare.js";
66
- export { ChainstackProvider } from "./provider-chainstack.js";
67
- export { EtherscanProvider, EtherscanPlugin } from "./provider-etherscan.js";
68
- export { InfuraProvider, InfuraWebSocketProvider } from "./provider-infura.js";
69
- export { PocketProvider } from "./provider-pocket.js";
70
- export { QuickNodeProvider } from "./provider-quicknode.js";
71
-
72
62
  import { IpcSocketProvider } from "./provider-ipcsocket.js"; /*-browser*/
73
63
  export { IpcSocketProvider };
74
64
  export { SocketProvider } from "./provider-socket.js";