@bsv/sdk 1.1.32 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/dist/cjs/mod.js +4 -0
  2. package/dist/cjs/mod.js.map +1 -1
  3. package/dist/cjs/package.json +4 -3
  4. package/dist/cjs/src/auth/Certificate.js +163 -0
  5. package/dist/cjs/src/auth/Certificate.js.map +1 -0
  6. package/dist/cjs/src/auth/index.js +9 -0
  7. package/dist/cjs/src/auth/index.js.map +1 -0
  8. package/dist/cjs/src/compat/BSM.js +17 -7
  9. package/dist/cjs/src/compat/BSM.js.map +1 -1
  10. package/dist/cjs/src/compat/ECIES.js +17 -7
  11. package/dist/cjs/src/compat/ECIES.js.map +1 -1
  12. package/dist/cjs/src/compat/HD.js +17 -7
  13. package/dist/cjs/src/compat/HD.js.map +1 -1
  14. package/dist/cjs/src/compat/Mnemonic.js +17 -7
  15. package/dist/cjs/src/compat/Mnemonic.js.map +1 -1
  16. package/dist/cjs/src/compat/index.js +17 -7
  17. package/dist/cjs/src/compat/index.js.map +1 -1
  18. package/dist/cjs/src/messages/index.js +17 -7
  19. package/dist/cjs/src/messages/index.js.map +1 -1
  20. package/dist/cjs/src/overlay-tools/LookupResolver.js +170 -0
  21. package/dist/cjs/src/overlay-tools/LookupResolver.js.map +1 -0
  22. package/dist/cjs/src/overlay-tools/OverlayAdminTokenTemplate.js +69 -0
  23. package/dist/cjs/src/overlay-tools/OverlayAdminTokenTemplate.js.map +1 -0
  24. package/dist/cjs/src/overlay-tools/SHIPBroadcaster.js +336 -0
  25. package/dist/cjs/src/overlay-tools/SHIPBroadcaster.js.map +1 -0
  26. package/dist/cjs/src/overlay-tools/index.js +29 -0
  27. package/dist/cjs/src/overlay-tools/index.js.map +1 -0
  28. package/dist/cjs/src/primitives/PrivateKey.js +17 -7
  29. package/dist/cjs/src/primitives/PrivateKey.js.map +1 -1
  30. package/dist/cjs/src/primitives/TransactionSignature.js +17 -7
  31. package/dist/cjs/src/primitives/TransactionSignature.js.map +1 -1
  32. package/dist/cjs/src/primitives/index.js +17 -7
  33. package/dist/cjs/src/primitives/index.js.map +1 -1
  34. package/dist/cjs/src/script/Spend.js +17 -7
  35. package/dist/cjs/src/script/Spend.js.map +1 -1
  36. package/dist/cjs/src/script/templates/PushDrop.js +218 -0
  37. package/dist/cjs/src/script/templates/PushDrop.js.map +1 -0
  38. package/dist/cjs/src/script/templates/index.js +3 -1
  39. package/dist/cjs/src/script/templates/index.js.map +1 -1
  40. package/dist/cjs/src/transaction/Beef.js +35 -6
  41. package/dist/cjs/src/transaction/Beef.js.map +1 -1
  42. package/dist/cjs/src/transaction/Transaction.js +13 -4
  43. package/dist/cjs/src/transaction/Transaction.js.map +1 -1
  44. package/dist/cjs/src/transaction/http/DefaultHttpClient.js +1 -1
  45. package/dist/cjs/src/transaction/http/DefaultHttpClient.js.map +1 -1
  46. package/dist/cjs/src/wallet/CachedKeyDeriver.js +177 -0
  47. package/dist/cjs/src/wallet/CachedKeyDeriver.js.map +1 -0
  48. package/dist/cjs/src/wallet/KeyDeriver.js +174 -0
  49. package/dist/cjs/src/wallet/KeyDeriver.js.map +1 -0
  50. package/dist/cjs/src/wallet/ProtoWallet.js +245 -0
  51. package/dist/cjs/src/wallet/ProtoWallet.js.map +1 -0
  52. package/dist/cjs/src/wallet/Wallet.interfaces.js +3 -0
  53. package/dist/cjs/src/wallet/Wallet.interfaces.js.map +1 -0
  54. package/dist/cjs/src/wallet/WalletClient.js +181 -0
  55. package/dist/cjs/src/wallet/WalletClient.js.map +1 -0
  56. package/dist/cjs/src/wallet/WalletError.js +28 -0
  57. package/dist/cjs/src/wallet/WalletError.js.map +1 -0
  58. package/dist/cjs/src/wallet/index.js +34 -0
  59. package/dist/cjs/src/wallet/index.js.map +1 -0
  60. package/dist/cjs/src/wallet/substrates/HTTPWalletWire.js +45 -0
  61. package/dist/cjs/src/wallet/substrates/HTTPWalletWire.js.map +1 -0
  62. package/dist/cjs/src/wallet/substrates/WalletWire.js +3 -0
  63. package/dist/cjs/src/wallet/substrates/WalletWire.js.map +1 -0
  64. package/dist/cjs/src/wallet/substrates/WalletWireCalls.js +36 -0
  65. package/dist/cjs/src/wallet/substrates/WalletWireCalls.js.map +1 -0
  66. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +1821 -0
  67. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -0
  68. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js +1305 -0
  69. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js.map +1 -0
  70. package/dist/cjs/src/wallet/substrates/XDM.js +130 -0
  71. package/dist/cjs/src/wallet/substrates/XDM.js.map +1 -0
  72. package/dist/cjs/src/wallet/substrates/index.js +33 -0
  73. package/dist/cjs/src/wallet/substrates/index.js.map +1 -0
  74. package/dist/cjs/src/wallet/substrates/window.CWI.js +102 -0
  75. package/dist/cjs/src/wallet/substrates/window.CWI.js.map +1 -0
  76. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  77. package/dist/esm/mod.js +4 -0
  78. package/dist/esm/mod.js.map +1 -1
  79. package/dist/esm/src/auth/Certificate.js +185 -0
  80. package/dist/esm/src/auth/Certificate.js.map +1 -0
  81. package/dist/esm/src/auth/index.js +2 -0
  82. package/dist/esm/src/auth/index.js.map +1 -0
  83. package/dist/esm/src/overlay-tools/LookupResolver.js +167 -0
  84. package/dist/esm/src/overlay-tools/LookupResolver.js.map +1 -0
  85. package/dist/esm/src/overlay-tools/OverlayAdminTokenTemplate.js +64 -0
  86. package/dist/esm/src/overlay-tools/OverlayAdminTokenTemplate.js.map +1 -0
  87. package/dist/esm/src/overlay-tools/SHIPBroadcaster.js +335 -0
  88. package/dist/esm/src/overlay-tools/SHIPBroadcaster.js.map +1 -0
  89. package/dist/esm/src/overlay-tools/index.js +6 -0
  90. package/dist/esm/src/overlay-tools/index.js.map +1 -0
  91. package/dist/esm/src/script/templates/PushDrop.js +215 -0
  92. package/dist/esm/src/script/templates/PushDrop.js.map +1 -0
  93. package/dist/esm/src/script/templates/index.js +1 -0
  94. package/dist/esm/src/script/templates/index.js.map +1 -1
  95. package/dist/esm/src/transaction/Beef.js +35 -6
  96. package/dist/esm/src/transaction/Beef.js.map +1 -1
  97. package/dist/esm/src/transaction/Transaction.js +13 -4
  98. package/dist/esm/src/transaction/Transaction.js.map +1 -1
  99. package/dist/esm/src/transaction/http/DefaultHttpClient.js +1 -1
  100. package/dist/esm/src/transaction/http/DefaultHttpClient.js.map +1 -1
  101. package/dist/esm/src/wallet/CachedKeyDeriver.js +174 -0
  102. package/dist/esm/src/wallet/CachedKeyDeriver.js.map +1 -0
  103. package/dist/esm/src/wallet/KeyDeriver.js +172 -0
  104. package/dist/esm/src/wallet/KeyDeriver.js.map +1 -0
  105. package/dist/esm/src/wallet/ProtoWallet.js +207 -0
  106. package/dist/esm/src/wallet/ProtoWallet.js.map +1 -0
  107. package/dist/esm/src/wallet/Wallet.interfaces.js +2 -0
  108. package/dist/esm/src/wallet/Wallet.interfaces.js.map +1 -0
  109. package/dist/esm/src/wallet/WalletClient.js +177 -0
  110. package/dist/esm/src/wallet/WalletClient.js.map +1 -0
  111. package/dist/esm/src/wallet/WalletError.js +25 -0
  112. package/dist/esm/src/wallet/WalletError.js.map +1 -0
  113. package/dist/esm/src/wallet/index.js +9 -0
  114. package/dist/esm/src/wallet/index.js.map +1 -0
  115. package/dist/esm/src/wallet/substrates/HTTPWalletWire.js +42 -0
  116. package/dist/esm/src/wallet/substrates/HTTPWalletWire.js.map +1 -0
  117. package/dist/esm/src/wallet/substrates/WalletWire.js +2 -0
  118. package/dist/esm/src/wallet/substrates/WalletWire.js.map +1 -0
  119. package/dist/esm/src/wallet/substrates/WalletWireCalls.js +34 -0
  120. package/dist/esm/src/wallet/substrates/WalletWireCalls.js.map +1 -0
  121. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +1816 -0
  122. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -0
  123. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js +1300 -0
  124. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js.map +1 -0
  125. package/dist/esm/src/wallet/substrates/XDM.js +128 -0
  126. package/dist/esm/src/wallet/substrates/XDM.js.map +1 -0
  127. package/dist/esm/src/wallet/substrates/index.js +8 -0
  128. package/dist/esm/src/wallet/substrates/index.js.map +1 -0
  129. package/dist/esm/src/wallet/substrates/window.CWI.js +100 -0
  130. package/dist/esm/src/wallet/substrates/window.CWI.js.map +1 -0
  131. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  132. package/dist/types/mod.d.ts +4 -0
  133. package/dist/types/mod.d.ts.map +1 -1
  134. package/dist/types/src/auth/Certificate.d.ts +76 -0
  135. package/dist/types/src/auth/Certificate.d.ts.map +1 -0
  136. package/dist/types/src/auth/index.d.ts +2 -0
  137. package/dist/types/src/auth/index.d.ts.map +1 -0
  138. package/dist/types/src/overlay-tools/LookupResolver.d.ts +71 -0
  139. package/dist/types/src/overlay-tools/LookupResolver.d.ts.map +1 -0
  140. package/dist/types/src/overlay-tools/OverlayAdminTokenTemplate.d.ts +44 -0
  141. package/dist/types/src/overlay-tools/OverlayAdminTokenTemplate.d.ts.map +1 -0
  142. package/dist/types/src/overlay-tools/SHIPBroadcaster.d.ts +90 -0
  143. package/dist/types/src/overlay-tools/SHIPBroadcaster.d.ts.map +1 -0
  144. package/dist/types/src/overlay-tools/index.d.ts +6 -0
  145. package/dist/types/src/overlay-tools/index.d.ts.map +1 -0
  146. package/dist/types/src/script/templates/PushDrop.d.ts +53 -0
  147. package/dist/types/src/script/templates/PushDrop.d.ts.map +1 -0
  148. package/dist/types/src/script/templates/index.d.ts +1 -0
  149. package/dist/types/src/script/templates/index.d.ts.map +1 -1
  150. package/dist/types/src/transaction/Beef.d.ts +16 -1
  151. package/dist/types/src/transaction/Beef.d.ts.map +1 -1
  152. package/dist/types/src/transaction/Transaction.d.ts.map +1 -1
  153. package/dist/types/src/wallet/CachedKeyDeriver.d.ts +92 -0
  154. package/dist/types/src/wallet/CachedKeyDeriver.d.ts.map +1 -0
  155. package/dist/types/src/wallet/KeyDeriver.d.ts +72 -0
  156. package/dist/types/src/wallet/KeyDeriver.d.ts.map +1 -0
  157. package/dist/types/src/wallet/ProtoWallet.d.ts +415 -0
  158. package/dist/types/src/wallet/ProtoWallet.d.ts.map +1 -0
  159. package/dist/types/src/wallet/Wallet.interfaces.d.ts +996 -0
  160. package/dist/types/src/wallet/Wallet.interfaces.d.ts.map +1 -0
  161. package/dist/types/src/wallet/WalletClient.d.ts +182 -0
  162. package/dist/types/src/wallet/WalletClient.d.ts.map +1 -0
  163. package/dist/types/src/wallet/WalletError.d.ts +14 -0
  164. package/dist/types/src/wallet/WalletError.d.ts.map +1 -0
  165. package/dist/types/src/wallet/index.d.ts +9 -0
  166. package/dist/types/src/wallet/index.d.ts.map +1 -0
  167. package/dist/types/src/wallet/substrates/HTTPWalletWire.d.ts +9 -0
  168. package/dist/types/src/wallet/substrates/HTTPWalletWire.d.ts.map +1 -0
  169. package/dist/types/src/wallet/substrates/WalletWire.d.ts +7 -0
  170. package/dist/types/src/wallet/substrates/WalletWire.d.ts.map +1 -0
  171. package/dist/types/src/wallet/substrates/WalletWireCalls.d.ts +33 -0
  172. package/dist/types/src/wallet/substrates/WalletWireCalls.d.ts.map +1 -0
  173. package/dist/types/src/wallet/substrates/WalletWireProcessor.d.ts +18 -0
  174. package/dist/types/src/wallet/substrates/WalletWireProcessor.d.ts.map +1 -0
  175. package/dist/types/src/wallet/substrates/WalletWireTransceiver.d.ts +196 -0
  176. package/dist/types/src/wallet/substrates/WalletWireTransceiver.d.ts.map +1 -0
  177. package/dist/types/src/wallet/substrates/XDM.d.ts +412 -0
  178. package/dist/types/src/wallet/substrates/XDM.d.ts.map +1 -0
  179. package/dist/types/src/wallet/substrates/index.d.ts +8 -0
  180. package/dist/types/src/wallet/substrates/index.d.ts.map +1 -0
  181. package/dist/types/src/wallet/substrates/window.CWI.d.ts +410 -0
  182. package/dist/types/src/wallet/substrates/window.CWI.d.ts.map +1 -0
  183. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  184. package/dist/umd/bundle.js +1 -1
  185. package/docs/overlay-tools.md +551 -0
  186. package/docs/script.md +135 -0
  187. package/docs/totp.md +119 -0
  188. package/docs/transaction.md +25 -0
  189. package/docs/wallet-substrates.md +10 -0
  190. package/docs/wallet.md +4182 -0
  191. package/mod.ts +5 -1
  192. package/package.json +44 -3
  193. package/src/auth/Certificate.ts +233 -0
  194. package/src/auth/__tests/Certificate.test.ts +282 -0
  195. package/src/auth/index.ts +1 -0
  196. package/src/overlay-tools/LookupResolver.ts +228 -0
  197. package/src/overlay-tools/OverlayAdminTokenTemplate.ts +79 -0
  198. package/src/overlay-tools/SHIPBroadcaster.ts +405 -0
  199. package/src/overlay-tools/__tests/LookupResolver.test.ts +1403 -0
  200. package/src/overlay-tools/__tests/OverlayAdminTokenTemplate.test.ts +69 -0
  201. package/src/overlay-tools/__tests/SHIPBroadcaster.test.ts +904 -0
  202. package/src/overlay-tools/index.ts +5 -0
  203. package/src/script/templates/PushDrop.ts +246 -0
  204. package/src/script/templates/__tests/PushDrop.test.ts +158 -0
  205. package/src/script/templates/index.ts +1 -0
  206. package/src/transaction/Beef.ts +36 -6
  207. package/src/transaction/Transaction.ts +13 -4
  208. package/src/transaction/__tests/Beef.test.ts +20 -6
  209. package/src/transaction/http/DefaultHttpClient.ts +1 -1
  210. package/src/wallet/CachedKeyDeriver.ts +193 -0
  211. package/src/wallet/KeyDeriver.ts +178 -0
  212. package/src/wallet/ProtoWallet.ts +732 -0
  213. package/src/wallet/Wallet.interfaces.ts +1170 -0
  214. package/src/wallet/WalletClient.ts +201 -0
  215. package/src/wallet/WalletError.ts +27 -0
  216. package/src/wallet/__tests/CachedKeyDeriver.test.ts +322 -0
  217. package/src/wallet/__tests/KeyDeriver.test.ts +118 -0
  218. package/src/wallet/__tests/ProtoWallet.test.ts +543 -0
  219. package/src/wallet/index.ts +8 -0
  220. package/src/wallet/substrates/HTTPWalletWire.ts +47 -0
  221. package/src/wallet/substrates/WalletWire.ts +6 -0
  222. package/src/wallet/substrates/WalletWireCalls.ts +34 -0
  223. package/src/wallet/substrates/WalletWireProcessor.ts +2046 -0
  224. package/src/wallet/substrates/WalletWireTransceiver.ts +1454 -0
  225. package/src/wallet/substrates/XDM.ts +157 -0
  226. package/src/wallet/substrates/__tests/WalletWire.integration.test.ts +2194 -0
  227. package/src/wallet/substrates/__tests/XDM.test.ts +659 -0
  228. package/src/wallet/substrates/index.ts +7 -0
  229. package/src/wallet/substrates/window.CWI.ts +133 -0
@@ -0,0 +1,174 @@
1
+ import { PrivateKey, PublicKey } from '../primitives/index.js';
2
+ import KeyDeriver from './KeyDeriver.js';
3
+ /**
4
+ * A cached version of KeyDeriver that caches the results of key derivation methods.
5
+ * This is useful for optimizing performance when the same keys are derived multiple times.
6
+ * It supports configurable cache size with sane defaults and maintains cache entries using LRU (Least Recently Used) eviction policy.
7
+ */
8
+ export default class CachedKeyDeriver {
9
+ keyDeriver;
10
+ cache;
11
+ maxCacheSize;
12
+ /**
13
+ * Initializes the CachedKeyDeriver instance with a root private key and optional cache settings.
14
+ * @param {PrivateKey | 'anyone'} rootKey - The root private key or the string 'anyone'.
15
+ * @param {Object} [options] - Optional settings for the cache.
16
+ * @param {number} [options.maxCacheSize=1000] - The maximum number of entries to store in the cache.
17
+ */
18
+ constructor(rootKey, options) {
19
+ this.keyDeriver = new KeyDeriver(rootKey);
20
+ this.cache = new Map();
21
+ this.maxCacheSize = options?.maxCacheSize || 1000;
22
+ }
23
+ /**
24
+ * Derives a public key based on protocol ID, key ID, and counterparty.
25
+ * Caches the result for future calls with the same parameters.
26
+ * @param {[0 | 1 | 2, string]} protocolID - The protocol ID including a security level and protocol name.
27
+ * @param {string} keyID - The key identifier.
28
+ * @param {PublicKey | string | 'self' | 'anyone'} counterparty - The counterparty's public key or a predefined value ('self' or 'anyone').
29
+ * @param {boolean} [forSelf=false] - Whether deriving for self.
30
+ * @returns {PublicKey} - The derived public key.
31
+ */
32
+ derivePublicKey(protocolID, keyID, counterparty, forSelf = false) {
33
+ const cacheKey = this.generateCacheKey('derivePublicKey', protocolID, keyID, counterparty, forSelf);
34
+ if (this.cache.has(cacheKey)) {
35
+ return this.cacheGet(cacheKey);
36
+ }
37
+ else {
38
+ const result = this.keyDeriver.derivePublicKey(protocolID, keyID, counterparty, forSelf);
39
+ this.cacheSet(cacheKey, result);
40
+ return result;
41
+ }
42
+ }
43
+ /**
44
+ * Derives a private key based on protocol ID, key ID, and counterparty.
45
+ * Caches the result for future calls with the same parameters.
46
+ * @param {[0 | 1 | 2, string]} protocolID - The protocol ID including a security level and protocol name.
47
+ * @param {string} keyID - The key identifier.
48
+ * @param {PublicKey | string | 'self' | 'anyone'} counterparty - The counterparty's public key or a predefined value ('self' or 'anyone').
49
+ * @returns {PrivateKey} - The derived private key.
50
+ */
51
+ derivePrivateKey(protocolID, keyID, counterparty) {
52
+ const cacheKey = this.generateCacheKey('derivePrivateKey', protocolID, keyID, counterparty);
53
+ if (this.cache.has(cacheKey)) {
54
+ return this.cacheGet(cacheKey);
55
+ }
56
+ else {
57
+ const result = this.keyDeriver.derivePrivateKey(protocolID, keyID, counterparty);
58
+ this.cacheSet(cacheKey, result);
59
+ return result;
60
+ }
61
+ }
62
+ /**
63
+ * Derives a symmetric key based on protocol ID, key ID, and counterparty.
64
+ * Caches the result for future calls with the same parameters.
65
+ * @param {[0 | 1 | 2, string]} protocolID - The protocol ID including a security level and protocol name.
66
+ * @param {string} keyID - The key identifier.
67
+ * @param {PublicKey | string | 'self' | 'anyone'} counterparty - The counterparty's public key or a predefined value ('self' or 'anyone').
68
+ * @returns {SymmetricKey} - The derived symmetric key.
69
+ * @throws {Error} - Throws an error if attempting to derive a symmetric key for 'anyone'.
70
+ */
71
+ deriveSymmetricKey(protocolID, keyID, counterparty) {
72
+ const cacheKey = this.generateCacheKey('deriveSymmetricKey', protocolID, keyID, counterparty);
73
+ if (this.cache.has(cacheKey)) {
74
+ return this.cacheGet(cacheKey);
75
+ }
76
+ else {
77
+ const result = this.keyDeriver.deriveSymmetricKey(protocolID, keyID, counterparty);
78
+ this.cacheSet(cacheKey, result);
79
+ return result;
80
+ }
81
+ }
82
+ /**
83
+ * Reveals the shared secret between the root key and the counterparty.
84
+ * Caches the result for future calls with the same parameters.
85
+ * @param {PublicKey | string | 'self' | 'anyone'} counterparty - The counterparty's public key or a predefined value ('self' or 'anyone').
86
+ * @returns {number[]} - The shared secret as a number array.
87
+ * @throws {Error} - Throws an error if attempting to reveal a shared secret for 'self'.
88
+ */
89
+ revealCounterpartySecret(counterparty) {
90
+ const cacheKey = this.generateCacheKey('revealCounterpartySecret', counterparty);
91
+ if (this.cache.has(cacheKey)) {
92
+ return this.cacheGet(cacheKey);
93
+ }
94
+ else {
95
+ const result = this.keyDeriver.revealCounterpartySecret(counterparty);
96
+ this.cacheSet(cacheKey, result);
97
+ return result;
98
+ }
99
+ }
100
+ /**
101
+ * Reveals the specific key association for a given protocol ID, key ID, and counterparty.
102
+ * Caches the result for future calls with the same parameters.
103
+ * @param {PublicKey | string | 'self' | 'anyone'} counterparty - The counterparty's public key or a predefined value ('self' or 'anyone').
104
+ * @param {[0 | 1 | 2, string]} protocolID - The protocol ID including a security level and protocol name.
105
+ * @param {string} keyID - The key identifier.
106
+ * @returns {number[]} - The specific key association as a number array.
107
+ */
108
+ revealSpecificSecret(counterparty, protocolID, keyID) {
109
+ const cacheKey = this.generateCacheKey('revealSpecificSecret', counterparty, protocolID, keyID);
110
+ if (this.cache.has(cacheKey)) {
111
+ return this.cacheGet(cacheKey);
112
+ }
113
+ else {
114
+ const result = this.keyDeriver.revealSpecificSecret(counterparty, protocolID, keyID);
115
+ this.cacheSet(cacheKey, result);
116
+ return result;
117
+ }
118
+ }
119
+ /**
120
+ * Generates a unique cache key based on the method name and input parameters.
121
+ * @param {string} methodName - The name of the method.
122
+ * @param {...any} args - The arguments passed to the method.
123
+ * @returns {string} - The generated cache key.
124
+ */
125
+ generateCacheKey(methodName, ...args) {
126
+ const serializedArgs = args.map((arg) => this.serializeArgument(arg)).join('|');
127
+ return `${methodName}|${serializedArgs}`;
128
+ }
129
+ /**
130
+ * Serializes an argument to a string for use in a cache key.
131
+ * @param {any} arg - The argument to serialize.
132
+ * @returns {string} - The serialized argument.
133
+ */
134
+ serializeArgument(arg) {
135
+ if (arg instanceof PublicKey || arg instanceof PrivateKey) {
136
+ return arg.toString();
137
+ }
138
+ else if (Array.isArray(arg)) {
139
+ return arg.map((item) => this.serializeArgument(item)).join(',');
140
+ }
141
+ else if (typeof arg === 'object' && arg !== null) {
142
+ return JSON.stringify(arg);
143
+ }
144
+ else {
145
+ return String(arg);
146
+ }
147
+ }
148
+ /**
149
+ * Retrieves an item from the cache and updates its position to reflect recent use.
150
+ * @param {string} cacheKey - The key of the cached item.
151
+ * @returns {any} - The cached value.
152
+ */
153
+ cacheGet(cacheKey) {
154
+ const value = this.cache.get(cacheKey);
155
+ // Update the entry to reflect recent use
156
+ this.cache.delete(cacheKey);
157
+ this.cache.set(cacheKey, value);
158
+ return value;
159
+ }
160
+ /**
161
+ * Adds an item to the cache and evicts the least recently used item if necessary.
162
+ * @param {string} cacheKey - The key of the item to cache.
163
+ * @param {any} value - The value to cache.
164
+ */
165
+ cacheSet(cacheKey, value) {
166
+ if (this.cache.size >= this.maxCacheSize) {
167
+ // Evict the least recently used item (first item in Map)
168
+ const firstKey = this.cache.keys().next().value;
169
+ this.cache.delete(firstKey);
170
+ }
171
+ this.cache.set(cacheKey, value);
172
+ }
173
+ }
174
+ //# sourceMappingURL=CachedKeyDeriver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CachedKeyDeriver.js","sourceRoot":"","sources":["../../../../src/wallet/CachedKeyDeriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAgB,MAAM,wBAAwB,CAAA;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AC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAClE,CAAC;aAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACnD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;QAC5B,CAAC;aAAM,CAAC;YACN,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;QACpB,CAAC;IACH,CAAC;IAED;;;;SAIK;IACG,QAAQ,CAAC,QAAgB;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACtC,yCAAyC;QACzC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAC3B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QAC/B,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;SAIK;IACG,QAAQ,CAAC,QAAgB,EAAE,KAAU;QAC3C,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACzC,yDAAyD;YACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAA;YAC/C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAC7B,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;IACjC,CAAC;CACF"}
@@ -0,0 +1,172 @@
1
+ import { PrivateKey, PublicKey, SymmetricKey, Hash, Utils } from '../primitives/index.js';
2
+ /**
3
+ * Class responsible for deriving various types of keys using a root private key.
4
+ * It supports deriving public and private keys, symmetric keys, and revealing key linkages.
5
+ */
6
+ export default class KeyDeriver {
7
+ rootKey;
8
+ /**
9
+ * Initializes the KeyDeriver instance with a root private key.
10
+ * @param {PrivateKey | 'anyone'} rootKey - The root private key or the string 'anyone'.
11
+ */
12
+ constructor(rootKey) {
13
+ if (rootKey === 'anyone') {
14
+ this.rootKey = new PrivateKey(1);
15
+ }
16
+ else {
17
+ this.rootKey = rootKey;
18
+ }
19
+ }
20
+ /**
21
+ * Derives a public key based on protocol ID, key ID, and counterparty.
22
+ * @param {[0 | 1 | 2, string]} protocolID - The protocol ID including a security level and protocol name.
23
+ * @param {string} keyID - The key identifier.
24
+ * @param {PublicKey | string | 'self' | 'anyone'} counterparty - The counterparty's public key or a predefined value ('self' or 'anyone').
25
+ * @param {boolean} [forSelf=false] - Whether deriving for self.
26
+ * @returns {PublicKey} - The derived public key.
27
+ */
28
+ derivePublicKey(protocolID, keyID, counterparty, forSelf = false) {
29
+ counterparty = this.normalizeCounterparty(counterparty);
30
+ if (forSelf) {
31
+ return this.rootKey.deriveChild(counterparty, this.computeInvoiceNumber(protocolID, keyID)).toPublicKey();
32
+ }
33
+ else {
34
+ return counterparty.deriveChild(this.rootKey, this.computeInvoiceNumber(protocolID, keyID));
35
+ }
36
+ }
37
+ /**
38
+ * Derives a private key based on protocol ID, key ID, and counterparty.
39
+ * @param {[0 | 1 | 2, string]} protocolID - The protocol ID including a security level and protocol name.
40
+ * @param {string} keyID - The key identifier.
41
+ * @param {PublicKey | string | 'self' | 'anyone'} counterparty - The counterparty's public key or a predefined value ('self' or 'anyone').
42
+ * @returns {PrivateKey} - The derived private key.
43
+ */
44
+ derivePrivateKey(protocolID, keyID, counterparty) {
45
+ counterparty = this.normalizeCounterparty(counterparty);
46
+ return this.rootKey.deriveChild(counterparty, this.computeInvoiceNumber(protocolID, keyID));
47
+ }
48
+ /**
49
+ * Derives a symmetric key based on protocol ID, key ID, and counterparty.
50
+ * Note: Symmetric keys should not be derivable by everyone due to security risks.
51
+ * @param {[0 | 1 | 2, string]} protocolID - The protocol ID including a security level and protocol name.
52
+ * @param {string} keyID - The key identifier.
53
+ * @param {PublicKey | string | 'self' | 'anyone'} counterparty - The counterparty's public key or a predefined value ('self' or 'anyone').
54
+ * @returns {SymmetricKey} - The derived symmetric key.
55
+ * @throws {Error} - Throws an error if attempting to derive a symmetric key for 'anyone'.
56
+ */
57
+ deriveSymmetricKey(protocolID, keyID, counterparty) {
58
+ if (counterparty === 'anyone') {
59
+ throw new Error('Symmetric keys (such as encryption keys or HMAC keys) should not be derivable by everyone, because messages would be decryptable by anyone who knows the identity public key of the user, and HMACs would be similarly forgeable.');
60
+ }
61
+ counterparty = this.normalizeCounterparty(counterparty);
62
+ const derivedPublicKey = this.derivePublicKey(protocolID, keyID, counterparty);
63
+ const derivedPrivateKey = this.derivePrivateKey(protocolID, keyID, counterparty);
64
+ return new SymmetricKey(derivedPrivateKey.deriveSharedSecret(derivedPublicKey).x.toArray());
65
+ }
66
+ /**
67
+ * Reveals the shared secret between the root key and the counterparty.
68
+ * Note: This should not be used for 'self'.
69
+ * @param {PublicKey | string | 'self' | 'anyone'} counterparty - The counterparty's public key or a predefined value ('self' or 'anyone').
70
+ * @returns {number[]} - The shared secret as a number array.
71
+ * @throws {Error} - Throws an error if attempting to reveal a shared secret for 'self'.
72
+ */
73
+ revealCounterpartySecret(counterparty) {
74
+ if (counterparty === 'self') {
75
+ throw new Error('Counterparty secrets cannot be revealed for counterparty=self.');
76
+ }
77
+ counterparty = this.normalizeCounterparty(counterparty);
78
+ // Double-check to ensure not revealing the secret for 'self'
79
+ const self = this.rootKey.toPublicKey();
80
+ const keyDerivedBySelf = this.rootKey.deriveChild(self, 'test').toHex();
81
+ const keyDerivedByCounterparty = this.rootKey.deriveChild(counterparty, 'test').toHex();
82
+ if (keyDerivedBySelf === keyDerivedByCounterparty) {
83
+ throw new Error('Counterparty secrets cannot be revealed for counterparty=self.');
84
+ }
85
+ return this.rootKey.deriveSharedSecret(counterparty).encode(true);
86
+ }
87
+ /**
88
+ * Reveals the specific key association for a given protocol ID, key ID, and counterparty.
89
+ * @param {PublicKey | string | 'self' | 'anyone'} counterparty - The counterparty's public key or a predefined value ('self' or 'anyone').
90
+ * @param {[0 | 1 | 2, string]} protocolID - The protocol ID including a security level and protocol name.
91
+ * @param {string} keyID - The key identifier.
92
+ * @returns {number[]} - The specific key association as a number array.
93
+ */
94
+ revealSpecificSecret(counterparty, protocolID, keyID) {
95
+ counterparty = this.normalizeCounterparty(counterparty);
96
+ const sharedSecret = this.rootKey.deriveSharedSecret(counterparty);
97
+ const invoiceNumberBin = Utils.toArray(this.computeInvoiceNumber(protocolID, keyID), 'utf8');
98
+ return Hash.sha256hmac(sharedSecret.encode(true), invoiceNumberBin);
99
+ }
100
+ /**
101
+ * Normalizes the counterparty to a public key.
102
+ * @param {PublicKey | string | 'self' | 'anyone'} counterparty - The counterparty's public key or a predefined value ('self' or 'anyone').
103
+ * @returns {PublicKey} - The normalized counterparty public key.
104
+ * @throws {Error} - Throws an error if the counterparty is invalid.
105
+ */
106
+ normalizeCounterparty(counterparty) {
107
+ if (!counterparty) {
108
+ throw new Error('counterparty must be self, anyone or a public key!');
109
+ }
110
+ else if (counterparty === 'self') {
111
+ return this.rootKey.toPublicKey();
112
+ }
113
+ else if (counterparty === 'anyone') {
114
+ return new PrivateKey(1).toPublicKey();
115
+ }
116
+ else if (typeof counterparty === 'string') {
117
+ return PublicKey.fromString(counterparty);
118
+ }
119
+ else {
120
+ return counterparty;
121
+ }
122
+ }
123
+ /**
124
+ * Computes the invoice number based on the protocol ID and key ID.
125
+ * @param {[0 | 1 | 2, string]} protocolID - The protocol ID including a security level and protocol name.
126
+ * @param {string} keyID - The key identifier.
127
+ * @returns {string} - The computed invoice number.
128
+ * @throws {Error} - Throws an error if protocol ID or key ID are invalid.
129
+ */
130
+ computeInvoiceNumber(protocolID, keyID) {
131
+ const securityLevel = protocolID[0];
132
+ if (!Number.isInteger(securityLevel) || securityLevel < 0 || securityLevel > 2) {
133
+ throw new Error('Protocol security level must be 0, 1, or 2');
134
+ }
135
+ const protocolName = protocolID[1].toLowerCase().trim();
136
+ if (keyID.length > 800) {
137
+ throw new Error('Key IDs must be 800 characters or less');
138
+ }
139
+ if (keyID.length < 1) {
140
+ throw new Error('Key IDs must be 1 character or more');
141
+ }
142
+ if (protocolName.length > 400) {
143
+ // Specific linkage revelation is the only protocol ID that can contain another protocol ID.
144
+ // Therefore, we allow it to be long enough to encapsulate the target protocol
145
+ if (protocolName.startsWith('specific linkage revelation ')) {
146
+ // The format is: 'specific linkage revelation x YYYYY'
147
+ // Where: x is the security level and YYYYY is the target protocol
148
+ // Thus, the max acceptable length is 30 + 400 = 430 bytes
149
+ if (protocolName.length > 430) {
150
+ throw new Error('Specific linkage revelation protocol names must be 430 characters or less');
151
+ }
152
+ }
153
+ else {
154
+ throw new Error('Protocol names must be 400 characters or less');
155
+ }
156
+ }
157
+ if (protocolName.length < 5) {
158
+ throw new Error('Protocol names must be 5 characters or more');
159
+ }
160
+ if (protocolName.includes(' ')) {
161
+ throw new Error('Protocol names cannot contain multiple consecutive spaces (" ")');
162
+ }
163
+ if (!/^[a-z0-9 ]+$/g.test(protocolName)) {
164
+ throw new Error('Protocol names can only contain letters, numbers and spaces');
165
+ }
166
+ if (protocolName.endsWith(' protocol')) {
167
+ throw new Error('No need to end your protocol name with " protocol"');
168
+ }
169
+ return `${securityLevel}-${protocolName}-${keyID}`;
170
+ }
171
+ }
172
+ //# sourceMappingURL=KeyDeriver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyDeriver.js","sourceRoot":"","sources":["../../../../src/wallet/KeyDeriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEzF;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,OAAO,CAAY;IAEnB;;;SAGK;IACL,YAAY,OAA8B;QACxC,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;YACzB,IAAI,CAAC,OAAO,GAAG,IAAI,U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AC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;QACD,IAAI,YAAY,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YAC9B,4FAA4F;YAC5F,8EAA8E;YAC9E,IAAI,YAAY,CAAC,UAAU,CAAC,8BAA8B,CAAC,EAAE,CAAC;gBAC5D,uDAAuD;gBACvD,kEAAkE;gBAClE,0DAA0D;gBAC1D,IAAI,YAAY,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;oBAC9B,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAA;gBAC9F,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;YAClE,CAAC;QACH,CAAC;QACD,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;QAChE,CAAC;QACD,IAAI,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAA;QACrF,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAA;QAChF,CAAC;QACD,IAAI,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;QACvE,CAAC;QACD,OAAO,GAAG,aAAa,IAAI,YAAY,IAAI,KAAK,EAAE,CAAA;IACpD,CAAC;CACF"}
@@ -0,0 +1,207 @@
1
+ import KeyDeriver from './KeyDeriver.js';
2
+ import { Hash, ECDSA, BigNumber, Signature, Schnorr, PublicKey, Point } from '../primitives/index.js';
3
+ import walletErrors, { WalletError } from './WalletError.js';
4
+ /**
5
+ * A ProtoWallet is a structure that fulfills the Wallet interface, capable of performing all foundational cryptographic operations. It can derive keys, create signatures, facilitate encryption and HMAC operations, and reveal key linkages. However, ProtoWallet does not create transactions, manage outputs, interact with the blockchain, enable the management of identity certificates, or store any data.
6
+ */
7
+ export default class ProtoWallet {
8
+ keyDeriver;
9
+ privilegedError = 'ProtoWallet is a single-keyring wallet, operating without context about whether its configured keyring is privileged.';
10
+ constructor(rootKey, KeyDeriverClass = KeyDeriver) {
11
+ this.keyDeriver = new KeyDeriverClass(rootKey);
12
+ }
13
+ async createAction(args, originator) {
14
+ throw new WalletError('ProtoWallet does not support creating transactions.', walletErrors.unsupportedAction);
15
+ }
16
+ async signAction(args, originator) {
17
+ throw new WalletError('ProtoWallet does not support creating transactions.', walletErrors.unsupportedAction);
18
+ }
19
+ async abortAction(args, originator) {
20
+ throw new WalletError('ProtoWallet does not support aborting transactions.', walletErrors.unsupportedAction);
21
+ }
22
+ async listActions(args, originator) {
23
+ throw new WalletError('ProtoWallet does not support retrieving transactions.', walletErrors.unsupportedAction);
24
+ }
25
+ async internalizeAction(args, originator) {
26
+ throw new WalletError('ProtoWallet does not support internalizing transactions.', walletErrors.unsupportedAction);
27
+ }
28
+ async listOutputs(args, originator) {
29
+ throw new WalletError('ProtoWallet does not support retrieving outputs.', walletErrors.unsupportedAction);
30
+ }
31
+ async relinquishOutput(args, originator) {
32
+ throw new WalletError('ProtoWallet does not support deleting outputs.', walletErrors.unsupportedAction);
33
+ }
34
+ async getPublicKey(args, originator) {
35
+ if (args.privileged) {
36
+ throw new WalletError(this.privilegedError);
37
+ }
38
+ if (args.identityKey) {
39
+ return { publicKey: this.keyDeriver.rootKey.toPublicKey().toString() };
40
+ }
41
+ else {
42
+ return {
43
+ publicKey: this.keyDeriver
44
+ .derivePublicKey(args.protocolID, args.keyID, args.counterparty || 'self', args.forSelf)
45
+ .toString()
46
+ };
47
+ }
48
+ }
49
+ async revealCounterpartyKeyLinkage(args, originator) {
50
+ if (args.privileged) {
51
+ throw new WalletError(this.privilegedError);
52
+ }
53
+ const { publicKey: identityKey } = await this.getPublicKey({ identityKey: true });
54
+ const linkage = this.keyDeriver.revealCounterpartySecret(args.counterparty);
55
+ const linkageProof = new Schnorr().generateProof(this.keyDeriver.rootKey, this.keyDeriver.rootKey.toPublicKey(), PublicKey.fromString(args.counterparty), Point.fromDER(linkage));
56
+ const linkageProofBin = [
57
+ ...linkageProof.R.encode(true),
58
+ ...linkageProof.SPrime.encode(true),
59
+ ...linkageProof.z.toArray()
60
+ ];
61
+ const revelationTime = new Date().toISOString();
62
+ const { ciphertext: encryptedLinkage } = await this.encrypt({
63
+ plaintext: linkage,
64
+ protocolID: [2, 'counterparty linkage revelation'],
65
+ keyID: revelationTime,
66
+ counterparty: args.verifier
67
+ });
68
+ const { ciphertext: encryptedLinkageProof } = await this.encrypt({
69
+ plaintext: linkageProofBin,
70
+ protocolID: [2, 'counterparty linkage revelation'],
71
+ keyID: revelationTime,
72
+ counterparty: args.verifier
73
+ });
74
+ return {
75
+ prover: identityKey,
76
+ verifier: args.verifier,
77
+ counterparty: args.counterparty,
78
+ revelationTime,
79
+ encryptedLinkage,
80
+ encryptedLinkageProof
81
+ };
82
+ }
83
+ async revealSpecificKeyLinkage(args, originator) {
84
+ if (args.privileged) {
85
+ throw new WalletError(this.privilegedError);
86
+ }
87
+ const { publicKey: identityKey } = await this.getPublicKey({ identityKey: true });
88
+ const linkage = this.keyDeriver.revealSpecificSecret(args.counterparty, args.protocolID, args.keyID);
89
+ const { ciphertext: encryptedLinkage } = await this.encrypt({
90
+ plaintext: linkage,
91
+ protocolID: [2, `specific linkage revelation ${args.protocolID[0]} ${args.protocolID[1]}`],
92
+ keyID: args.keyID,
93
+ counterparty: args.verifier
94
+ });
95
+ const { ciphertext: encryptedLinkageProof } = await this.encrypt({
96
+ plaintext: [0], // Proof type 0, no proof provided
97
+ protocolID: [2, `specific linkage revelation ${args.protocolID[0]} ${args.protocolID[1]}`],
98
+ keyID: args.keyID,
99
+ counterparty: args.verifier
100
+ });
101
+ return {
102
+ prover: identityKey,
103
+ verifier: args.verifier,
104
+ counterparty: args.counterparty,
105
+ protocolID: args.protocolID,
106
+ keyID: args.keyID,
107
+ encryptedLinkage,
108
+ encryptedLinkageProof,
109
+ proofType: 0
110
+ };
111
+ }
112
+ async encrypt(args, originator) {
113
+ if (args.privileged) {
114
+ throw new WalletError(this.privilegedError);
115
+ }
116
+ const key = this.keyDeriver.deriveSymmetricKey(args.protocolID, args.keyID, args.counterparty || 'self');
117
+ return { ciphertext: key.encrypt(args.plaintext) };
118
+ }
119
+ async decrypt(args, originator) {
120
+ if (args.privileged) {
121
+ throw new WalletError(this.privilegedError);
122
+ }
123
+ const key = this.keyDeriver.deriveSymmetricKey(args.protocolID, args.keyID, args.counterparty || 'self');
124
+ return { plaintext: key.decrypt(args.ciphertext) };
125
+ }
126
+ async createHmac(args, originator) {
127
+ if (args.privileged) {
128
+ throw new WalletError(this.privilegedError);
129
+ }
130
+ const key = this.keyDeriver.deriveSymmetricKey(args.protocolID, args.keyID, args.counterparty || 'self');
131
+ return { hmac: Hash.sha256hmac(key.toArray(), args.data) };
132
+ }
133
+ async verifyHmac(args, originator) {
134
+ if (args.privileged) {
135
+ throw new WalletError(this.privilegedError);
136
+ }
137
+ const key = this.keyDeriver.deriveSymmetricKey(args.protocolID, args.keyID, args.counterparty || 'self');
138
+ const valid = Hash.sha256hmac(key.toArray(), args.data).toString() === args.hmac.toString();
139
+ if (!valid) {
140
+ throw new WalletError('HMAC is not valid', walletErrors.invalidHmac);
141
+ }
142
+ return { valid };
143
+ }
144
+ async createSignature(args, originator) {
145
+ if (args.privileged) {
146
+ throw new WalletError(this.privilegedError);
147
+ }
148
+ let hash = args.hashToDirectlySign;
149
+ if (!hash) {
150
+ hash = Hash.sha256(args.data);
151
+ }
152
+ const key = this.keyDeriver.derivePrivateKey(args.protocolID, args.keyID, args.counterparty || 'anyone');
153
+ return { signature: ECDSA.sign(new BigNumber(hash), key, true).toDER() };
154
+ }
155
+ async verifySignature(args, originator) {
156
+ if (args.privileged) {
157
+ throw new WalletError(this.privilegedError);
158
+ }
159
+ let hash = args.hashToDirectlyVerify;
160
+ if (!hash) {
161
+ hash = Hash.sha256(args.data);
162
+ }
163
+ const key = this.keyDeriver.derivePublicKey(args.protocolID, args.keyID, args.counterparty || 'self', args.forSelf);
164
+ const valid = ECDSA.verify(new BigNumber(hash), Signature.fromDER(args.signature), key);
165
+ if (!valid) {
166
+ throw new WalletError('Signature is not valid', walletErrors.invalidSignature);
167
+ }
168
+ return { valid };
169
+ }
170
+ async acquireCertificate(args, originator) {
171
+ throw new WalletError('ProtoWallet does not support acquiring certificates.', walletErrors.unsupportedAction);
172
+ }
173
+ async listCertificates(args, originator) {
174
+ throw new WalletError('ProtoWallet does not support retrieving certificates.', walletErrors.unsupportedAction);
175
+ }
176
+ async proveCertificate(args, originator) {
177
+ throw new WalletError('ProtoWallet does not support proving certificates.', walletErrors.unsupportedAction);
178
+ }
179
+ async relinquishCertificate(args, originator) {
180
+ throw new WalletError('ProtoWallet does not support deleting certificates.', walletErrors.unsupportedAction);
181
+ }
182
+ async discoverByIdentityKey(args, originator) {
183
+ throw new WalletError('ProtoWallet does not support resolving identities.', walletErrors.unsupportedAction);
184
+ }
185
+ async discoverByAttributes(args, originator) {
186
+ throw new WalletError('ProtoWallet does not support resolving identities.', walletErrors.unsupportedAction);
187
+ }
188
+ async isAuthenticated(args, originator) {
189
+ return { authenticated: true };
190
+ }
191
+ async waitForAuthentication(args, originator) {
192
+ return { authenticated: true };
193
+ }
194
+ async getHeight(args, originator) {
195
+ throw new WalletError('ProtoWallet does not support blockchain tracking.', walletErrors.unsupportedAction);
196
+ }
197
+ async getHeaderForHeight(args, originator) {
198
+ throw new WalletError('ProtoWallet does not support blockchain tracking.', walletErrors.unsupportedAction);
199
+ }
200
+ async getNetwork(args, originator) {
201
+ return { network: 'mainnet' };
202
+ }
203
+ async getVersion(args, originator) {
204
+ return { version: 'proto-1.0.0' };
205
+ }
206
+ }
207
+ //# sourceMappingURL=ProtoWallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProtoWallet.js","sourceRoot":"","sources":["../../../../src/wallet/ProtoWallet.ts"],"names":[],"mappings":"AA6BA,OAAO,UAAU,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAc,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AACjH,OAAO,YAAY,EAAE,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE5D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B,UAAU,CAAY;IACtB,eAAe,GACb,uHAAuH,CAAA;IAEzH,YAAY,OAA8B,EAAE,eAAe,GAAG,UAAU;QACtE,IAAI,CAAC,UAAU,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,CAAA;IAChD,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,IAgCC,EACD,UAAoD;QAcpD,MAAM,IAAI,WAAW,CAAC,qDAAqD,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAA;IAC9G,CAAC;IAED,KAAK,CAAC,UAAU,CACd,IAgBC,EACD,UAAoD;QAUpD,MAAM,IAAI,WAAW,CAAC,qDAAqD,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAA;IAC9G,CAAC;IAED,KAAK,CAAC,WAAW,CACf,IAEC,EACD,UAAoD;QAEpD,MAAM,IAAI,WAAW,CAAC,qDAAqD,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAA;IAC9G,CAAC;IAED,KAAK,CAAC,WAAW,CACf,IAWC,EACD,UAAoD;QAuCpD,MAAM,IAAI,WAAW,CAAC,uDAAuD,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAA;IAChH,CAAC;IAED,KAAK,CAAC,iBAAiB,CACrB,IAkBC,EACD,UAAoD;QAEpD,MAAM,IAAI,WAAW,CAAC,0DAA0D,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AAE,OAAO,EAAE,SAAS,EAAE,CAAA;IAC/B,CAAC;IAED,KAAK,CAAC,UAAU,CACd,IAAQ,EACR,UAAoD;QAEpD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,CAAA;IACnC,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Wallet.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Wallet.interfaces.js","sourceRoot":"","sources":["../../../../src/wallet/Wallet.interfaces.ts"],"names":[],"mappings":""}