@provablehq/sdk 0.10.2 → 0.10.4

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 (219) hide show
  1. package/dist/dynamic/browser.cjs +12 -0
  2. package/dist/dynamic/browser.d.cts +8 -0
  3. package/dist/dynamic/browser.d.ts +2 -2
  4. package/dist/dynamic/node.cjs +12 -0
  5. package/dist/dynamic/node.d.cts +8 -0
  6. package/dist/dynamic/node.d.ts +2 -2
  7. package/dist/mainnet/account.d.cts +347 -0
  8. package/dist/mainnet/browser.cjs +8530 -0
  9. package/dist/mainnet/browser.cjs.map +1 -0
  10. package/dist/mainnet/browser.d.cts +72 -0
  11. package/dist/mainnet/browser.d.ts +3 -3
  12. package/dist/mainnet/browser.js +78 -32
  13. package/dist/mainnet/browser.js.map +1 -1
  14. package/dist/mainnet/constants.d.cts +40 -0
  15. package/dist/mainnet/external-signing.d.cts +76 -0
  16. package/dist/mainnet/integrations/sealance/merkle-tree.d.cts +192 -0
  17. package/dist/mainnet/keys/keystore/error.d.cts +24 -0
  18. package/dist/mainnet/keys/keystore/file.d.cts +177 -0
  19. package/dist/mainnet/keys/keystore/interface.d.cts +161 -0
  20. package/dist/mainnet/keys/provider/interface.d.cts +170 -0
  21. package/dist/mainnet/keys/provider/memory.d.cts +213 -0
  22. package/dist/mainnet/keys/provider/memory.d.ts +6 -2
  23. package/dist/mainnet/keys/provider/offline.d.cts +365 -0
  24. package/dist/mainnet/keys/verifier/interface.d.cts +70 -0
  25. package/dist/mainnet/keys/verifier/memory.d.cts +37 -0
  26. package/dist/mainnet/keys/verifier/memory.d.ts +1 -1
  27. package/dist/mainnet/models/authorization.d.cts +6 -0
  28. package/dist/mainnet/models/authorization.d.ts +2 -2
  29. package/dist/mainnet/models/blockJSON.d.cts +33 -0
  30. package/dist/mainnet/models/confirmed_transaction.d.cts +9 -0
  31. package/dist/mainnet/models/cryptoBoxPubkey.d.cts +4 -0
  32. package/dist/mainnet/models/deployment/deploymentJSON.d.cts +6 -0
  33. package/dist/mainnet/models/deployment/deploymentObject.d.cts +6 -0
  34. package/dist/mainnet/models/encryptedProvingRequest.d.cts +4 -0
  35. package/dist/mainnet/models/execution/executionJSON.d.cts +11 -0
  36. package/dist/mainnet/models/execution/executionObject.d.cts +11 -0
  37. package/dist/mainnet/models/external-signing.d.cts +123 -0
  38. package/dist/mainnet/models/finalizeJSON.d.cts +6 -0
  39. package/dist/mainnet/models/functionInput.d.cts +7 -0
  40. package/dist/mainnet/models/functionObject.d.cts +8 -0
  41. package/dist/mainnet/models/imports.d.cts +7 -0
  42. package/dist/mainnet/models/input/inputJSON.d.cts +10 -0
  43. package/dist/mainnet/models/input/inputObject.d.cts +15 -0
  44. package/dist/mainnet/models/inputID.d.cts +4 -0
  45. package/dist/mainnet/models/keyPair.d.cts +4 -0
  46. package/dist/mainnet/models/output/outputJSON.d.cts +7 -0
  47. package/dist/mainnet/models/output/outputObject.d.cts +18 -0
  48. package/dist/mainnet/models/owner/ownerJSON.d.cts +4 -0
  49. package/dist/mainnet/models/owner/ownerObject.d.cts +5 -0
  50. package/dist/mainnet/models/plaintext/array.d.cts +3 -0
  51. package/dist/mainnet/models/plaintext/literal.d.cts +1 -0
  52. package/dist/mainnet/models/plaintext/plaintext.d.cts +5 -0
  53. package/dist/mainnet/models/plaintext/struct.d.cts +5 -0
  54. package/dist/mainnet/models/provingRequest.d.cts +6 -0
  55. package/dist/mainnet/models/provingRequest.d.ts +1 -1
  56. package/dist/mainnet/models/provingResponse.d.cts +51 -0
  57. package/dist/mainnet/models/ratification.d.cts +4 -0
  58. package/dist/mainnet/models/record-provider/encryptedRecord.d.cts +58 -0
  59. package/dist/mainnet/models/record-provider/ownedRecord.d.cts +60 -0
  60. package/dist/mainnet/models/record-provider/recordSearchParams.d.cts +19 -0
  61. package/dist/mainnet/models/record-scanner/encryptedRecordsResult.d.cts +7 -0
  62. package/dist/mainnet/models/record-scanner/encryptedRegistrationRequest.d.cts +8 -0
  63. package/dist/mainnet/models/record-scanner/error.d.cts +47 -0
  64. package/dist/mainnet/models/record-scanner/error.d.ts +1 -1
  65. package/dist/mainnet/models/record-scanner/ownedFilter.d.cts +22 -0
  66. package/dist/mainnet/models/record-scanner/ownedFilter.d.ts +3 -3
  67. package/dist/mainnet/models/record-scanner/ownedRecordsResponseFilter.d.cts +42 -0
  68. package/dist/mainnet/models/record-scanner/ownedRecordsResult.d.cts +13 -0
  69. package/dist/mainnet/models/record-scanner/recordsFilter.d.cts +35 -0
  70. package/dist/mainnet/models/record-scanner/recordsFilter.d.ts +2 -2
  71. package/dist/mainnet/models/record-scanner/recordsResponseFilter.d.cts +42 -0
  72. package/dist/mainnet/models/record-scanner/registrationRequest.d.cts +13 -0
  73. package/dist/mainnet/models/record-scanner/registrationResponse.d.cts +13 -0
  74. package/dist/mainnet/models/record-scanner/registrationResult.d.cts +9 -0
  75. package/dist/mainnet/models/record-scanner/revokeResult.d.cts +17 -0
  76. package/dist/mainnet/models/record-scanner/serialNumbersResult.d.cts +15 -0
  77. package/dist/mainnet/models/record-scanner/statusResponse.d.cts +13 -0
  78. package/dist/mainnet/models/record-scanner/statusResult.d.cts +13 -0
  79. package/dist/mainnet/models/record-scanner/tagsResult.d.cts +12 -0
  80. package/dist/mainnet/models/request.d.cts +14 -0
  81. package/dist/mainnet/models/request.d.ts +1 -1
  82. package/dist/mainnet/models/solution.d.cts +14 -0
  83. package/dist/mainnet/models/transaction/transactionJSON.d.cts +11 -0
  84. package/dist/mainnet/models/transaction/transactionObject.d.cts +14 -0
  85. package/dist/mainnet/models/transition/transitionJSON.d.cts +13 -0
  86. package/dist/mainnet/models/transition/transitionObject.d.cts +15 -0
  87. package/dist/mainnet/network-client.d.cts +850 -0
  88. package/dist/mainnet/network-client.d.ts +3 -0
  89. package/dist/mainnet/node-polyfill.cjs +238 -0
  90. package/dist/mainnet/node-polyfill.cjs.map +1 -0
  91. package/dist/mainnet/node-polyfill.d.cts +5 -0
  92. package/dist/mainnet/node-polyfill.js +1 -1
  93. package/dist/mainnet/node-polyfill.js.map +1 -1
  94. package/dist/mainnet/node.cjs +686 -0
  95. package/dist/mainnet/node.cjs.map +1 -0
  96. package/dist/mainnet/node.d.cts +3 -0
  97. package/dist/mainnet/node.js +2 -2
  98. package/dist/mainnet/polyfill/crypto.d.cts +1 -0
  99. package/dist/mainnet/polyfill/fetch.d.cts +1 -0
  100. package/dist/mainnet/polyfill/shared.d.cts +1 -0
  101. package/dist/mainnet/polyfill/worker.d.cts +1 -0
  102. package/dist/mainnet/polyfill/xmlhttprequest.d.cts +1 -0
  103. package/dist/mainnet/program-manager.d.cts +1600 -0
  104. package/dist/mainnet/program-manager.d.ts +13 -1
  105. package/dist/mainnet/record-provider.d.cts +274 -0
  106. package/dist/mainnet/record-scanner.d.cts +371 -0
  107. package/dist/mainnet/record-scanner.d.ts +9 -6
  108. package/dist/mainnet/security.d.cts +62 -0
  109. package/dist/mainnet/security.d.ts +5 -5
  110. package/dist/mainnet/utils.d.cts +23 -0
  111. package/dist/mainnet/utils.d.ts +10 -2
  112. package/dist/mainnet/wasm.d.cts +1 -0
  113. package/dist/testnet/account.d.cts +347 -0
  114. package/dist/testnet/browser.cjs +8530 -0
  115. package/dist/testnet/browser.cjs.map +1 -0
  116. package/dist/testnet/browser.d.cts +72 -0
  117. package/dist/testnet/browser.d.ts +3 -3
  118. package/dist/testnet/browser.js +78 -32
  119. package/dist/testnet/browser.js.map +1 -1
  120. package/dist/testnet/constants.d.cts +40 -0
  121. package/dist/testnet/external-signing.d.cts +76 -0
  122. package/dist/testnet/integrations/sealance/merkle-tree.d.cts +192 -0
  123. package/dist/testnet/keys/keystore/error.d.cts +24 -0
  124. package/dist/testnet/keys/keystore/file.d.cts +177 -0
  125. package/dist/testnet/keys/keystore/interface.d.cts +161 -0
  126. package/dist/testnet/keys/provider/interface.d.cts +170 -0
  127. package/dist/testnet/keys/provider/memory.d.cts +213 -0
  128. package/dist/testnet/keys/provider/memory.d.ts +6 -2
  129. package/dist/testnet/keys/provider/offline.d.cts +365 -0
  130. package/dist/testnet/keys/verifier/interface.d.cts +70 -0
  131. package/dist/testnet/keys/verifier/memory.d.cts +37 -0
  132. package/dist/testnet/keys/verifier/memory.d.ts +1 -1
  133. package/dist/testnet/models/authorization.d.cts +6 -0
  134. package/dist/testnet/models/authorization.d.ts +2 -2
  135. package/dist/testnet/models/blockJSON.d.cts +33 -0
  136. package/dist/testnet/models/confirmed_transaction.d.cts +9 -0
  137. package/dist/testnet/models/cryptoBoxPubkey.d.cts +4 -0
  138. package/dist/testnet/models/deployment/deploymentJSON.d.cts +6 -0
  139. package/dist/testnet/models/deployment/deploymentObject.d.cts +6 -0
  140. package/dist/testnet/models/encryptedProvingRequest.d.cts +4 -0
  141. package/dist/testnet/models/execution/executionJSON.d.cts +11 -0
  142. package/dist/testnet/models/execution/executionObject.d.cts +11 -0
  143. package/dist/testnet/models/external-signing.d.cts +123 -0
  144. package/dist/testnet/models/finalizeJSON.d.cts +6 -0
  145. package/dist/testnet/models/functionInput.d.cts +7 -0
  146. package/dist/testnet/models/functionObject.d.cts +8 -0
  147. package/dist/testnet/models/imports.d.cts +7 -0
  148. package/dist/testnet/models/input/inputJSON.d.cts +10 -0
  149. package/dist/testnet/models/input/inputObject.d.cts +15 -0
  150. package/dist/testnet/models/inputID.d.cts +4 -0
  151. package/dist/testnet/models/keyPair.d.cts +4 -0
  152. package/dist/testnet/models/output/outputJSON.d.cts +7 -0
  153. package/dist/testnet/models/output/outputObject.d.cts +18 -0
  154. package/dist/testnet/models/owner/ownerJSON.d.cts +4 -0
  155. package/dist/testnet/models/owner/ownerObject.d.cts +5 -0
  156. package/dist/testnet/models/plaintext/array.d.cts +3 -0
  157. package/dist/testnet/models/plaintext/literal.d.cts +1 -0
  158. package/dist/testnet/models/plaintext/plaintext.d.cts +5 -0
  159. package/dist/testnet/models/plaintext/struct.d.cts +5 -0
  160. package/dist/testnet/models/provingRequest.d.cts +6 -0
  161. package/dist/testnet/models/provingRequest.d.ts +1 -1
  162. package/dist/testnet/models/provingResponse.d.cts +51 -0
  163. package/dist/testnet/models/ratification.d.cts +4 -0
  164. package/dist/testnet/models/record-provider/encryptedRecord.d.cts +58 -0
  165. package/dist/testnet/models/record-provider/ownedRecord.d.cts +60 -0
  166. package/dist/testnet/models/record-provider/recordSearchParams.d.cts +19 -0
  167. package/dist/testnet/models/record-scanner/encryptedRecordsResult.d.cts +7 -0
  168. package/dist/testnet/models/record-scanner/encryptedRegistrationRequest.d.cts +8 -0
  169. package/dist/testnet/models/record-scanner/error.d.cts +47 -0
  170. package/dist/testnet/models/record-scanner/error.d.ts +1 -1
  171. package/dist/testnet/models/record-scanner/ownedFilter.d.cts +22 -0
  172. package/dist/testnet/models/record-scanner/ownedFilter.d.ts +3 -3
  173. package/dist/testnet/models/record-scanner/ownedRecordsResponseFilter.d.cts +42 -0
  174. package/dist/testnet/models/record-scanner/ownedRecordsResult.d.cts +13 -0
  175. package/dist/testnet/models/record-scanner/recordsFilter.d.cts +35 -0
  176. package/dist/testnet/models/record-scanner/recordsFilter.d.ts +2 -2
  177. package/dist/testnet/models/record-scanner/recordsResponseFilter.d.cts +42 -0
  178. package/dist/testnet/models/record-scanner/registrationRequest.d.cts +13 -0
  179. package/dist/testnet/models/record-scanner/registrationResponse.d.cts +13 -0
  180. package/dist/testnet/models/record-scanner/registrationResult.d.cts +9 -0
  181. package/dist/testnet/models/record-scanner/revokeResult.d.cts +17 -0
  182. package/dist/testnet/models/record-scanner/serialNumbersResult.d.cts +15 -0
  183. package/dist/testnet/models/record-scanner/statusResponse.d.cts +13 -0
  184. package/dist/testnet/models/record-scanner/statusResult.d.cts +13 -0
  185. package/dist/testnet/models/record-scanner/tagsResult.d.cts +12 -0
  186. package/dist/testnet/models/request.d.cts +14 -0
  187. package/dist/testnet/models/request.d.ts +1 -1
  188. package/dist/testnet/models/solution.d.cts +14 -0
  189. package/dist/testnet/models/transaction/transactionJSON.d.cts +11 -0
  190. package/dist/testnet/models/transaction/transactionObject.d.cts +14 -0
  191. package/dist/testnet/models/transition/transitionJSON.d.cts +13 -0
  192. package/dist/testnet/models/transition/transitionObject.d.cts +15 -0
  193. package/dist/testnet/network-client.d.cts +850 -0
  194. package/dist/testnet/network-client.d.ts +3 -0
  195. package/dist/testnet/node-polyfill.cjs +238 -0
  196. package/dist/testnet/node-polyfill.cjs.map +1 -0
  197. package/dist/testnet/node-polyfill.d.cts +5 -0
  198. package/dist/testnet/node-polyfill.js +1 -1
  199. package/dist/testnet/node-polyfill.js.map +1 -1
  200. package/dist/testnet/node.cjs +686 -0
  201. package/dist/testnet/node.cjs.map +1 -0
  202. package/dist/testnet/node.d.cts +3 -0
  203. package/dist/testnet/node.js +2 -2
  204. package/dist/testnet/polyfill/crypto.d.cts +1 -0
  205. package/dist/testnet/polyfill/fetch.d.cts +1 -0
  206. package/dist/testnet/polyfill/shared.d.cts +1 -0
  207. package/dist/testnet/polyfill/worker.d.cts +1 -0
  208. package/dist/testnet/polyfill/xmlhttprequest.d.cts +1 -0
  209. package/dist/testnet/program-manager.d.cts +1600 -0
  210. package/dist/testnet/program-manager.d.ts +13 -1
  211. package/dist/testnet/record-provider.d.cts +274 -0
  212. package/dist/testnet/record-scanner.d.cts +371 -0
  213. package/dist/testnet/record-scanner.d.ts +9 -6
  214. package/dist/testnet/security.d.cts +62 -0
  215. package/dist/testnet/security.d.ts +5 -5
  216. package/dist/testnet/utils.d.cts +23 -0
  217. package/dist/testnet/utils.d.ts +10 -2
  218. package/dist/testnet/wasm.d.cts +1 -0
  219. package/package.json +51 -9
@@ -0,0 +1,170 @@
1
+ import { FunctionKeyPair } from "../../models/keyPair.js";
2
+ import { KeyStore } from "../keystore/interface.js";
3
+ /**
4
+ * Interface for key search parameters. This allows for arbitrary search parameters to be passed to key provider
5
+ * implementations.
6
+ */
7
+ interface KeySearchParams {
8
+ [key: string]: any;
9
+ }
10
+ /**
11
+ * KeyProvider interface. Enables the retrieval of public proving and verifying keys for Aleo Programs.
12
+ */
13
+ interface FunctionKeyProvider {
14
+ /**
15
+ * Get bond_public function keys from the credits.aleo program
16
+ *
17
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_public function
18
+ */
19
+ bondPublicKeys(): Promise<FunctionKeyPair>;
20
+ /**
21
+ * Get bond_validator function keys from the credits.aleo program
22
+ *
23
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_validator function
24
+ */
25
+ bondValidatorKeys(): Promise<FunctionKeyPair>;
26
+ /**
27
+ * Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId
28
+ * exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.
29
+ *
30
+ * @param {string} keyId access key for the cache
31
+ * @param {FunctionKeyPair} keys keys to cache
32
+ */
33
+ cacheKeys(keyId: string, keys: FunctionKeyPair): void;
34
+ /**
35
+ * Get claim_unbond_public function keys from the credits.aleo program
36
+ *
37
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the claim_unbond_public function
38
+ */
39
+ claimUnbondPublicKeys(): Promise<FunctionKeyPair>;
40
+ /**
41
+ * Get arbitrary function keys from a provider
42
+ *
43
+ * @param {KeySearchParams | undefined} params - Optional search parameters for the key provider
44
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program
45
+ *
46
+ * @example
47
+ * // Create a search object which implements the KeySearchParams interface
48
+ * class IndexDbSearch implements KeySearchParams {
49
+ * db: string
50
+ * keyId: string
51
+ * constructor(params: {db: string, keyId: string}) {
52
+ * this.db = params.db;
53
+ * this.keyId = params.keyId;
54
+ * }
55
+ * }
56
+ *
57
+ * // Create a new object which implements the KeyProvider interface
58
+ * class IndexDbKeyProvider implements FunctionKeyProvider {
59
+ * async functionKeys(params: KeySearchParams): Promise<FunctionKeyPair> {
60
+ * return new Promise((resolve, reject) => {
61
+ * const request = indexedDB.open(params.db, 1);
62
+ *
63
+ * request.onupgradeneeded = function(e) {
64
+ * const db = e.target.result;
65
+ * if (!db.objectStoreNames.contains('keys')) {
66
+ * db.createObjectStore('keys', { keyPath: 'id' });
67
+ * }
68
+ * };
69
+ *
70
+ * request.onsuccess = function(e) {
71
+ * const db = e.target.result;
72
+ * const transaction = db.transaction(["keys"], "readonly");
73
+ * const store = transaction.objectStore("keys");
74
+ * const request = store.get(params.keyId);
75
+ * request.onsuccess = function(e) {
76
+ * if (request.result) {
77
+ * resolve(request.result as FunctionKeyPair);
78
+ * } else {
79
+ * reject(new Error("Key not found"));
80
+ * }
81
+ * };
82
+ * request.onerror = function(e) { reject(new Error("Error fetching key")); };
83
+ * };
84
+ *
85
+ * request.onerror = function(e) { reject(new Error("Error opening database")); };
86
+ * });
87
+ * }
88
+ *
89
+ * // implement the other methods...
90
+ * }
91
+ *
92
+ *
93
+ * const keyProvider = new AleoKeyProvider();
94
+ * const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
95
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
96
+ *
97
+ * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
98
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
99
+ * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
100
+ *
101
+ * // Keys can also be fetched manually
102
+ * const searchParams = new IndexDbSearch({db: "keys", keyId: "credits.aleo:transferPrivate"});
103
+ * const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.functionKeys(searchParams);
104
+ */
105
+ functionKeys(params?: KeySearchParams): Promise<FunctionKeyPair>;
106
+ /**
107
+ * Gets an object which implements the `KeyStore` interface for accessing proving and verifying
108
+ * keys directly from persistent storage.
109
+ *
110
+ * @returns {Promise<KeyStore | undefined>} The key store if available, or undefined.
111
+ */
112
+ keyStore(): Promise<KeyStore | undefined>;
113
+ /**
114
+ * Get fee_private function keys from the credits.aleo program
115
+ *
116
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the fee_private function
117
+ */
118
+ feePrivateKeys(): Promise<FunctionKeyPair>;
119
+ /**
120
+ * Get fee_public function keys from the credits.aleo program
121
+ *
122
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the fee_public function
123
+ */
124
+ feePublicKeys(): Promise<FunctionKeyPair>;
125
+ /**
126
+ * Get keys for the inclusion proof.
127
+ *
128
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion proof
129
+ */
130
+ inclusionKeys(): Promise<FunctionKeyPair>;
131
+ /**
132
+ * Get join function keys from the credits.aleo program
133
+ *
134
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
135
+ */
136
+ joinKeys(): Promise<FunctionKeyPair>;
137
+ /**
138
+ * Get split function keys from the credits.aleo program
139
+ *
140
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the split function
141
+ */
142
+ splitKeys(): Promise<FunctionKeyPair>;
143
+ /**
144
+ * Get keys for a variant of the transfer function from the credits.aleo program
145
+ *
146
+ * @param {string} visibility Visibility of the transfer function (private, public, privateToPublic, publicToPrivate)
147
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified transfer function
148
+ *
149
+ * @example
150
+ * // Create a new object which implements the KeyProvider interface
151
+ * const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
152
+ * const keyProvider = new AleoKeyProvider();
153
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
154
+ *
155
+ * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
156
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
157
+ * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
158
+ *
159
+ * // Keys can also be fetched manually
160
+ * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");
161
+ */
162
+ transferKeys(visibility: string): Promise<FunctionKeyPair>;
163
+ /**
164
+ * Get unbond_public function keys from the credits.aleo program
165
+ *
166
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the unbond_public function
167
+ */
168
+ unBondPublicKeys(): Promise<FunctionKeyPair>;
169
+ }
170
+ export { FunctionKeyProvider, KeySearchParams };
@@ -0,0 +1,213 @@
1
+ import { Key } from "../../constants.js";
2
+ import { CachedKeyPair, FunctionKeyPair } from "../../models/keyPair.js";
3
+ import { FunctionKeyProvider, KeySearchParams } from "./interface.js";
4
+ import { ProvingKey, VerifyingKey } from "../../wasm.js";
5
+ import { TransportFunction } from "../../utils.js";
6
+ import { KeyStore } from "../keystore/interface.js";
7
+ type AleoKeyProviderInitParams = {
8
+ proverUri?: string;
9
+ verifierUri?: string;
10
+ cacheKey?: string;
11
+ };
12
+ /**
13
+ * AleoKeyProviderParams search parameter for the AleoKeyProvider. It allows for the specification of a proverUri and
14
+ * verifierUri to fetch keys via HTTP from a remote resource as well as a unique cacheKey to store the keys in memory.
15
+ */
16
+ declare class AleoKeyProviderParams implements KeySearchParams {
17
+ name: string | undefined;
18
+ proverUri: string | undefined;
19
+ verifierUri: string | undefined;
20
+ cacheKey: string | undefined;
21
+ /**
22
+ * Create a new AleoKeyProviderParams object which implements the KeySearchParams interface. Users can optionally
23
+ * specify a url for the proverUri & verifierUri to fetch keys via HTTP from a remote resource as well as a unique
24
+ * cacheKey to store the keys in memory for future use. If no proverUri or verifierUri is specified, a cachekey must
25
+ * be provided.
26
+ *
27
+ * @param { AleoKeyProviderInitParams } params - Optional search parameters
28
+ */
29
+ constructor(params: {
30
+ proverUri?: string;
31
+ verifierUri?: string;
32
+ cacheKey?: string;
33
+ name?: string;
34
+ });
35
+ }
36
+ /**
37
+ * AleoKeyProvider class. Implements the FunctionKeyProvider interface. Enables the retrieval of Aleo program proving and
38
+ * verifying keys for the credits.aleo program over HTTP from official Aleo sources and storing and retrieving function
39
+ * keys from a local memory cache.
40
+ */
41
+ declare class AleoKeyProvider implements FunctionKeyProvider {
42
+ cache: Map<string, CachedKeyPair>;
43
+ cacheOption: boolean;
44
+ keyUris: string;
45
+ transport: TransportFunction;
46
+ fetchBytes(url?: string): Promise<Uint8Array>;
47
+ constructor(options?: {
48
+ transport?: TransportFunction;
49
+ });
50
+ keyStore(): Promise<KeyStore | undefined>;
51
+ /**
52
+ * Use local memory to store keys
53
+ *
54
+ * @param {boolean} useCache whether to store keys in local memory
55
+ */
56
+ useCache(useCache: boolean): void;
57
+ /**
58
+ * Clear the key cache
59
+ */
60
+ clearCache(): void;
61
+ /**
62
+ * Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId
63
+ * exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.
64
+ *
65
+ * @param {string} keyId access key for the cache
66
+ * @param {FunctionKeyPair} keys keys to cache
67
+ */
68
+ cacheKeys(keyId: string, keys: FunctionKeyPair): void;
69
+ /**
70
+ * Determine if a keyId exists in the cache
71
+ *
72
+ * @param {string} keyId keyId of a proving and verifying key pair
73
+ * @returns {boolean} true if the keyId exists in the cache, false otherwise
74
+ */
75
+ containsKeys(keyId: string): boolean;
76
+ /**
77
+ * Delete a set of keys from the cache
78
+ *
79
+ * @param {string} keyId keyId of a proving and verifying key pair to delete from memory
80
+ * @returns {boolean} true if the keyId exists in the cache and was deleted, false if the key did not exist
81
+ */
82
+ deleteKeys(keyId: string): boolean;
83
+ /**
84
+ * Get a set of keys from the cache
85
+ * @param keyId keyId of a proving and verifying key pair
86
+ *
87
+ * @returns {FunctionKeyPair} Proving and verifying keys for the specified program
88
+ */
89
+ getKeys(keyId: string): FunctionKeyPair;
90
+ /**
91
+ * Get arbitrary function keys from a provider
92
+ *
93
+ * @param {KeySearchParams} params parameters for the key search in form of: {proverUri: string, verifierUri: string, cacheKey: string}
94
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program
95
+ *
96
+ * @example
97
+ * // Create a new object which implements the KeyProvider interface
98
+ * const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
99
+ * const keyProvider = new AleoKeyProvider();
100
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
101
+ *
102
+ * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
103
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
104
+ * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
105
+ *
106
+ * // Keys can also be fetched manually using the key provider
107
+ * const keySearchParams = { "cacheKey": "myProgram:myFunction" };
108
+ * const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.functionKeys(keySearchParams);
109
+ */
110
+ functionKeys(params?: KeySearchParams): Promise<FunctionKeyPair>;
111
+ /**
112
+ * Returns the proving and verifying keys for a specified program from a specified url.
113
+ *
114
+ * @param {string} verifierUrl Url of the proving key
115
+ * @param {string} proverUrl Url the verifying key
116
+ * @param {string} cacheKey Key to store the keys in the cache
117
+ *
118
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program
119
+ *
120
+ * @example
121
+ * // Create a new AleoKeyProvider object
122
+ * const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
123
+ * const keyProvider = new AleoKeyProvider();
124
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
125
+ *
126
+ * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
127
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
128
+ * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
129
+ *
130
+ * // Keys can also be fetched manually
131
+ * const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.fetchKeys(
132
+ * CREDITS_PROGRAM_KEYS.transfer_private.prover,
133
+ * CREDITS_PROGRAM_KEYS.transfer_private.verifier,
134
+ * );
135
+ */
136
+ fetchRemoteKeys(proverUrl: string, verifierUrl: string, cacheKey?: string): Promise<FunctionKeyPair>;
137
+ /***
138
+ * Fetches the proving key from a remote source.
139
+ *
140
+ * @param proverUrl
141
+ * @param cacheKey
142
+ *
143
+ * @returns {Promise<ProvingKey>} Proving key for the specified program
144
+ */
145
+ fetchProvingKey(proverUrl: string, cacheKey?: string): Promise<ProvingKey>;
146
+ fetchCreditsKeys(key: Key): Promise<FunctionKeyPair>;
147
+ bondPublicKeys(): Promise<FunctionKeyPair>;
148
+ bondValidatorKeys(): Promise<FunctionKeyPair>;
149
+ claimUnbondPublicKeys(): Promise<FunctionKeyPair>;
150
+ /**
151
+ * Returns the proving and verifying keys for the transfer functions in the credits.aleo program
152
+ * @param {string} visibility Visibility of the transfer function
153
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the transfer functions
154
+ *
155
+ * @example
156
+ * // Create a new AleoKeyProvider
157
+ * const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
158
+ * const keyProvider = new AleoKeyProvider();
159
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
160
+ *
161
+ * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
162
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
163
+ * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
164
+ *
165
+ * // Keys can also be fetched manually
166
+ * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");
167
+ */
168
+ transferKeys(visibility: string): Promise<FunctionKeyPair>;
169
+ /**
170
+ * Returns the proving and verifying keys for the transfer_public function.
171
+ *
172
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the transfer_public function
173
+ */
174
+ transferPublicKeys(): Promise<FunctionKeyPair>;
175
+ /**
176
+ * Returns the proving and verifying keys for the inclusion proof.
177
+ *
178
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion proof.
179
+ */
180
+ inclusionKeys(): Promise<FunctionKeyPair>;
181
+ /**
182
+ * Returns the proving and verifying keys for the join function in the credits.aleo program
183
+ *
184
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
185
+ */
186
+ joinKeys(): Promise<FunctionKeyPair>;
187
+ /**
188
+ * Returns the proving and verifying keys for the split function in the credits.aleo program
189
+ *
190
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the split function
191
+ * */
192
+ splitKeys(): Promise<FunctionKeyPair>;
193
+ /**
194
+ * Returns the proving and verifying keys for the fee_private function in the credits.aleo program
195
+ *
196
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the fee function
197
+ */
198
+ feePrivateKeys(): Promise<FunctionKeyPair>;
199
+ /**
200
+ * Returns the proving and verifying keys for the fee_public function in the credits.aleo program
201
+ *
202
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the fee function
203
+ */
204
+ feePublicKeys(): Promise<FunctionKeyPair>;
205
+ /**
206
+ * Gets a verifying key. If the verifying key is for a credits.aleo function, get it from the wasm cache otherwise
207
+ *
208
+ * @returns {Promise<VerifyingKey>} Verifying key for the function
209
+ */
210
+ getVerifyingKey(verifierUri: string): Promise<VerifyingKey>;
211
+ unBondPublicKeys(): Promise<FunctionKeyPair>;
212
+ }
213
+ export { AleoKeyProvider, AleoKeyProviderInitParams, AleoKeyProviderParams };
@@ -1,7 +1,8 @@
1
1
  import { Key } from "../../constants.js";
2
2
  import { CachedKeyPair, FunctionKeyPair } from "../../models/keyPair.js";
3
- import { FunctionKeyProvider, KeySearchParams } from "./interface";
3
+ import { FunctionKeyProvider, KeySearchParams } from "./interface.js";
4
4
  import { ProvingKey, VerifyingKey } from "../../wasm.js";
5
+ import { TransportFunction } from "../../utils.js";
5
6
  import { KeyStore } from "../keystore/interface.js";
6
7
  type AleoKeyProviderInitParams = {
7
8
  proverUri?: string;
@@ -41,8 +42,11 @@ declare class AleoKeyProvider implements FunctionKeyProvider {
41
42
  cache: Map<string, CachedKeyPair>;
42
43
  cacheOption: boolean;
43
44
  keyUris: string;
45
+ transport: TransportFunction;
44
46
  fetchBytes(url?: string): Promise<Uint8Array>;
45
- constructor();
47
+ constructor(options?: {
48
+ transport?: TransportFunction;
49
+ });
46
50
  keyStore(): Promise<KeyStore | undefined>;
47
51
  /**
48
52
  * Use local memory to store keys