@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,365 @@
1
+ import { FunctionKeyProvider, KeySearchParams } from "./interface.js";
2
+ import { CachedKeyPair, FunctionKeyPair } from "../../models/keyPair.js";
3
+ import { ProvingKey, VerifyingKey } from "../../wasm.js";
4
+ import { KeyStore } from "../keystore/interface.js";
5
+ /**
6
+ * Search parameters for the offline key provider. This class implements the KeySearchParams interface and includes
7
+ * a convenience method for creating a new instance of this class for each function of the credits.aleo program.
8
+ *
9
+ * @example
10
+ * // If storing a key for a custom program function
11
+ * offlineSearchParams = new OfflineSearchParams("myprogram.aleo/myfunction");
12
+ *
13
+ * // If storing a key for a credits.aleo program function
14
+ * bondPublicKeyParams = OfflineSearchParams.bondPublicKeyParams();
15
+ */
16
+ declare class OfflineSearchParams implements KeySearchParams {
17
+ cacheKey: string | undefined;
18
+ verifyCreditsKeys: boolean | undefined;
19
+ /**
20
+ * Create a new OfflineSearchParams instance.
21
+ *
22
+ * @param {string} cacheKey - Key used to store the local function proving & verifying keys. This should be stored
23
+ * under the naming convention "programName/functionName" (i.e. "myprogram.aleo/myfunction")
24
+ * @param {boolean} verifyCreditsKeys - Whether to verify the keys against the credits.aleo program,
25
+ * defaults to false, but should be set to true if using keys from the credits.aleo program
26
+ */
27
+ constructor(cacheKey: string, verifyCreditsKeys?: boolean);
28
+ /**
29
+ * Create a new OfflineSearchParams instance for the bond_public function of the credits.aleo program.
30
+ */
31
+ static bondPublicKeyParams(): OfflineSearchParams;
32
+ /**
33
+ * Create a new OfflineSearchParams instance for the bond_validator function of the credits.aleo program.
34
+ */
35
+ static bondValidatorKeyParams(): OfflineSearchParams;
36
+ /**
37
+ * Create a new OfflineSearchParams instance for the claim_unbond_public function of the credits.aleo program.
38
+ */
39
+ static claimUnbondPublicKeyParams(): OfflineSearchParams;
40
+ /**
41
+ * Create a new OfflineSearchParams instance for the fee_private function of the credits.aleo program.
42
+ */
43
+ static feePrivateKeyParams(): OfflineSearchParams;
44
+ /**
45
+ * Create a new OfflineSearchParams instance for the fee_public function of the credits.aleo program.
46
+ */
47
+ static feePublicKeyParams(): OfflineSearchParams;
48
+ /**
49
+ * Create a new OfflineSearchParams instance for the inclusion prover function.
50
+ */
51
+ static inclusionKeyParams(): OfflineSearchParams;
52
+ /**
53
+ * Create a new OfflineSearchParams instance for the join function of the credits.aleo program.
54
+ */
55
+ static joinKeyParams(): OfflineSearchParams;
56
+ /**
57
+ * Create a new OfflineSearchParams instance for the set_validator_state function of the credits.aleo program.
58
+ */
59
+ static setValidatorStateKeyParams(): OfflineSearchParams;
60
+ /**
61
+ * Create a new OfflineSearchParams instance for the split function of the credits.aleo program.
62
+ */
63
+ static splitKeyParams(): OfflineSearchParams;
64
+ /**
65
+ * Create a new OfflineSearchParams instance for the transfer_private function of the credits.aleo program.
66
+ */
67
+ static transferPrivateKeyParams(): OfflineSearchParams;
68
+ /**
69
+ * Create a new OfflineSearchParams instance for the transfer_private_to_public function of the credits.aleo program.
70
+ */
71
+ static transferPrivateToPublicKeyParams(): OfflineSearchParams;
72
+ /**
73
+ * Create a new OfflineSearchParams instance for the transfer_public function of the credits.aleo program.
74
+ */
75
+ static transferPublicKeyParams(): OfflineSearchParams;
76
+ /**
77
+ * Create a new OfflineSearchParams instance for the transfer_public_as_signer function of the credits.aleo program.
78
+ */
79
+ static transferPublicAsSignerKeyParams(): OfflineSearchParams;
80
+ /**
81
+ * Create a new OfflineSearchParams instance for the transfer_public_to_private function of the credits.aleo program.
82
+ */
83
+ static transferPublicToPrivateKeyParams(): OfflineSearchParams;
84
+ /**
85
+ * Create a new OfflineSearchParams instance for the unbond_public function of the credits.aleo program.
86
+ */
87
+ static unbondPublicKeyParams(): OfflineSearchParams;
88
+ }
89
+ /**
90
+ * A key provider meant for building transactions offline on devices such as hardware wallets. This key provider is not
91
+ * able to contact the internet for key material and instead relies on the user to insert Aleo function proving &
92
+ * verifying keys from local storage prior to usage.
93
+ *
94
+ * @example
95
+ * // Create an offline program manager
96
+ * const programManager = new ProgramManager();
97
+ *
98
+ * // Create a temporary account for the execution of the program
99
+ * const account = new Account();
100
+ * programManager.setAccount(account);
101
+ *
102
+ * // Create the proving keys from the key bytes on the offline machine
103
+ * console.log("Creating proving keys from local key files");
104
+ * const program = "program hello_hello.aleo; function hello: input r0 as u32.public; input r1 as u32.private; add r0 r1 into r2; output r2 as u32.private;";
105
+ * const myFunctionProver = await getLocalKey("/path/to/my/function/hello_hello.prover");
106
+ * const myFunctionVerifier = await getLocalKey("/path/to/my/function/hello_hello.verifier");
107
+ * const feePublicProvingKeyBytes = await getLocalKey("/path/to/credits.aleo/feePublic.prover");
108
+ *
109
+ * myFunctionProvingKey = ProvingKey.fromBytes(myFunctionProver);
110
+ * myFunctionVerifyingKey = VerifyingKey.fromBytes(myFunctionVerifier);
111
+ * const feePublicProvingKey = ProvingKey.fromBytes(feePublicKeyBytes);
112
+ *
113
+ * // Create an offline key provider
114
+ * console.log("Creating offline key provider");
115
+ * const offlineKeyProvider = new OfflineKeyProvider();
116
+ *
117
+ * // Cache the keys
118
+ * // Cache the proving and verifying keys for the custom hello function
119
+ * OfflineKeyProvider.cacheKeys("hello_hello.aleo/hello", myFunctionProvingKey, myFunctionVerifyingKey);
120
+ *
121
+ * // Cache the proving key for the fee_public function (the verifying key is automatically cached)
122
+ * OfflineKeyProvider.insertFeePublicKey(feePublicProvingKey);
123
+ *
124
+ * // Create an offline query using the latest state root in order to create the inclusion proof
125
+ * const offlineQuery = new OfflineQuery("latestStateRoot");
126
+ *
127
+ * // Insert the key provider into the program manager
128
+ * programManager.setKeyProvider(offlineKeyProvider);
129
+ *
130
+ * // Create the offline search params
131
+ * const offlineSearchParams = new OfflineSearchParams("hello_hello.aleo/hello");
132
+ *
133
+ * // Create the offline transaction
134
+ * const offlineExecuteTx = <Transaction>await this.buildExecutionTransaction("hello_hello.aleo", "hello", 1, false, ["5u32", "5u32"], undefined, offlineSearchParams, undefined, undefined, undefined, undefined, offlineQuery, program);
135
+ *
136
+ * // Broadcast the transaction later on a machine with internet access
137
+ * const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
138
+ * const txId = await networkClient.broadcastTransaction(offlineExecuteTx);
139
+ */
140
+ declare class OfflineKeyProvider implements FunctionKeyProvider {
141
+ cache: Map<string, CachedKeyPair>;
142
+ constructor();
143
+ keyStore(): Promise<KeyStore | undefined>;
144
+ /**
145
+ * Get bond_public function keys from the credits.aleo program. The keys must be cached prior to calling this
146
+ * method for it to work.
147
+ *
148
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_public function
149
+ */
150
+ bondPublicKeys(): Promise<FunctionKeyPair>;
151
+ /**
152
+ * Get bond_validator function keys from the credits.aleo program. The keys must be cached prior to calling this
153
+ * method for it to work.
154
+ *
155
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_public function
156
+ */
157
+ bondValidatorKeys(): Promise<FunctionKeyPair>;
158
+ /**
159
+ * Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId
160
+ * exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.
161
+ *
162
+ * @param {string} keyId access key for the cache
163
+ * @param {FunctionKeyPair} keys keys to cache
164
+ */
165
+ cacheKeys(keyId: string, keys: FunctionKeyPair): void;
166
+ /**
167
+ * Get unbond_public function keys from the credits.aleo program. The keys must be cached prior to calling this
168
+ * method for it to work.
169
+ *
170
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the unbond_public function
171
+ */
172
+ claimUnbondPublicKeys(): Promise<FunctionKeyPair>;
173
+ /**
174
+ * Get arbitrary function key from the offline key provider cache.
175
+ *
176
+ * @param {KeySearchParams | undefined} params - Optional search parameters for the key provider
177
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program
178
+ *
179
+ * @example
180
+ * /// First cache the keys from local offline resources
181
+ * const offlineKeyProvider = new OfflineKeyProvider();
182
+ * const myFunctionVerifyingKey = VerifyingKey.fromString("verifier...");
183
+ * const myFunctionProvingKeyBytes = await readBinaryFile('./resources/myfunction.prover');
184
+ * const myFunctionProvingKey = ProvingKey.fromBytes(myFunctionProvingKeyBytes);
185
+ *
186
+ * /// Cache the keys for future use with a memorable locator
187
+ * offlineKeyProvider.cacheKeys("myprogram.aleo/myfunction", [myFunctionProvingKey, myFunctionVerifyingKey]);
188
+ *
189
+ * /// When they're needed, retrieve the keys from the cache
190
+ *
191
+ * /// First create a search parameter object with the same locator used to cache the keys
192
+ * const keyParams = new OfflineSearchParams("myprogram.aleo/myfunction");
193
+ *
194
+ * /// Then retrieve the keys
195
+ * const [myFunctionProver, myFunctionVerifier] = await offlineKeyProvider.functionKeys(keyParams);
196
+ */
197
+ functionKeys(params?: KeySearchParams): Promise<FunctionKeyPair>;
198
+ /**
199
+ * Determines if the keys for a given credits function match the expected keys.
200
+ *
201
+ * @returns {boolean} Whether the keys match the expected keys
202
+ */
203
+ verifyCreditsKeys(locator: string, provingKey: ProvingKey, verifyingKey: VerifyingKey): boolean;
204
+ /**
205
+ * Get fee_private function keys from the credits.aleo program. The keys must be cached prior to calling this
206
+ * method for it to work.
207
+ *
208
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
209
+ */
210
+ feePrivateKeys(): Promise<FunctionKeyPair>;
211
+ /**
212
+ * Get fee_public function keys from the credits.aleo program. The keys must be cached prior to calling this
213
+ * method for it to work.
214
+ *
215
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
216
+ */
217
+ feePublicKeys(): Promise<FunctionKeyPair>;
218
+ /**
219
+ * Get the inclusion prover keys from. The keys must be cached prior to calling this method for it to work.
220
+ *
221
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion prover
222
+ */
223
+ inclusionKeys(): Promise<FunctionKeyPair>;
224
+ /**
225
+ * Get join function keys from the credits.aleo program. The keys must be cached prior to calling this
226
+ * method for it to work.
227
+ *
228
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
229
+ */
230
+ joinKeys(): Promise<FunctionKeyPair>;
231
+ /**
232
+ * Get split function keys from the credits.aleo program. The keys must be cached prior to calling this
233
+ * method for it to work.
234
+ *
235
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
236
+ */
237
+ splitKeys(): Promise<FunctionKeyPair>;
238
+ /**
239
+ * Get keys for a variant of the transfer function from the credits.aleo program.
240
+ *
241
+ *
242
+ * @param {string} visibility Visibility of the transfer function (private, public, privateToPublic, publicToPrivate)
243
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified transfer function
244
+ *
245
+ * @example
246
+ * // Create a new OfflineKeyProvider
247
+ * const offlineKeyProvider = new OfflineKeyProvider();
248
+ *
249
+ * // Cache the keys for future use with the official locator
250
+ * const transferPublicProvingKeyBytes = await readBinaryFile('./resources/transfer_public.prover.a74565e');
251
+ * const transferPublicProvingKey = ProvingKey.fromBytes(transferPublicProvingKeyBytes);
252
+ *
253
+ * // Cache the transfer_public keys for future use with the OfflinKeyProvider's convenience method for
254
+ * // transfer_public (the verifying key will be cached automatically)
255
+ * offlineKeyProvider.insertTransferPublicKeys(transferPublicProvingKey);
256
+ *
257
+ * /// When they're needed, retrieve the keys from the cache
258
+ * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");
259
+ */
260
+ transferKeys(visibility: string): Promise<FunctionKeyPair>;
261
+ /**
262
+ * Get unbond_public function keys from the credits.aleo program
263
+ *
264
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
265
+ */
266
+ unBondPublicKeys(): Promise<FunctionKeyPair>;
267
+ /**
268
+ * Insert the proving and verifying keys for the bond_public function into the cache. Only the proving key needs
269
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
270
+ * that the keys match the expected checksum for bond_public before inserting them into the cache.
271
+ *
272
+ * @param provingKey
273
+ */
274
+ insertBondPublicKeys(provingKey: ProvingKey): void;
275
+ /**
276
+ * Insert the proving and verifying keys for the claim_unbond_public function into the cache. Only the proving key needs
277
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
278
+ * that the keys match the expected checksum for claim_unbond_public before inserting them into the cache.
279
+ *
280
+ * @param provingKey
281
+ */
282
+ insertClaimUnbondPublicKeys(provingKey: ProvingKey): void;
283
+ /**
284
+ * Insert the proving and verifying keys for the fee_private function into the cache. Only the proving key needs
285
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
286
+ * that the keys match the expected checksum for fee_private before inserting them into the cache.
287
+ *
288
+ * @param provingKey
289
+ */
290
+ insertFeePrivateKeys(provingKey: ProvingKey): void;
291
+ /**
292
+ * Insert the proving and verifying keys for the fee_public function into the cache. Only the proving key needs
293
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
294
+ * that the keys match the expected checksum for fee_public before inserting them into the cache.
295
+ *
296
+ * @param provingKey
297
+ */
298
+ insertFeePublicKeys(provingKey: ProvingKey): void;
299
+ /**
300
+ * Insert the proving and verifying keys for the inclusion prover into the cache. Only the proving key needs
301
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
302
+ * that the keys match the expected checksum for the inclusion prover.
303
+ *
304
+ * @param provingKey
305
+ */
306
+ insertInclusionKeys(provingKey: ProvingKey): void;
307
+ /**
308
+ * Insert the proving and verifying keys for the join function into the cache. Only the proving key needs
309
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
310
+ * that the keys match the expected checksum for join before inserting them into the cache.
311
+ *
312
+ * @param provingKey
313
+ */
314
+ insertJoinKeys(provingKey: ProvingKey): void;
315
+ /**
316
+ * Insert the proving and verifying keys for the set_validator_state function into the cache. Only the proving key needs
317
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
318
+ * that the keys match the expected checksum for set_validator_state before inserting them into the cache.
319
+ *
320
+ * @param provingKey
321
+ */
322
+ insertSetValidatorStateKeys(provingKey: ProvingKey): void;
323
+ /**
324
+ * Insert the proving and verifying keys for the split function into the cache. Only the proving key needs
325
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
326
+ * that the keys match the expected checksum for split before inserting them into the cache.
327
+ *
328
+ * @param provingKey
329
+ */
330
+ insertSplitKeys(provingKey: ProvingKey): void;
331
+ /**
332
+ * Insert the proving and verifying keys for the transfer_private function into the cache. Only the proving key needs
333
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
334
+ * that the keys match the expected checksum for transfer_private before inserting them into the cache.
335
+ *
336
+ * @param provingKey
337
+ */
338
+ insertTransferPrivateKeys(provingKey: ProvingKey): void;
339
+ /**
340
+ * Insert the proving and verifying keys for the transfer_private_to_public function into the cache. Only the proving key needs
341
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
342
+ * that the keys match the expected checksum for transfer_private_to_public before inserting them into the cache.
343
+ *
344
+ * @param provingKey
345
+ */
346
+ insertTransferPrivateToPublicKeys(provingKey: ProvingKey): void;
347
+ /**
348
+ * Insert the proving and verifying keys for the transfer_public function into the cache. Only the proving key needs
349
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
350
+ * that the keys match the expected checksum for transfer_public before inserting them into the cache.
351
+ *
352
+ * @param provingKey
353
+ */
354
+ insertTransferPublicKeys(provingKey: ProvingKey): void;
355
+ /**
356
+ * Insert the proving and verifying keys for the transfer_public_to_private function into the cache. Only the proving key needs
357
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
358
+ * that the keys match the expected checksum for transfer_public_to_private before inserting them into the cache.
359
+ *
360
+ * @param provingKey
361
+ */
362
+ insertTransferPublicToPrivateKeys(provingKey: ProvingKey): void;
363
+ insertUnbondPublicKeys(provingKey: ProvingKey): void;
364
+ }
365
+ export { OfflineKeyProvider, OfflineSearchParams };
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Fingerprint for a proving and verifying key that includes the checksum of the bytes and size in number of bytes.
3
+ *
4
+ * @property {string} checksum - SHA-256 checksum of the key bytes.
5
+ * @property {number} size - Size of the key in number of bytes.
6
+ */
7
+ export interface KeyFingerprint {
8
+ checksum: string;
9
+ size: number;
10
+ }
11
+ /**
12
+ * Options for verifying the integrity of proving and verifying keys. An identifier to allow the interface to find key metadata and/or the desired metadata to verify must be passed in.
13
+ *
14
+ * @property {Uint8Array} keyBytes - The raw bytes of the cryptographic key.
15
+ * @property {string} [locator] - Optional identifier or path indicating where the key or KeyFingerprint might be stored.
16
+ * @property {KeyFingerprint} [fingerprint] - Optional metadata containing the key's expected checksum and size for verification purposes.
17
+ */
18
+ export interface KeyMetadata {
19
+ keyBytes: Uint8Array;
20
+ locator?: string;
21
+ fingerprint?: KeyFingerprint;
22
+ }
23
+ /**
24
+ * Error thrown when there is a mismatch between expected and actual key metadata.
25
+ * This can occur during verification of either the checksum or size of a key.
26
+ *
27
+ * @extends Error
28
+ */
29
+ export declare class KeyVerificationError extends Error {
30
+ readonly locator: string;
31
+ readonly field: "checksum" | "size";
32
+ readonly expected: string;
33
+ readonly actual: string;
34
+ /**
35
+ * Creates a new KeyVerificationError instance (error.name is "ChecksumMismatchError").
36
+ *
37
+ * @param {string} locator - The key locator where the mismatch occurred.
38
+ * @param {"checksum" | "size"} field - The field that failed verification (either "checksum" or "size").
39
+ * @param {string} expected - The expected value of the field.
40
+ * @param {string} actual - The actual value encountered.
41
+ */
42
+ constructor(locator: string, field: "checksum" | "size", expected: string, actual: string);
43
+ }
44
+ /**
45
+ * Computes the SHA-256 checksum of a given set of bytes.
46
+ *
47
+ * @param {Uint8Array} bytes - The bytes to compute the checksum of.
48
+ */
49
+ export declare function sha256Hex(bytes: Uint8Array): Promise<string>;
50
+ /**
51
+ * Verifies key-pair metadata (checksums and sizes) against raw bytes in order to ensure the correct keypair is used.
52
+ * Implementations throw {@link KeyVerificationError} when verification fails.
53
+ */
54
+ export interface KeyVerifier {
55
+ /**
56
+ * Computes and optionally stores key metadata. If keyFingerprint is provided, verifies against it.
57
+ * @param {KeyMetadata} keyMetadata - Object containing key bytes and optional verification data.
58
+ * @throws {KeyVerificationError} When provided keyFingerprint doesn't match computed values.
59
+ * @returns {Promise<KeyFingerprint>} Computed key metadata.
60
+ */
61
+ computeKeyMetadata(keyMetadata: KeyMetadata): Promise<KeyFingerprint>;
62
+ /**
63
+ * Verifies prover bytes against key metadata (size + checksum).
64
+ *
65
+ * @param {KeyMetadata} keyMetadata - Object containing the key bytes, an optional locator and optional metadata for verification.
66
+ * @throws {KeyVerificationError} when size or checksum does not match.
67
+ * @returns {Promise<void>} Promise that resolves when verification succeeds.
68
+ */
69
+ verifyKeyBytes(keyMetadata: KeyMetadata): Promise<void>;
70
+ }
@@ -0,0 +1,37 @@
1
+ import { KeyVerifier, KeyFingerprint, KeyMetadata } from "./interface.js";
2
+ /**
3
+ * In-memory implementation of KeyVerifier that stores and verifies key fingerprints.
4
+ * Provides functionality to compute and verify cryptographic checksums of keys, storing them
5
+ * in memory for subsequent verification. This implementation is primarily used for testing
6
+ * and development purposes where persistence is not required.
7
+ *
8
+ * Key features:
9
+ * - Computes SHA-256 checksums and sizes for key bytes.
10
+ * - Stores key fingerprints in memory using string locators.
11
+ * - Verifies key bytes against stored or provided fingerprints.
12
+ *
13
+ * @implements {KeyVerifier}
14
+ */
15
+ export declare class MemKeyVerifier implements KeyVerifier {
16
+ private keyStore;
17
+ /**
18
+ * Computes and optionally stores key metadata. If a keyFingerprint is provided, this function will verify the computed checksum against it before storing it.
19
+ *
20
+ * @param {KeyMetadata} keyMetadata - Object containing key bytes and optional verification data.
21
+ * @throws {KeyVerificationError} When provided keyFingerprint doesn't match computed values.
22
+ * @returns {Promise<KeyFingerprint>} Computed key metadata.
23
+ */
24
+ computeKeyMetadata(keyMetadata: KeyMetadata): Promise<KeyFingerprint>;
25
+ /**
26
+ * Verifies key bytes against stored or provided metadata. Follows a priority verification scheme:
27
+ * 1. If KeyFingerprint is provided in the metadata, this method verifies against that first.
28
+ * 2. If a locator is provided, attempts to verify against stored fingerprint.
29
+ * 3. If neither is available, throws an error.
30
+ *
31
+ * @param {KeyMetadata} keyMetadata - Object containing the key bytes and optional verification metadata.
32
+ * @throws {Error} When neither fingerprint nor valid locator is provided for verification.
33
+ * @throws {KeyVerificationError} When size or checksum verification fails.
34
+ * @returns {Promise<void>} Promise that resolves when verification succeeds.
35
+ */
36
+ verifyKeyBytes(keyMetadata: KeyMetadata): Promise<void>;
37
+ }
@@ -1,4 +1,4 @@
1
- import { KeyVerifier, KeyFingerprint, KeyMetadata } from "./interface";
1
+ import { KeyVerifier, KeyFingerprint, KeyMetadata } from "./interface.js";
2
2
  /**
3
3
  * In-memory implementation of KeyVerifier that stores and verifies key fingerprints.
4
4
  * Provides functionality to compute and verify cryptographic checksums of keys, storing them
@@ -0,0 +1,6 @@
1
+ import { RequestJSON } from "./request.js";
2
+ import { TransitionJSON } from "./transition/transitionJSON.js";
3
+ export interface AuthorizationJSON {
4
+ requests: RequestJSON[];
5
+ transitions: TransitionJSON[];
6
+ }
@@ -1,5 +1,5 @@
1
- import { RequestJSON } from "./request";
2
- import { TransitionJSON } from "./transition/transitionJSON";
1
+ import { RequestJSON } from "./request.js";
2
+ import { TransitionJSON } from "./transition/transitionJSON.js";
3
3
  export interface AuthorizationJSON {
4
4
  requests: RequestJSON[];
5
5
  transitions: TransitionJSON[];
@@ -0,0 +1,33 @@
1
+ import { ConfirmedTransactionJSON } from "./confirmed_transaction.js";
2
+ import { RatificationJSON } from "./ratification.js";
3
+ import { SolutionsJSON } from "./solution.js";
4
+ export type BlockJSON = {
5
+ block_hash: string;
6
+ previous_hash: string;
7
+ header: Header;
8
+ transactions?: (ConfirmedTransactionJSON)[];
9
+ signature: string;
10
+ ratifications: (RatificationJSON)[];
11
+ solutions: SolutionsJSON;
12
+ aborted_solution_ids: string[];
13
+ aborted_transaction_ids: string[];
14
+ };
15
+ export type Header = {
16
+ previous_state_root: string;
17
+ transactions_root: string;
18
+ finalize_root: string;
19
+ ratifications_root: string;
20
+ solutions_root: string;
21
+ subdag_root: string;
22
+ metadata: Metadata;
23
+ };
24
+ export type Metadata = {
25
+ network: bigint;
26
+ round: bigint;
27
+ height: bigint;
28
+ coinbase_target: bigint;
29
+ proof_target: bigint;
30
+ timestamp: bigint;
31
+ cumulative_weight: bigint;
32
+ cumulative_proof_target: bigint;
33
+ };
@@ -0,0 +1,9 @@
1
+ import { TransactionJSON } from "./transaction/transactionJSON.js";
2
+ import { FinalizeJSON } from "./finalizeJSON.js";
3
+ export interface ConfirmedTransactionJSON {
4
+ status: string;
5
+ type: string;
6
+ index: bigint;
7
+ transaction: TransactionJSON;
8
+ finalize: FinalizeJSON[];
9
+ }
@@ -0,0 +1,4 @@
1
+ export interface CryptoBoxPubKey {
2
+ key_id: string;
3
+ public_key: string;
4
+ }
@@ -0,0 +1,6 @@
1
+ export type VerifyingKeys = [string, [string, string]];
2
+ export interface DeploymentJSON {
3
+ "edition": number;
4
+ "program": string;
5
+ "verifying_keys": VerifyingKeys;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { FunctionObject } from "../functionObject.js";
2
+ export interface DeploymentObject {
3
+ "edition": number;
4
+ "program": string;
5
+ "functions": FunctionObject[];
6
+ }
@@ -0,0 +1,4 @@
1
+ export interface EncryptedProvingRequest {
2
+ key_id: string;
3
+ ciphertext: string;
4
+ }
@@ -0,0 +1,11 @@
1
+ import { TransitionJSON } from "../transition/transitionJSON.js";
2
+ export interface ExecutionJSON {
3
+ transitions: TransitionJSON[];
4
+ proof: string;
5
+ global_state_root: string;
6
+ }
7
+ export interface FeeExecutionJSON {
8
+ transition: TransitionJSON;
9
+ proof: string;
10
+ global_state_root: string;
11
+ }
@@ -0,0 +1,11 @@
1
+ import { TransitionObject } from "../transition/transitionObject.js";
2
+ export interface ExecutionObject {
3
+ transitions: TransitionObject[];
4
+ proof: string;
5
+ global_state_root: string;
6
+ }
7
+ export interface FeeExecutionObject {
8
+ transition: TransitionObject;
9
+ proof: string;
10
+ global_state_root: string;
11
+ }