@provablehq/sdk 0.10.0-rc → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/dynamic/browser.d.ts +8 -0
  2. package/dist/dynamic/browser.js +8 -0
  3. package/dist/dynamic/node.d.ts +8 -0
  4. package/dist/dynamic/node.js +8 -0
  5. package/dist/mainnet/account.d.ts +61 -6
  6. package/dist/mainnet/browser.d.ts +41 -8
  7. package/dist/mainnet/browser.js +3699 -564
  8. package/dist/mainnet/browser.js.map +1 -1
  9. package/dist/mainnet/constants.d.ts +6 -0
  10. package/dist/mainnet/external-signing.d.ts +76 -0
  11. package/dist/mainnet/integrations/sealance/merkle-tree.d.ts +192 -0
  12. package/dist/mainnet/keys/keystore/error.d.ts +24 -0
  13. package/dist/mainnet/keys/keystore/file.d.ts +177 -0
  14. package/dist/mainnet/keys/keystore/interface.d.ts +161 -0
  15. package/dist/mainnet/keys/provider/interface.d.ts +170 -0
  16. package/dist/mainnet/{function-key-provider.d.ts → keys/provider/memory.d.ts} +27 -167
  17. package/dist/mainnet/{offline-key-provider.d.ts → keys/provider/offline.d.ts} +21 -4
  18. package/dist/mainnet/keys/verifier/interface.d.ts +70 -0
  19. package/dist/mainnet/keys/verifier/memory.d.ts +37 -0
  20. package/dist/mainnet/models/cryptoBoxPubkey.d.ts +4 -0
  21. package/dist/mainnet/models/encryptedProvingRequest.d.ts +4 -0
  22. package/dist/mainnet/models/external-signing.d.ts +123 -0
  23. package/dist/mainnet/models/functionInput.d.ts +7 -0
  24. package/dist/mainnet/models/input/inputJSON.d.ts +1 -0
  25. package/dist/mainnet/models/input/inputObject.d.ts +1 -0
  26. package/dist/mainnet/models/keyPair.d.ts +4 -0
  27. package/dist/mainnet/models/output/outputJSON.d.ts +1 -0
  28. package/dist/mainnet/models/output/outputObject.d.ts +1 -0
  29. package/dist/mainnet/models/provingResponse.d.ts +48 -2
  30. package/dist/mainnet/models/record-provider/encryptedRecord.d.ts +58 -0
  31. package/dist/mainnet/models/record-provider/ownedRecord.d.ts +60 -0
  32. package/dist/mainnet/models/record-provider/recordSearchParams.d.ts +19 -0
  33. package/dist/mainnet/models/record-scanner/encryptedRecordsResult.d.ts +7 -0
  34. package/dist/mainnet/models/record-scanner/encryptedRegistrationRequest.d.ts +8 -0
  35. package/dist/mainnet/models/record-scanner/error.d.ts +47 -0
  36. package/dist/mainnet/models/record-scanner/ownedFilter.d.ts +22 -0
  37. package/dist/mainnet/models/record-scanner/ownedRecordsResponseFilter.d.ts +42 -0
  38. package/dist/mainnet/models/record-scanner/ownedRecordsResult.d.ts +13 -0
  39. package/dist/mainnet/models/record-scanner/recordsFilter.d.ts +35 -0
  40. package/dist/mainnet/models/record-scanner/recordsResponseFilter.d.ts +42 -0
  41. package/dist/mainnet/models/record-scanner/registrationRequest.d.ts +13 -0
  42. package/dist/mainnet/models/record-scanner/registrationResponse.d.ts +13 -0
  43. package/dist/mainnet/models/record-scanner/registrationResult.d.ts +9 -0
  44. package/dist/mainnet/models/record-scanner/revokeResult.d.ts +17 -0
  45. package/dist/mainnet/models/record-scanner/serialNumbersResult.d.ts +15 -0
  46. package/dist/mainnet/models/record-scanner/statusResponse.d.ts +13 -0
  47. package/dist/mainnet/models/record-scanner/statusResult.d.ts +13 -0
  48. package/dist/mainnet/models/record-scanner/tagsResult.d.ts +12 -0
  49. package/dist/mainnet/network-client.d.ts +129 -46
  50. package/dist/mainnet/node-polyfill.js +2 -49
  51. package/dist/mainnet/node-polyfill.js.map +1 -1
  52. package/dist/mainnet/node.d.ts +1 -0
  53. package/dist/mainnet/node.js +376 -4
  54. package/dist/mainnet/node.js.map +1 -1
  55. package/dist/mainnet/program-manager.d.ts +538 -58
  56. package/dist/mainnet/record-provider.d.ts +113 -75
  57. package/dist/mainnet/record-scanner.d.ts +368 -0
  58. package/dist/mainnet/security.d.ts +62 -0
  59. package/dist/mainnet/utils.d.ts +1 -0
  60. package/dist/mainnet/wasm.d.ts +1 -1
  61. package/dist/testnet/account.d.ts +61 -6
  62. package/dist/testnet/browser.d.ts +41 -8
  63. package/dist/testnet/browser.js +3699 -564
  64. package/dist/testnet/browser.js.map +1 -1
  65. package/dist/testnet/constants.d.ts +6 -0
  66. package/dist/testnet/external-signing.d.ts +76 -0
  67. package/dist/testnet/integrations/sealance/merkle-tree.d.ts +192 -0
  68. package/dist/testnet/keys/keystore/error.d.ts +24 -0
  69. package/dist/testnet/keys/keystore/file.d.ts +177 -0
  70. package/dist/testnet/keys/keystore/interface.d.ts +161 -0
  71. package/dist/testnet/keys/provider/interface.d.ts +170 -0
  72. package/dist/testnet/{function-key-provider.d.ts → keys/provider/memory.d.ts} +27 -167
  73. package/dist/testnet/{offline-key-provider.d.ts → keys/provider/offline.d.ts} +21 -4
  74. package/dist/testnet/keys/verifier/interface.d.ts +70 -0
  75. package/dist/testnet/keys/verifier/memory.d.ts +37 -0
  76. package/dist/testnet/models/cryptoBoxPubkey.d.ts +4 -0
  77. package/dist/testnet/models/encryptedProvingRequest.d.ts +4 -0
  78. package/dist/testnet/models/external-signing.d.ts +123 -0
  79. package/dist/testnet/models/functionInput.d.ts +7 -0
  80. package/dist/testnet/models/input/inputJSON.d.ts +1 -0
  81. package/dist/testnet/models/input/inputObject.d.ts +1 -0
  82. package/dist/testnet/models/keyPair.d.ts +4 -0
  83. package/dist/testnet/models/output/outputJSON.d.ts +1 -0
  84. package/dist/testnet/models/output/outputObject.d.ts +1 -0
  85. package/dist/testnet/models/provingResponse.d.ts +48 -2
  86. package/dist/testnet/models/record-provider/encryptedRecord.d.ts +58 -0
  87. package/dist/testnet/models/record-provider/ownedRecord.d.ts +60 -0
  88. package/dist/testnet/models/record-provider/recordSearchParams.d.ts +19 -0
  89. package/dist/testnet/models/record-scanner/encryptedRecordsResult.d.ts +7 -0
  90. package/dist/testnet/models/record-scanner/encryptedRegistrationRequest.d.ts +8 -0
  91. package/dist/testnet/models/record-scanner/error.d.ts +47 -0
  92. package/dist/testnet/models/record-scanner/ownedFilter.d.ts +22 -0
  93. package/dist/testnet/models/record-scanner/ownedRecordsResponseFilter.d.ts +42 -0
  94. package/dist/testnet/models/record-scanner/ownedRecordsResult.d.ts +13 -0
  95. package/dist/testnet/models/record-scanner/recordsFilter.d.ts +35 -0
  96. package/dist/testnet/models/record-scanner/recordsResponseFilter.d.ts +42 -0
  97. package/dist/testnet/models/record-scanner/registrationRequest.d.ts +13 -0
  98. package/dist/testnet/models/record-scanner/registrationResponse.d.ts +13 -0
  99. package/dist/testnet/models/record-scanner/registrationResult.d.ts +9 -0
  100. package/dist/testnet/models/record-scanner/revokeResult.d.ts +17 -0
  101. package/dist/testnet/models/record-scanner/serialNumbersResult.d.ts +15 -0
  102. package/dist/testnet/models/record-scanner/statusResponse.d.ts +13 -0
  103. package/dist/testnet/models/record-scanner/statusResult.d.ts +13 -0
  104. package/dist/testnet/models/record-scanner/tagsResult.d.ts +12 -0
  105. package/dist/testnet/network-client.d.ts +129 -46
  106. package/dist/testnet/node-polyfill.js +2 -49
  107. package/dist/testnet/node-polyfill.js.map +1 -1
  108. package/dist/testnet/node.d.ts +1 -0
  109. package/dist/testnet/node.js +376 -4
  110. package/dist/testnet/node.js.map +1 -1
  111. package/dist/testnet/program-manager.d.ts +538 -58
  112. package/dist/testnet/record-provider.d.ts +113 -75
  113. package/dist/testnet/record-scanner.d.ts +368 -0
  114. package/dist/testnet/security.d.ts +62 -0
  115. package/dist/testnet/utils.d.ts +1 -0
  116. package/dist/testnet/wasm.d.ts +1 -1
  117. package/package.json +11 -6
@@ -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 };
@@ -1,19 +1,13 @@
1
- import { Key } from "./constants.js";
2
- import { ProvingKey, VerifyingKey } from "./wasm.js";
3
- type FunctionKeyPair = [ProvingKey, VerifyingKey];
4
- type CachedKeyPair = [Uint8Array, Uint8Array];
1
+ import { Key } from "../../constants.js";
2
+ import { CachedKeyPair, FunctionKeyPair } from "../../models/keyPair.js";
3
+ import { FunctionKeyProvider, KeySearchParams } from "./interface";
4
+ import { ProvingKey, VerifyingKey } from "../../wasm.js";
5
+ import { KeyStore } from "../keystore/interface.js";
5
6
  type AleoKeyProviderInitParams = {
6
7
  proverUri?: string;
7
8
  verifierUri?: string;
8
9
  cacheKey?: string;
9
10
  };
10
- /**
11
- * Interface for record search parameters. This allows for arbitrary search parameters to be passed to record provider
12
- * implementations.
13
- */
14
- interface KeySearchParams {
15
- [key: string]: any;
16
- }
17
11
  /**
18
12
  * AleoKeyProviderParams search parameter for the AleoKeyProvider. It allows for the specification of a proverUri and
19
13
  * verifierUri to fetch keys via HTTP from a remote resource as well as a unique cacheKey to store the keys in memory.
@@ -39,155 +33,8 @@ declare class AleoKeyProviderParams implements KeySearchParams {
39
33
  });
40
34
  }
41
35
  /**
42
- * KeyProvider interface. Enables the retrieval of public proving and verifying keys for Aleo Programs.
43
- */
44
- interface FunctionKeyProvider {
45
- /**
46
- * Get bond_public function keys from the credits.aleo program
47
- *
48
- * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_public function
49
- */
50
- bondPublicKeys(): Promise<FunctionKeyPair>;
51
- /**
52
- * Get bond_validator function keys from the credits.aleo program
53
- *
54
- * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_validator function
55
- */
56
- bondValidatorKeys(): Promise<FunctionKeyPair>;
57
- /**
58
- * Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId
59
- * exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.
60
- *
61
- * @param {string} keyId access key for the cache
62
- * @param {FunctionKeyPair} keys keys to cache
63
- */
64
- cacheKeys(keyId: string, keys: FunctionKeyPair): void;
65
- /**
66
- * Get unbond_public function keys from the credits.aleo program
67
- *
68
- * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the unbond_public function
69
- */
70
- claimUnbondPublicKeys(): Promise<FunctionKeyPair>;
71
- /**
72
- * Get arbitrary function keys from a provider
73
- *
74
- * @param {KeySearchParams | undefined} params - Optional search parameters for the key provider
75
- * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program
76
- *
77
- * @example
78
- * // Create a search object which implements the KeySearchParams interface
79
- * class IndexDbSearch implements KeySearchParams {
80
- * db: string
81
- * keyId: string
82
- * constructor(params: {db: string, keyId: string}) {
83
- * this.db = params.db;
84
- * this.keyId = params.keyId;
85
- * }
86
- * }
87
- *
88
- * // Create a new object which implements the KeyProvider interface
89
- * class IndexDbKeyProvider implements FunctionKeyProvider {
90
- * async functionKeys(params: KeySearchParams): Promise<FunctionKeyPair> {
91
- * return new Promise((resolve, reject) => {
92
- * const request = indexedDB.open(params.db, 1);
93
- *
94
- * request.onupgradeneeded = function(e) {
95
- * const db = e.target.result;
96
- * if (!db.objectStoreNames.contains('keys')) {
97
- * db.createObjectStore('keys', { keyPath: 'id' });
98
- * }
99
- * };
100
- *
101
- * request.onsuccess = function(e) {
102
- * const db = e.target.result;
103
- * const transaction = db.transaction(["keys"], "readonly");
104
- * const store = transaction.objectStore("keys");
105
- * const request = store.get(params.keyId);
106
- * request.onsuccess = function(e) {
107
- * if (request.result) {
108
- * resolve(request.result as FunctionKeyPair);
109
- * } else {
110
- * reject(new Error("Key not found"));
111
- * }
112
- * };
113
- * request.onerror = function(e) { reject(new Error("Error fetching key")); };
114
- * };
115
- *
116
- * request.onerror = function(e) { reject(new Error("Error opening database")); };
117
- * });
118
- * }
119
- *
120
- * // implement the other methods...
121
- * }
122
- *
123
- *
124
- * const keyProvider = new AleoKeyProvider();
125
- * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
126
- * const recordProvider = new NetworkRecordProvider(account, networkClient);
127
- *
128
- * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
129
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
130
- * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
131
- *
132
- * // Keys can also be fetched manually
133
- * const searchParams = new IndexDbSearch({db: "keys", keyId: "credits.aleo:transferPrivate"});
134
- * const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.functionKeys(searchParams);
135
- */
136
- functionKeys(params?: KeySearchParams): Promise<FunctionKeyPair>;
137
- /**
138
- * Get fee_private function keys from the credits.aleo program
139
- *
140
- * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
141
- */
142
- feePrivateKeys(): Promise<FunctionKeyPair>;
143
- /**
144
- * Get fee_public function keys from the credits.aleo program
145
- *
146
- * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
147
- */
148
- feePublicKeys(): Promise<FunctionKeyPair>;
149
- /**
150
- * Get join function keys from the credits.aleo program
151
- *
152
- * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
153
- */
154
- joinKeys(): Promise<FunctionKeyPair>;
155
- /**
156
- * Get split function keys from the credits.aleo program
157
- *
158
- * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
159
- */
160
- splitKeys(): Promise<FunctionKeyPair>;
161
- /**
162
- * Get keys for a variant of the transfer function from the credits.aleo program
163
- *
164
- * @param {string} visibility Visibility of the transfer function (private, public, privateToPublic, publicToPrivate)
165
- * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified transfer function
166
- *
167
- * @example
168
- * // Create a new object which implements the KeyProvider interface
169
- * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
170
- * const keyProvider = new AleoKeyProvider();
171
- * const recordProvider = new NetworkRecordProvider(account, networkClient);
172
- *
173
- * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
174
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
175
- * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
176
- *
177
- * // Keys can also be fetched manually
178
- * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");
179
- */
180
- transferKeys(visibility: string): Promise<FunctionKeyPair>;
181
- /**
182
- * Get unbond_public function keys from the credits.aleo program
183
- *
184
- * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
185
- */
186
- unBondPublicKeys(): Promise<FunctionKeyPair>;
187
- }
188
- /**
189
- * AleoKeyProvider class. Implements the KeyProvider interface. Enables the retrieval of Aleo program proving and
190
- * verifying keys for the credits.aleo program over http from official Aleo sources and storing and retrieving function
36
+ * AleoKeyProvider class. Implements the FunctionKeyProvider interface. Enables the retrieval of Aleo program proving and
37
+ * verifying keys for the credits.aleo program over HTTP from official Aleo sources and storing and retrieving function
191
38
  * keys from a local memory cache.
192
39
  */
193
40
  declare class AleoKeyProvider implements FunctionKeyProvider {
@@ -196,6 +43,7 @@ declare class AleoKeyProvider implements FunctionKeyProvider {
196
43
  keyUris: string;
197
44
  fetchBytes(url?: string): Promise<Uint8Array>;
198
45
  constructor();
46
+ keyStore(): Promise<KeyStore | undefined>;
199
47
  /**
200
48
  * Use local memory to store keys
201
49
  *
@@ -243,12 +91,12 @@ declare class AleoKeyProvider implements FunctionKeyProvider {
243
91
  *
244
92
  * @example
245
93
  * // Create a new object which implements the KeyProvider interface
246
- * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
94
+ * const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
247
95
  * const keyProvider = new AleoKeyProvider();
248
96
  * const recordProvider = new NetworkRecordProvider(account, networkClient);
249
97
  *
250
98
  * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
251
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
99
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
252
100
  * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
253
101
  *
254
102
  * // Keys can also be fetched manually using the key provider
@@ -267,12 +115,12 @@ declare class AleoKeyProvider implements FunctionKeyProvider {
267
115
  *
268
116
  * @example
269
117
  * // Create a new AleoKeyProvider object
270
- * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
118
+ * const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
271
119
  * const keyProvider = new AleoKeyProvider();
272
120
  * const recordProvider = new NetworkRecordProvider(account, networkClient);
273
121
  *
274
122
  * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
275
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
123
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
276
124
  * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
277
125
  *
278
126
  * // Keys can also be fetched manually
@@ -302,18 +150,30 @@ declare class AleoKeyProvider implements FunctionKeyProvider {
302
150
  *
303
151
  * @example
304
152
  * // Create a new AleoKeyProvider
305
- * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
153
+ * const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
306
154
  * const keyProvider = new AleoKeyProvider();
307
155
  * const recordProvider = new NetworkRecordProvider(account, networkClient);
308
156
  *
309
157
  * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
310
- * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
158
+ * const programManager = new ProgramManager("https://api.provable.com/v2", keyProvider, recordProvider);
311
159
  * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
312
160
  *
313
161
  * // Keys can also be fetched manually
314
162
  * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");
315
163
  */
316
164
  transferKeys(visibility: string): Promise<FunctionKeyPair>;
165
+ /**
166
+ * Returns the proving and verifying keys for the transfer_public function.
167
+ *
168
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the transfer_public function
169
+ */
170
+ transferPublicKeys(): Promise<FunctionKeyPair>;
171
+ /**
172
+ * Returns the proving and verifying keys for the inclusion proof.
173
+ *
174
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion proof.
175
+ */
176
+ inclusionKeys(): Promise<FunctionKeyPair>;
317
177
  /**
318
178
  * Returns the proving and verifying keys for the join function in the credits.aleo program
319
179
  *
@@ -346,4 +206,4 @@ declare class AleoKeyProvider implements FunctionKeyProvider {
346
206
  getVerifyingKey(verifierUri: string): Promise<VerifyingKey>;
347
207
  unBondPublicKeys(): Promise<FunctionKeyPair>;
348
208
  }
349
- export { AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, CachedKeyPair, FunctionKeyPair, FunctionKeyProvider, KeySearchParams };
209
+ export { AleoKeyProvider, AleoKeyProviderInitParams, AleoKeyProviderParams };
@@ -1,5 +1,7 @@
1
- import { CachedKeyPair, FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider.js";
2
- import { ProvingKey, VerifyingKey } from "./wasm.js";
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";
3
5
  /**
4
6
  * Search parameters for the offline key provider. This class implements the KeySearchParams interface and includes
5
7
  * a convenience method for creating a new instance of this class for each function of the credits.aleo program.
@@ -32,7 +34,7 @@ declare class OfflineSearchParams implements KeySearchParams {
32
34
  */
33
35
  static bondValidatorKeyParams(): OfflineSearchParams;
34
36
  /**
35
- * Create a new OfflineSearchParams instance for the claim_unbond_public function of the
37
+ * Create a new OfflineSearchParams instance for the claim_unbond_public function of the credits.aleo program.
36
38
  */
37
39
  static claimUnbondPublicKeyParams(): OfflineSearchParams;
38
40
  /**
@@ -132,12 +134,13 @@ declare class OfflineSearchParams implements KeySearchParams {
132
134
  * const offlineExecuteTx = <Transaction>await this.buildExecutionTransaction("hello_hello.aleo", "hello", 1, false, ["5u32", "5u32"], undefined, offlineSearchParams, undefined, undefined, undefined, undefined, offlineQuery, program);
133
135
  *
134
136
  * // Broadcast the transaction later on a machine with internet access
135
- * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
137
+ * const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
136
138
  * const txId = await networkClient.broadcastTransaction(offlineExecuteTx);
137
139
  */
138
140
  declare class OfflineKeyProvider implements FunctionKeyProvider {
139
141
  cache: Map<string, CachedKeyPair>;
140
142
  constructor();
143
+ keyStore(): Promise<KeyStore | undefined>;
141
144
  /**
142
145
  * Get bond_public function keys from the credits.aleo program. The keys must be cached prior to calling this
143
146
  * method for it to work.
@@ -212,6 +215,12 @@ declare class OfflineKeyProvider implements FunctionKeyProvider {
212
215
  * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
213
216
  */
214
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>;
215
224
  /**
216
225
  * Get join function keys from the credits.aleo program. The keys must be cached prior to calling this
217
226
  * method for it to work.
@@ -287,6 +296,14 @@ declare class OfflineKeyProvider implements FunctionKeyProvider {
287
296
  * @param provingKey
288
297
  */
289
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;
290
307
  /**
291
308
  * Insert the proving and verifying keys for the join function into the cache. Only the proving key needs
292
309
  * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
@@ -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";
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
+ }
@@ -0,0 +1,4 @@
1
+ export interface CryptoBoxPubKey {
2
+ key_id: string;
3
+ public_key: string;
4
+ }
@@ -0,0 +1,4 @@
1
+ export interface EncryptedProvingRequest {
2
+ key_id: string;
3
+ ciphertext: string;
4
+ }