@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,40 @@
1
+ import { VerifyingKey } from "./wasm.js";
2
+ export declare const KEY_STORE: string;
3
+ export interface Key {
4
+ name: string;
5
+ locator: string;
6
+ prover: string;
7
+ verifier: string;
8
+ verifyingKey: () => VerifyingKey;
9
+ }
10
+ export declare const CREDITS_PROGRAM_KEYS: {
11
+ bond_public: Key;
12
+ bond_validator: Key;
13
+ claim_unbond_public: Key;
14
+ fee_private: Key;
15
+ fee_public: Key;
16
+ inclusion: Key;
17
+ join: Key;
18
+ set_validator_state: Key;
19
+ split: Key;
20
+ transfer_private: Key;
21
+ transfer_private_to_public: Key;
22
+ transfer_public: Key;
23
+ transfer_public_as_signer: Key;
24
+ transfer_public_to_private: Key;
25
+ unbond_public: Key;
26
+ getKey: (key: string) => Key;
27
+ };
28
+ export declare const PRIVATE_TRANSFER_TYPES: Set<string>;
29
+ export declare const VALID_TRANSFER_TYPES: Set<string>;
30
+ export declare const PRIVATE_TRANSFER: Set<string>;
31
+ export declare const PRIVATE_TO_PUBLIC_TRANSFER: Set<string>;
32
+ export declare const PUBLIC_TRANSFER: Set<string>;
33
+ export declare const PUBLIC_TRANSFER_AS_SIGNER: Set<string>;
34
+ export declare const PUBLIC_TO_PRIVATE_TRANSFER: Set<string>;
35
+ export declare const RECORD_DOMAIN = "RecordScannerV0";
36
+ /**
37
+ * Zero address on Aleo blockchain that corresponds to field element 0. Used as padding in Merkle trees and as a sentinel value.
38
+ */
39
+ export declare const ZERO_ADDRESS = "aleo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3ljyzc";
40
+ export declare const FIVE_MINUTES: number;
@@ -0,0 +1,76 @@
1
+ import { ExecutionRequest } from "./wasm.js";
2
+ import type { ExternalSigningInput, ExternalSigningOptions, ExecutionRequestParams, InputStrategy } from "./models/external-signing.js";
3
+ export * from "./models/external-signing.js";
4
+ /**
5
+ * Build an ExecutionRequest from externally signed data.
6
+ *
7
+ * The `strategy` parameter determines how record input IDs are resolved:
8
+ * - `{ recordViewKeys?, gammas? }` — explicit record view keys and gammas
9
+ * - `{ viewKey, gammas? }` — derive record view keys from a ViewKey
10
+ * - `{ inputIds }` — pre-computed input IDs (Field or [Field, Group, Field, Field, Field] tuples)
11
+ *
12
+ * @throws {Error} If `strategy` is not a valid `InputStrategy` variant.
13
+ *
14
+ * @example
15
+ * // With explicit record view keys
16
+ * buildExecutionRequestFromExternallySignedData(
17
+ * { programId, functionName, inputs, inputTypes, signature, tvk, signer, skTag },
18
+ * { recordViewKeys: [...], gammas: [...] },
19
+ * );
20
+ *
21
+ * // With a view key
22
+ * buildExecutionRequestFromExternallySignedData(
23
+ * { programId, functionName, inputs, inputTypes, signature, tvk, signer, skTag },
24
+ * { viewKey: "AViewKey1..." },
25
+ * );
26
+ *
27
+ * // With pre-computed input IDs
28
+ * buildExecutionRequestFromExternallySignedData(
29
+ * { programId, functionName, inputs, inputTypes, signature, tvk, signer, skTag },
30
+ * { inputIds: [...] },
31
+ * );
32
+ */
33
+ export declare function buildExecutionRequestFromExternallySignedData(params: ExecutionRequestParams, strategy?: InputStrategy): ExecutionRequest;
34
+ /**
35
+ * Computes the function ID and serialized input data for a program function call.
36
+ * Used by external signing wallets and other applications that need publicly computable inputs
37
+ * for building a signed execution request (e.g. before calling {@link ExecutionRequest.sign}).
38
+ *
39
+ * The optional `outputFormat` field controls how field elements are returned:
40
+ * - `"string"` (default) — human-readable strings like `"123field"`
41
+ * - `"bytes"` — raw little-endian `Uint8Array`s
42
+ *
43
+ * @param {ExternalSigningOptions} options - Program name, function name, inputs, input_types, root flag, an optional program checksum, an optional view key, and an optional output format.
44
+ * @throws Throws if parsing the program ID, function name, or inputs fails or if the inputs do not match the type signatures passed in the input_types parameter.
45
+ *
46
+ * @example
47
+ * // String output (default)
48
+ * const result = await computeExternalSigningInputs({
49
+ * programName: "credits.aleo",
50
+ * functionName: "transfer_public",
51
+ * inputs: ["aleo1...", "100u64"],
52
+ * inputTypes: ["address.public", "u64.public"],
53
+ * isRoot: true,
54
+ * });
55
+ * result.functionId; // string
56
+ *
57
+ * @example
58
+ * // Bytes output
59
+ * const result = await computeExternalSigningInputs({
60
+ * programName: "credits.aleo",
61
+ * functionName: "transfer_public",
62
+ * inputs: ["aleo1...", "100u64"],
63
+ * inputTypes: ["address.public", "u64.public"],
64
+ * isRoot: true,
65
+ * outputFormat: "bytes",
66
+ * });
67
+ * result.functionId; // Uint8Array
68
+ *
69
+ * @returns {ExternalSigningInput} A JSON object for inputs to external signing algorithms.
70
+ */
71
+ export declare function computeExternalSigningInputs(options: ExternalSigningOptions & {
72
+ outputFormat: "bytes";
73
+ }): Promise<ExternalSigningInput<"bytes">>;
74
+ export declare function computeExternalSigningInputs(options: ExternalSigningOptions & {
75
+ outputFormat?: "string";
76
+ }): Promise<ExternalSigningInput<"string">>;
@@ -0,0 +1,192 @@
1
+ import { Field } from "../../wasm.js";
2
+ /**
3
+ * Client library that encapsulates methods for constructing Merkle exclusion proofs for compliant stablecoin programs following the Sealance architecture.
4
+ *
5
+
6
+ * @example
7
+ * Construct a Merkle exclusion proof.
8
+ * ```typescript
9
+ * const sealance = new SealanceMerkleTree();
10
+ * const leaves = [
11
+ * "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px",
12
+ * "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t",
13
+ * "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t",
14
+ * ];
15
+ * const result = sealance.generateLeaves(leaves);
16
+ * const tree = sealance.buildTree(result);
17
+ * const [leftIdx, rightIdx] = sealance.getLeafIndices(tree, "aleo1kypwp5m7qtk9mwazgcpg0tq8aal23mnrvwfvug65qgcg9xvsrqgspyjm6n");
18
+ * const proof_left = sealance.getSiblingPath(tree, leftIdx, 15);
19
+ * const proof_right = sealance.getSiblingPath(tree, rightIdx, 15);
20
+ * const exclusion_proof = [proof_left, proof_right];
21
+ * const formatted_proof = sealance.formatMerkleProof(exclusion_proof);
22
+ * ```
23
+ */
24
+ declare class SealanceMerkleTree {
25
+ private static hasher;
26
+ /**
27
+ * Converts an Aleo blockchain address to a field element.
28
+ *
29
+ * This function decodes a bech32m-encoded Aleo address and converts it to a field element
30
+ * represented as a BigInt. The address format follows the Aleo protocol specification,
31
+ * starting with the prefix "aleo1" followed by encoded data.
32
+ *
33
+ * @param address - The Aleo blockchain address (e.g., "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px")
34
+ * @returns A BigInt representing the field element.
35
+ * @throws Error if the address is invalid or cannot be decoded.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const sealance = new SealanceMerkleTree();
40
+ * const address = "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px";
41
+ * const fieldValue = sealance.convertAddressToField(address);
42
+ * console.log(fieldValue); // 123456789...n
43
+ * ```
44
+ */
45
+ convertAddressToField(address: string): bigint;
46
+ /**
47
+ * Hashes two elements using Poseidon4 hash function
48
+ * @param prefix - Prefix for the hash (e.g., "0field" for nodes, "1field" for leaves)
49
+ * @param el1 - First element to hash
50
+ * @param el2 - Second element to hash
51
+ * @returns The hash result as a Field
52
+ * @throws {Error} If inputs are empty or invalid
53
+ */
54
+ hashTwoElements(prefix: string, el1: string, el2: string): Field;
55
+ /**
56
+ * Builds a Merkle tree from given leaves. The tree is built bottom-up, hashing pairs of elements at each level.
57
+ *
58
+ * @param leaves - Array of leaf elements (must have even number of elements).
59
+ * @returns Array representing the complete Merkle tree as BigInts.
60
+ * @throws {Error} If leaves array is empty or has odd number of elements.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const sealance = new SealanceMerkleTree();
65
+ * const leaves = ["0field", "1field", "2field", "3field"];
66
+ * const tree = sealance.buildTree(leaves);
67
+ * const root = tree[tree.length - 1]; // Get the Merkle root
68
+ * ```
69
+ */
70
+ buildTree(leaves: string[]): bigint[];
71
+ /**
72
+ * Converts an array of decimal string representations of U256 numbers to an array of BigInts.
73
+ *
74
+ * @param tree - Array of decimal string representations of U256 numbers.
75
+ * @returns Array of BigInts.
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * const treeStrings = ["0","4328470178059738374782465505490977516512210899136548187530607227309847251692","1741259420362056497457198439964202806733137875365061915996980524089960046336"];
80
+ * const sealance = new SealanceMerkleTree();
81
+ * const treeBigInts = sealance.convertTreeToBigInt(treeStrings);
82
+ * console.log(treeBigInts); // [
83
+ * 0,
84
+ * 4328470178059738374782465505490977516512210899136548187530607227309847251692,
85
+ * 1741259420362056497457198439964202806733137875365061915996980524089960046336
86
+ * ]
87
+ * ```
88
+ */
89
+ convertTreeToBigInt(tree: string[]): bigint[];
90
+ /**
91
+ * Converts Aleo addresses to field elements, sorts them, pads with zero fields, and returns an array. This prepares addresses for Merkle tree construction.
92
+ *
93
+ * @param addresses - Array of Aleo addresses.
94
+ * @param maxTreeDepth - Maximum depth of the Merkle tree (default: 15).
95
+ * @returns Array of field elements ready for Merkle tree construction.
96
+ * @throws {Error} If the number of addresses exceeds the maximum capacity.
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * const addresses = [
101
+ * "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px",
102
+ * "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t",
103
+ * "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t",
104
+ * ];
105
+ * const sealance = new SealanceMerkleTree();
106
+ * const leaves = sealance.generateLeaves(addresses, 15);
107
+ * console.log(leaves); // [
108
+ * "0field",
109
+ * "1295133970529764960316948294624974168921228814652993007266766481909235735940field",
110
+ * "1295133970529764960316948294624974168921228814652993007266766481909235735940field",
111
+ * "3501665755452795161867664882580888971213780722176652848275908626939553697821field"
112
+ * ]
113
+ * ```
114
+ */
115
+ generateLeaves(addresses: string[], maxTreeDepth?: number): string[];
116
+ /**
117
+ * Finds the leaf indices for non-inclusion proof of an address and returns the indices of the two adjacent leaves that surround the target address.
118
+ *
119
+ * @param merkleTree - The complete Merkle tree as array of BigInts.
120
+ * @param address - The Aleo address for which to find indices.
121
+ * @returns Tuple of [leftLeafIndex, rightLeafIndex].
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * const addresses = [
126
+ * "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px",
127
+ * "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t",
128
+ * "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t",
129
+ * ];
130
+ * const sealance = new SealanceMerkleTree();
131
+ * const leaves = sealance.generateLeaves(addresses);
132
+ * const tree = sealance.buildTree(leaves);
133
+ * const [leftIdx, rightIdx] = sealance.getLeafIndices(tree, "aleo1...");
134
+ * ```
135
+ */
136
+ getLeafIndices(merkleTree: bigint[], address: string): [number, number];
137
+ /**
138
+ * Generates the sibling path (Merkle proof) for a given leaf index
139
+ *
140
+ * @param tree - The complete Merkle tree.
141
+ * @param leafIndex - Index of the leaf for which to generate the proof.
142
+ * @param depth - Maximum depth of the tree.
143
+ * @returns Object containing siblings array and leaf_index.
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * const addresses = [
148
+ * "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px",
149
+ * "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t",
150
+ * "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t",
151
+ * ];
152
+ * const sealance = new SealanceMerkleTree();
153
+ * const leaves = sealance.generateLeaves(addresses);
154
+ * const tree = sealance.buildTree(leaves);
155
+ * const [leftIdx, rightIdx] = sealance.getLeafIndices(tree, "aleo1...");
156
+ * const proof = sealance.getSiblingPath(tree, leftIdx, 15);
157
+ * // proof = { siblings: [0n, 1n, ...], leaf_index: leftIdx }
158
+ * ```
159
+ */
160
+ getSiblingPath(tree: bigint[], leafIndex: number, depth: number): {
161
+ siblings: bigint[];
162
+ leaf_index: number;
163
+ };
164
+ /**
165
+ * Generates a formatted exclusion proof suitable for Aleo transactions.
166
+ *
167
+ * @param proof - An array of two {sibling path, leafindex} objects.
168
+ * @returns String representation of the exclusion proof.
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * const addresses = [
173
+ * "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px",
174
+ * "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t",
175
+ * "aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t",
176
+ * ];
177
+ * const sealance = new SealanceMerkleTree();
178
+ * const leaves = sealance.generateLeaves(addresses);
179
+ * const tree = sealance.buildTree(leaves);
180
+ * const [leftIdx, rightIdx] = sealance.getLeafIndices(tree, "aleo1...");
181
+ * const proof1 = getSiblingPath(tree, leftIdx, 15);
182
+ * const proof2 = getSiblingPath(tree, rightIdx, 15);
183
+ * const formattedProof = formatMerkleProof([proof1, proof2]);
184
+ * // formattedProof = "[{ siblings: [0field, 1field, ...], leaf_index: 0u32 }, { siblings: [0field, 2field, ...], leaf_index: 1u32 }]"
185
+ * ```
186
+ */
187
+ formatMerkleProof(proof: {
188
+ siblings: bigint[];
189
+ leaf_index: number;
190
+ }[]): string;
191
+ }
192
+ export { SealanceMerkleTree };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Reason code for invalid locator validation failures.
3
+ * - `"reserved_name"`: A locator component is empty or `"."`.
4
+ * - `"path_traversal"`: A locator component contains `..`.
5
+ * - `"path_separator"`: A locator component contains a path separator (`/`, `\`) or null byte.
6
+ * - `"negative_value"`: A numeric locator field (edition, amendment, recordInputPosition) is not a non-negative integer.
7
+ */
8
+ export type InvalidLocatorReason = "reserved_name" | "path_traversal" | "path_separator" | "negative_value";
9
+ /**
10
+ * Error thrown when a key locator is invalid for filesystem use.
11
+ * Used to prevent path traversal and other filesystem injection when deriving paths from locators.
12
+ *
13
+ * @extends Error
14
+ */
15
+ export declare class InvalidLocatorError extends Error {
16
+ readonly locator: string;
17
+ readonly reason: InvalidLocatorReason;
18
+ /**
19
+ * @param message - Human-readable description of the validation failure.
20
+ * @param locator - The invalid locator string that failed validation.
21
+ * @param reason - Machine-readable reason code for the failure.
22
+ */
23
+ constructor(message: string, locator: string, reason: InvalidLocatorReason);
24
+ }
@@ -0,0 +1,177 @@
1
+ import { FunctionKeyPair } from "../../models/keyPair.js";
2
+ import { KeyFingerprint } from "../verifier/interface.js";
3
+ import { KeyLocator, KeyStore, ProvingKeyLocator, VerifyingKeyLocator } from "./interface.js";
4
+ import { ProvingKey, VerifyingKey } from "../../wasm.js";
5
+ export declare class LocalFileKeyStore implements KeyStore {
6
+ private directory;
7
+ private readonly keyVerifier;
8
+ /**
9
+ * Creates a new directory at the given path or CURRENTDIR/.aleo if none is provided to store keys.
10
+ * If a custom directory is passed and its last path segment is not ".aleo", ".aleo" is appended
11
+ * so keys are stored under that subdirectory (e.g. /home/project → /home/project/.aleo).
12
+ *
13
+ * @param {string} [directory] - Optional custom directory path for key storage. Defaults to ".aleo" in current working directory.
14
+ * @throws {Error} If directory creation fails.
15
+ */
16
+ constructor(directory?: string);
17
+ /**
18
+ * Validates a single locator component for unsafe filesystem characters.
19
+ *
20
+ * @private
21
+ * @param {string} value - The component value to validate.
22
+ * @param {string} label - Label for error messages (e.g. "program", "functionName").
23
+ * @throws {InvalidLocatorError} If the value is empty, contains traversal sequences, path separators, or null bytes.
24
+ */
25
+ private validateComponent;
26
+ /**
27
+ * Validates that a numeric locator field is not negative.
28
+ *
29
+ * @private
30
+ * @param {number} value - The numeric value to validate.
31
+ * @param {string} label - Label for error messages (e.g. "edition", "amendment").
32
+ * @throws {InvalidLocatorError} If the value is negative.
33
+ */
34
+ private validateNonNegative;
35
+ /**
36
+ * Serializes a {@link KeyLocator} to a filesystem-safe flat string, validating components first.
37
+ *
38
+ * For prover/verifier keys: `{program}.{functionName}.e{edition}.a{amendment}.{network}.{keyType}`
39
+ * For translation keys: `{program}.{functionName}.e{edition}.a{amendment}.{network}.translation.{recordName}.{recordInputPosition}`
40
+ *
41
+ * Note: The optional `checksum` field is excluded — it is used for integrity verification only
42
+ * (via {@link checksumToFingerprint}) and is not part of the key identity.
43
+ *
44
+ * @private
45
+ * @param {KeyLocator} locator - The key locator.
46
+ * @returns {string} A dot-delimited string safe for use as a filename.
47
+ * @throws {InvalidLocatorError} If any component contains unsafe characters.
48
+ */
49
+ private serializeLocator;
50
+ /**
51
+ * Converts an optional checksum string from a locator into a KeyFingerprint
52
+ * suitable for the key verifier, using the actual key byte length for size.
53
+ *
54
+ * @private
55
+ */
56
+ private checksumToFingerprint;
57
+ /**
58
+ * Generates the path for a key metadata file based on the locator.
59
+ *
60
+ * @private
61
+ * @param {string} locator - Unique identifier for the key.
62
+ * @returns {string} Full filesystem path to the metadata file.
63
+ */
64
+ private metadataPath;
65
+ /**
66
+ * Reads and parses the key fingerprint metadata from storage.
67
+ *
68
+ * @private
69
+ * @param {string} locator - Unique identifier for the key.
70
+ * @returns {Promise<KeyFingerprint | null>} The key fingerprint if found, null if file doesn't exist.
71
+ * @throws {Error} If file read fails for any reason other than not found.
72
+ */
73
+ private readKeyMetadata;
74
+ /**
75
+ * Writes key fingerprint metadata to storage.
76
+ *
77
+ * @private
78
+ * @param {string} locator - Unique identifier for the key.
79
+ * @param {KeyFingerprint} metadata - Key fingerprint metadata to store.
80
+ * @returns {Promise<void>}
81
+ * @throws {Error} If directory creation or file write fails.
82
+ */
83
+ private writeKeyMetadata;
84
+ private readFileOptional;
85
+ /**
86
+ * Atomically writes data to a file, ensuring the parent directories exist.
87
+ *
88
+ * @private
89
+ * @param {string} filepath - Full path to the file to write
90
+ * @param {Uint8Array} data - Binary data to write to the file
91
+ * @returns {Promise<void>} Resolves when write is complete
92
+ * @throws {Error} If directory creation or file write fails
93
+ */
94
+ private writeFileAtomic;
95
+ /**
96
+ * Recursively removes all files and subdirectories under the given directory, then removes the directory itself.
97
+ * Uses fs.rm with recursive: true and force: true so that symbolic links are removed without following them,
98
+ * avoiding deletion of content outside the keystore.
99
+ *
100
+ * @private
101
+ * @param {string} dir - Directory path to clear
102
+ * @returns {Promise<void>} Resolves when clearing is complete
103
+ * @throws {Error} If directory removal fails for reasons other than non-existence
104
+ */
105
+ private clearDirectory;
106
+ /**
107
+ * Retrieves the key bytes from storage and optionally verifies them.
108
+ *
109
+ * @param {KeyLocator} locator - The key locator with optional checksum for verification.
110
+ * @returns {Promise<Uint8Array | null>} The key bytes if found and verified, null if not found.
111
+ * @throws {KeyVerificationError} If verification fails.
112
+ */
113
+ getKeyBytes(locator: KeyLocator): Promise<Uint8Array | null>;
114
+ /**
115
+ * Retrieves and verifies a proving key from storage.
116
+ *
117
+ * @param {ProvingKeyLocator} locator - The proving key locator.
118
+ * @returns {Promise<ProvingKey | null>} The proving key if found and verified, null if not found.
119
+ * @throws {KeyVerificationError} If verification fails.
120
+ * @throws {Error} If key bytes cannot be parsed into a valid ProvingKey.
121
+ */
122
+ getProvingKey(locator: ProvingKeyLocator): Promise<ProvingKey | null>;
123
+ /**
124
+ * Retrieves and verifies a verifying key from storage.
125
+ *
126
+ * @param {VerifyingKeyLocator} locator - The verifying key locator.
127
+ * @returns {Promise<VerifyingKey | null>} The verifying key if found and verified, null if not found.
128
+ * @throws {KeyVerificationError} If verification fails.
129
+ * @throws {Error} If key bytes cannot be parsed into a valid VerifyingKey.
130
+ */
131
+ getVerifyingKey(locator: VerifyingKeyLocator): Promise<VerifyingKey | null>;
132
+ /**
133
+ * Stores proving and verifying keys in key storage.
134
+ *
135
+ * @param {ProvingKeyLocator} proverLocator The locator for the proving key.
136
+ * @param {VerifyingKeyLocator} verifierLocator The locator for the verifying key.
137
+ * @param {FunctionKeyPair} keys The proving and verifying keys.
138
+ */
139
+ setKeys(proverLocator: ProvingKeyLocator, verifierLocator: VerifyingKeyLocator, keys: FunctionKeyPair): Promise<void>;
140
+ /**
141
+ * Store a raw key in storage along with its fingerprint metadata for future verification.
142
+ *
143
+ * @param {Uint8Array} keyBytes The raw key bytes.
144
+ * @param {KeyLocator} locator The unique locator for the key.
145
+ * @returns {Promise<void>}
146
+ * @throws {Error} If computing key metadata or writing to storage fails
147
+ */
148
+ setKeyBytes(keyBytes: Uint8Array, locator: KeyLocator): Promise<void>;
149
+ /**
150
+ * Returns stored metadata for a key, if any.
151
+ *
152
+ * @param {KeyLocator} locator The unique locator for the key.
153
+ * @returns {Promise<KeyFingerprint | null>} The stored fingerprint metadata, or null if none exists.
154
+ */
155
+ getKeyMetadata(locator: KeyLocator): Promise<KeyFingerprint | null>;
156
+ /**
157
+ * Checks if a key exists for the given locator.
158
+ *
159
+ * @param {KeyLocator} locator - The unique key locator.
160
+ * @returns {Promise<boolean>} True if key exists, false otherwise.
161
+ */
162
+ has(locator: KeyLocator): Promise<boolean>;
163
+ /**
164
+ * Deletes a key and its associated metadata from storage. Silently ignores errors if files don't exist.
165
+ *
166
+ * @param {KeyLocator} locator - The unique key locator.
167
+ * @returns {Promise<void>}
168
+ */
169
+ delete(locator: KeyLocator): Promise<void>;
170
+ /**
171
+ * Clears the key storage directory by recursively removing all files and subdirectories under it, then removes the keystore directory itself.
172
+ *
173
+ * @returns {Promise<void>}
174
+ * @throws {Error} If directory listing fails for reasons other than non-existence.
175
+ */
176
+ clear(): Promise<void>;
177
+ }
@@ -0,0 +1,161 @@
1
+ import { FunctionKeyPair } from "../../models/keyPair.js";
2
+ export type { InvalidLocatorReason } from "./error.js";
3
+ export { InvalidLocatorError } from "./error.js";
4
+ import { KeyFingerprint } from "../verifier/interface.js";
5
+ import { ProvingKey, VerifyingKey } from "../../wasm.js";
6
+ /**
7
+ * Discriminates the type of key a locator refers to.
8
+ */
9
+ export type KeyType = "prover" | "verifier" | "translation";
10
+ /**
11
+ * Shared fields for all function key locators.
12
+ *
13
+ * @property {string} program - The program name (e.g. "credits.aleo").
14
+ * @property {string} functionName - The function name (e.g. "transfer_private").
15
+ * @property {number} edition - The program edition (u16). Incremented when a program is re-deployed.
16
+ * @property {number} amendment - The program amendment. Reserved for future protocol-level amendments; defaults to 0.
17
+ * @property {string} network - The network name (e.g. "mainnet", "testnet").
18
+ * @property {string} [checksum] - Optional SHA-256 checksum for key verification. Used for integrity verification only; not part of the key identity or serialized form.
19
+ */
20
+ export interface BaseFunctionKeyLocator {
21
+ program: string;
22
+ functionName: string;
23
+ edition: number;
24
+ amendment: number;
25
+ network: string;
26
+ checksum?: string;
27
+ }
28
+ /**
29
+ * Locator for a proving key.
30
+ */
31
+ export interface ProvingKeyLocator extends BaseFunctionKeyLocator {
32
+ keyType: "prover";
33
+ }
34
+ /**
35
+ * Locator for a verifying key.
36
+ */
37
+ export interface VerifyingKeyLocator extends BaseFunctionKeyLocator {
38
+ keyType: "verifier";
39
+ }
40
+ /**
41
+ * Locator for a translation key, which requires additional record information.
42
+ *
43
+ * @property {string} recordName - The name of the record associated with the translation key.
44
+ * @property {number} recordInputPosition - The position of the record input in the function signature.
45
+ */
46
+ export interface TranslationKeyLocator extends BaseFunctionKeyLocator {
47
+ keyType: "translation";
48
+ recordName: string;
49
+ recordInputPosition: number;
50
+ }
51
+ /**
52
+ * A locator that uniquely identifies a function's proving, verifying, or translation key.
53
+ * Discriminated on the {@link KeyType} field.
54
+ *
55
+ * @example
56
+ * const prover: KeyLocator = { program: "credits.aleo", functionName: "transfer_private", edition: 1, amendment: 0, network: "mainnet", keyType: "prover" };
57
+ * const verifier: KeyLocator = { program: "credits.aleo", functionName: "transfer_private", edition: 1, amendment: 0, network: "mainnet", keyType: "verifier" };
58
+ */
59
+ export type KeyLocator = ProvingKeyLocator | VerifyingKeyLocator | TranslationKeyLocator;
60
+ /**
61
+ * Creates a {@link ProvingKeyLocator}.
62
+ *
63
+ * @param {string} program - The program name (e.g. "credits.aleo").
64
+ * @param {string} functionName - The function name (e.g. "transfer_private").
65
+ * @param {number} [edition=1] - The program edition.
66
+ * @param {number} [amendment=0] - The program amendment.
67
+ * @param {string} [network] - The network name. Defaults to the build-time network.
68
+ * @param {string} [checksum] - Optional SHA-256 checksum for key verification.
69
+ * @returns {ProvingKeyLocator}
70
+ */
71
+ export declare function provingKeyLocator(program: string, functionName: string, edition?: number, amendment?: number, network?: string, checksum?: string): ProvingKeyLocator;
72
+ /**
73
+ * Creates a {@link VerifyingKeyLocator}.
74
+ *
75
+ * @param {string} program - The program name (e.g. "credits.aleo").
76
+ * @param {string} functionName - The function name (e.g. "transfer_private").
77
+ * @param {number} [edition=1] - The program edition.
78
+ * @param {number} [amendment=0] - The program amendment.
79
+ * @param {string} [network] - The network name. Defaults to the build-time network.
80
+ * @param {string} [checksum] - Optional SHA-256 checksum for key verification.
81
+ * @returns {VerifyingKeyLocator}
82
+ */
83
+ export declare function verifyingKeyLocator(program: string, functionName: string, edition?: number, amendment?: number, network?: string, checksum?: string): VerifyingKeyLocator;
84
+ /**
85
+ * Creates a {@link TranslationKeyLocator}.
86
+ *
87
+ * @param {string} program - The program name (e.g. "credits.aleo").
88
+ * @param {string} functionName - The function name (e.g. "transfer_private").
89
+ * @param {string} recordName - The record name associated with the translation key.
90
+ * @param {number} recordInputPosition - The record input position in the function signature.
91
+ * @param {number} [edition=1] - The program edition.
92
+ * @param {number} [amendment=0] - The program amendment.
93
+ * @param {string} [network] - The network name. Defaults to the build-time network.
94
+ * @param {string} [checksum] - Optional SHA-256 checksum for key verification.
95
+ * @returns {TranslationKeyLocator}
96
+ */
97
+ export declare function translationKeyLocator(program: string, functionName: string, recordName: string, recordInputPosition: number, edition?: number, amendment?: number, network?: string, checksum?: string): TranslationKeyLocator;
98
+ export interface KeyStore {
99
+ /**
100
+ * Returns the raw bytes of a key for a given locator.
101
+ *
102
+ * @param {KeyLocator} locator The unique locator for the desired key.
103
+ * @returns {Promise<Uint8Array | null>} The raw key bytes if they exist, or null if not found.
104
+ */
105
+ getKeyBytes(locator: KeyLocator): Promise<Uint8Array | null>;
106
+ /**
107
+ * Returns the `ProvingKey` for a given locator.
108
+ *
109
+ * @param {ProvingKeyLocator} locator The unique locator for the desired `ProvingKey`.
110
+ * @returns {Promise<ProvingKey | null>} Returns the `ProvingKey` for the given locator if it exists or null if it does not.
111
+ */
112
+ getProvingKey(locator: ProvingKeyLocator): Promise<ProvingKey | null>;
113
+ /**
114
+ * Returns the `VerifyingKey` for a given locator.
115
+ *
116
+ * @param {VerifyingKeyLocator} locator The unique locator for the desired `VerifyingKey`.
117
+ * @returns {Promise<VerifyingKey | null>} Returns the `VerifyingKey` for the given locator if it exists or null if it does not exist.
118
+ */
119
+ getVerifyingKey(locator: VerifyingKeyLocator): Promise<VerifyingKey | null>;
120
+ /**
121
+ * Stores proving and verifying keys in key storage.
122
+ *
123
+ * @param {ProvingKeyLocator} proverLocator The locator for the proving key.
124
+ * @param {VerifyingKeyLocator} verifierLocator The locator for the verifying key.
125
+ * @param {FunctionKeyPair} keys The proving and verifying keys.
126
+ */
127
+ setKeys(proverLocator: ProvingKeyLocator, verifierLocator: VerifyingKeyLocator, keys: FunctionKeyPair): Promise<void>;
128
+ /**
129
+ * Store a raw key in storage along with its fingerprint metadata for future verification.
130
+ *
131
+ * @param {Uint8Array} keyBytes The raw key bytes.
132
+ * @param {KeyLocator} locator The unique locator for the desired key.
133
+ * @returns {Promise<void>}
134
+ */
135
+ setKeyBytes(keyBytes: Uint8Array, locator: KeyLocator): Promise<void>;
136
+ /**
137
+ * Returns stored metadata for a key, if any.
138
+ *
139
+ * @param {KeyLocator} locator The unique locator for the key.
140
+ * @returns {Promise<KeyFingerprint | null>} The stored fingerprint for that key, or null if none exists.
141
+ */
142
+ getKeyMetadata(locator: KeyLocator): Promise<KeyFingerprint | null>;
143
+ /**
144
+ * Determines if a given key exists or not.
145
+ *
146
+ * @param {KeyLocator} locator The unique locator for the key.
147
+ * @returns {Promise<boolean>} True if the key exists, false otherwise.
148
+ */
149
+ has(locator: KeyLocator): Promise<boolean>;
150
+ /**
151
+ * Deletes a key and its metadata corresponding to a given locator.
152
+ *
153
+ * @param {KeyLocator} locator The unique locator for the key.
154
+ * @returns {Promise<void>}
155
+ */
156
+ delete(locator: KeyLocator): Promise<void>;
157
+ /**
158
+ * Clears all keys in the keystore.
159
+ */
160
+ clear(): Promise<void>;
161
+ }