@provablehq/sdk 0.9.9 → 0.9.10-testnet-rc

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.
@@ -32,3 +32,4 @@ export declare const PRIVATE_TO_PUBLIC_TRANSFER: Set<string>;
32
32
  export declare const PUBLIC_TRANSFER: Set<string>;
33
33
  export declare const PUBLIC_TRANSFER_AS_SIGNER: Set<string>;
34
34
  export declare const PUBLIC_TO_PRIVATE_TRANSFER: Set<string>;
35
+ export declare const RECORD_DOMAIN = "RecordScannerV0";
@@ -146,6 +146,12 @@ interface FunctionKeyProvider {
146
146
  * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
147
147
  */
148
148
  feePublicKeys(): Promise<FunctionKeyPair>;
149
+ /**
150
+ * Get keys for the inclusion proof.
151
+ *
152
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
153
+ */
154
+ inclusionKeys(): Promise<FunctionKeyPair>;
149
155
  /**
150
156
  * Get join function keys from the credits.aleo program
151
157
  *
@@ -314,6 +320,18 @@ declare class AleoKeyProvider implements FunctionKeyProvider {
314
320
  * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");
315
321
  */
316
322
  transferKeys(visibility: string): Promise<FunctionKeyPair>;
323
+ /**
324
+ * Returns the proving and verifying keys for the transfer_public function.
325
+ *
326
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the transfer_public function
327
+ */
328
+ transferPublicKeys(): Promise<FunctionKeyPair>;
329
+ /**
330
+ * Returns the proving and verifying keys for the inclusion proof.
331
+ *
332
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion proof.
333
+ */
334
+ inclusionKeys(): Promise<FunctionKeyPair>;
317
335
  /**
318
336
  * Returns the proving and verifying keys for the join function in the credits.aleo program
319
337
  *
@@ -5,6 +5,7 @@
5
5
  * @example
6
6
  * const recordsResponseFilter: RecordsResponseFilter = {
7
7
  * block_height: true,
8
+ * block_timestamp: true,
8
9
  * checksum: true,
9
10
  * commitment: true,
10
11
  * record_ciphertext: true,
@@ -14,6 +15,7 @@
14
15
  * owner: true,
15
16
  * program_name: true,
16
17
  * record_name: true,
18
+ * sender_ciphertext: true,
17
19
  * transaction_id: true,
18
20
  * transition_id: true,
19
21
  * transaction_index: true,
@@ -21,10 +23,12 @@
21
23
  * }
22
24
  */
23
25
  export type RecordsResponseFilter = {
24
- blockHeight?: boolean;
26
+ block_height?: boolean;
27
+ block_timestamp?: boolean;
25
28
  checksum?: boolean;
26
29
  commitment?: boolean;
27
30
  record_ciphertext?: boolean;
31
+ sender_ciphertext?: boolean;
28
32
  function_name?: boolean;
29
33
  nonce?: boolean;
30
34
  output_index?: boolean;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * RegistrationResponse is a type that represents a response from a record scanning service.
2
+ * RegistrationResponse is a type that represents a response from a record scanning service's registration endpoint.
3
3
  *
4
4
  * @example
5
5
  * const registrationResponse: RegistrationResponse = {
@@ -8,7 +8,7 @@
8
8
  * status: "pending",
9
9
  * }
10
10
  */
11
- interface RegistrationResponse {
11
+ export interface RegistrationResponse {
12
12
  uuid: string;
13
13
  job_id?: string;
14
14
  status?: string;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * StatusResponse is a type that represents a response from a record scanning service's status endpoint.
3
+ *
4
+ * @example
5
+ * const statusResponse: StatusResponse = {
6
+ * synced: true,
7
+ * percentage: 100,
8
+ * }
9
+ */
10
+ export interface StatusResponse {
11
+ synced: boolean;
12
+ percentage: number;
13
+ }
@@ -1,6 +1,6 @@
1
1
  import './node-polyfill.js';
2
- export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KEY_STORE, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TO_PRIVATE_TRANSFER, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, ProgramManager, VALID_TRANSFER_TYPES, initializeWasm, logAndThrow } from './browser.js';
3
- export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Boolean, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, ExecutionResponse, Field, Execution as FunctionExecution, GraphKey, Group, I128, I16, I32, I64, I8, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U128, U16, U32, U64, U8, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/testnet.js';
2
+ export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KEY_STORE, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TO_PRIVATE_TRANSFER, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, ProgramManager, RECORD_DOMAIN, RecordScanner, VALID_TRANSFER_TYPES, initializeWasm, logAndThrow } from './browser.js';
3
+ export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Boolean, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, ExecutionResponse, Field, Execution as FunctionExecution, GraphKey, Group, I128, I16, I32, I64, I8, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U128, U16, U32, U64, U8, VerifyingKey, ViewKey, getOrInitConsensusVersionTestHeights, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/testnet.js';
4
4
  import 'core-js/proposals/json-parse-with-source.js';
5
5
  import 'node:crypto';
6
6
  import 'node:fs';
@@ -212,6 +212,12 @@ declare class OfflineKeyProvider implements FunctionKeyProvider {
212
212
  * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
213
213
  */
214
214
  feePublicKeys(): Promise<FunctionKeyPair>;
215
+ /**
216
+ * Get the inclusion prover keys from. The keys must be cached prior to calling this method for it to work.
217
+ *
218
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion prover
219
+ */
220
+ inclusionKeys(): Promise<FunctionKeyPair>;
215
221
  /**
216
222
  * Get join function keys from the credits.aleo program. The keys must be cached prior to calling this
217
223
  * method for it to work.
@@ -287,6 +293,14 @@ declare class OfflineKeyProvider implements FunctionKeyProvider {
287
293
  * @param provingKey
288
294
  */
289
295
  insertFeePublicKeys(provingKey: ProvingKey): void;
296
+ /**
297
+ * Insert the proving and verifying keys for the inclusion prover into the cache. Only the proving key needs
298
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
299
+ * that the keys match the expected checksum for the inclusion prover.
300
+ *
301
+ * @param provingKey
302
+ */
303
+ insertInclusionKeys(provingKey: ProvingKey): void;
290
304
  /**
291
305
  * Insert the proving and verifying keys for the join function into the cache. Only the proving key needs
292
306
  * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
@@ -120,6 +120,7 @@ declare class ProgramManager {
120
120
  host: string;
121
121
  networkClient: AleoNetworkClient;
122
122
  recordProvider: RecordProvider | undefined;
123
+ inclusionKeysLoaded: boolean;
123
124
  /** Create a new instance of the ProgramManager
124
125
  *
125
126
  * @param { string | undefined } host A host uri running the official Aleo API
@@ -1068,6 +1069,15 @@ declare class ProgramManager {
1068
1069
  * assert(isValid);
1069
1070
  */
1070
1071
  verifyExecution(executionResponse: ExecutionResponse, blockHeight: number, imports?: ImportedPrograms, importedVerifyingKeys?: ImportedVerifyingKeys): boolean;
1072
+ /**
1073
+ * Set the inclusion key bytes.
1074
+ *
1075
+ * @param {executionResponse} executionResponse The response from an offline function execution (via the `programManager.run` method)
1076
+ * @param {ImportedPrograms} imports The imported programs used in the execution. Specified as { "programName": "programSourceCode", ... }
1077
+ * @param {ImportedVerifyingKeys} importedVerifyingKeys The verifying keys in the execution. Specified as { "programName": [["functionName", "verifyingKey"], ...], ... }
1078
+ * @returns {boolean} True if the proof is valid, false otherwise
1079
+ *
1080
+
1071
1081
  /**
1072
1082
  * Create a program object from a program's source code
1073
1083
  *
@@ -0,0 +1,151 @@
1
+ import { EncryptedRecord } from "./models/record-provider/encryptedRecord";
2
+ import { OwnedFilter } from "./models/record-scanner/ownedFilter";
3
+ import { OwnedRecord } from "./models/record-provider/ownedRecord";
4
+ import { RecordProvider } from "./record-provider";
5
+ import { Field, ViewKey } from "./wasm";
6
+ import { RecordsFilter } from "./models/record-scanner/recordsFilter";
7
+ import { RegistrationResponse } from "./models/record-scanner/registrationResponse";
8
+ import { StatusResponse } from "./models/record-scanner/statusResponse";
9
+ type RecordScannerOptions = {
10
+ url: string;
11
+ apiKey?: string | {
12
+ header: string;
13
+ value: string;
14
+ };
15
+ };
16
+ /**
17
+ * RecordScanner is a RecordProvider implementation that uses the record scanner service to find records.
18
+ *
19
+ * @example
20
+ * const account = new Account({ privateKey: 'APrivateKey1...' });
21
+ *
22
+ * const recordScanner = new RecordScanner({ url: "https://record-scanner.aleo.org" });
23
+ * recordScanner.setAccount(account);
24
+ * recordScanner.setApiKey("your-api-key");
25
+ * const uuid = await recordScanner.register(0);
26
+ *
27
+ * const filter = {
28
+ * uuid,
29
+ * filter: {
30
+ * program: "credits.aleo",
31
+ * records: ["credits"],
32
+ * },
33
+ * responseFilter: {
34
+ * commitment: true,
35
+ * owner: true,
36
+ * tag: true,
37
+ * tag?: boolean;
38
+ * sender: true,
39
+ * spent: true,
40
+ * record_ciphertext: true,
41
+ * block_height: true;
42
+ * block_timestamp: true;
43
+ * output_index: true;
44
+ * record_name: true;
45
+ * function_name: true;
46
+ * program_name: true;
47
+ * transition_id: true;
48
+ * transaction_id: true;
49
+ * transaction_index: true;
50
+ * transition_index: true;
51
+ * },
52
+ * unspent: true,
53
+ * };
54
+ *
55
+ * const records = await recordScanner.findRecords(filter);
56
+ */
57
+ declare class RecordScanner implements RecordProvider {
58
+ readonly url: string;
59
+ private apiKey?;
60
+ private uuid?;
61
+ constructor(options: RecordScannerOptions);
62
+ /**
63
+ * Set the API key to use for the record scanner.
64
+ *
65
+ * @param {string} apiKey The API key to use for the record scanner.
66
+ */
67
+ setApiKey(apiKey: string | {
68
+ header: string;
69
+ value: string;
70
+ }): Promise<void>;
71
+ /**
72
+ * Set the UUID to use for the record scanner.
73
+ *
74
+ * @param {Field} uuid The UUID to use for the record scanner.
75
+ */
76
+ setUuid(uuidOrViewKey: Field | ViewKey): Promise<void>;
77
+ /**
78
+ * Register the account with the record scanner service.
79
+ *
80
+ * @param {number} startBlock The block height to start scanning from.
81
+ * @returns {Promise<RegistrationResponse>} The response from the record scanner service.
82
+ */
83
+ register(viewKey: ViewKey, startBlock: number): Promise<RegistrationResponse>;
84
+ /**
85
+ * Get encrypted records from the record scanner service.
86
+ *
87
+ * @param {RecordsFilter} recordsFilter The filter to use to find the records and filter the response.
88
+ * @returns {Promise<EncryptedRecord[]>} The encrypted records.
89
+ */
90
+ encryptedRecords(recordsFilter: RecordsFilter): Promise<EncryptedRecord[]>;
91
+ /**
92
+ * Check if a list of serial numbers exist in the record scanner service.
93
+ *
94
+ * @param {string[]} serialNumbers The serial numbers to check.
95
+ * @returns {Promise<Record<string, boolean>>} Map of Aleo Record serial numbers and whether they appeared in any inputs on chain. If boolean corresponding to the Serial Number has a true value, that Record is considered spent by the Aleo Network.
96
+ */
97
+ checkSerialNumbers(serialNumbers: string[]): Promise<Record<string, boolean>>;
98
+ /**
99
+ * Check if a list of tags exist in the record scanner service.
100
+ *
101
+ * @param {string[]} tags The tags to check.
102
+ * @returns {Promise<Record<string, boolean>>} Map of Aleo Record tags and whether they appeared in any inputs on chain. If boolean corresponding to the tag has a true value, that Record is considered spent by the Aleo Network.
103
+ */
104
+ checkTags(tags: string[]): Promise<Record<string, boolean>>;
105
+ /**
106
+ * Check the status of a record scanner indexing job.
107
+ *
108
+ * @param {string} jobId The job id to check.
109
+ * @returns {Promise<StatusResponse>} The status of the job.
110
+ */
111
+ checkStatus(): Promise<StatusResponse>;
112
+ /**
113
+ * Find a record in the record scanner service.
114
+ *
115
+ * @param {OwnedFilter} searchParameters The filter to use to find the record.
116
+ * @returns {Promise<OwnedRecord>} The record.
117
+ */
118
+ findRecord(searchParameters: OwnedFilter): Promise<OwnedRecord>;
119
+ /**
120
+ * Find records in the record scanner service.
121
+ *
122
+ * @param {OwnedFilter} filter The filter to use to find the records.
123
+ * @returns {Promise<OwnedRecord[]>} The records.
124
+ */
125
+ findRecords(filter: OwnedFilter): Promise<OwnedRecord[]>;
126
+ /**
127
+ * Find a credits record in the record scanner service.
128
+ *
129
+ * @param {number} microcredits The amount of microcredits to find.
130
+ * @param {OwnedFilter} searchParameters The filter to use to find the record.
131
+ * @returns {Promise<OwnedRecord>} The record.
132
+ */
133
+ findCreditsRecord(microcredits: number, searchParameters: OwnedFilter): Promise<OwnedRecord>;
134
+ /**
135
+ * Find credits records using a record scanning service.
136
+ *
137
+ * @param {number[]} microcreditAmounts The amounts of microcredits to find.
138
+ * @param {OwnedFilter} searchParameters The filter to use to find the records.
139
+ * @returns {Promise<OwnedRecord[]>} The records
140
+ */
141
+ findCreditsRecords(microcreditAmounts: number[], searchParameters: OwnedFilter): Promise<OwnedRecord[]>;
142
+ /**
143
+ * Wrapper function to make a request to the record scanner service and handle any errors.
144
+ *
145
+ * @param {Request} req The request to make.
146
+ * @returns {Promise<Response>} The response.
147
+ */
148
+ private request;
149
+ computeUUID(vk: ViewKey): Field;
150
+ }
151
+ export { RecordScanner };
@@ -1 +1 @@
1
- export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, Execution, ExecutionResponse, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, Metadata, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U8, U16, U32, U64, U128, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "@provablehq/wasm/testnet.js";
1
+ export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, Execution, ExecutionResponse, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, Metadata, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U8, U16, U32, U64, U128, VerifyingKey, ViewKey, initThreadPool, getOrInitConsensusVersionTestHeights, verifyFunctionExecution, } from "@provablehq/wasm/testnet.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@provablehq/sdk",
3
- "version": "0.9.9",
3
+ "version": "0.9.10-testnet-rc",
4
4
  "description": "A Software Development Kit (SDK) for Zero-Knowledge Transactions",
5
5
  "collaborators": [
6
6
  "The Provable Team"
@@ -30,7 +30,7 @@
30
30
  ],
31
31
  "scripts": {
32
32
  "build": "rimraf dist && rollup -c rollup.config.js",
33
- "test": "rimraf tmp && rollup -c rollup.test.js && mocha tmp/**/*.test.js --timeout 60000"
33
+ "test": "rimraf tmp && rollup -c rollup.test.js && mocha tmp/**/*.test.js --timeout 60000 && RUN_SKIPPED=true mocha tmp/**/wasm.test.js --timeout 60000 --grep Consensus"
34
34
  },
35
35
  "repository": {
36
36
  "type": "git",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "homepage": "https://github.com/ProvableHQ/sdk#readme",
49
49
  "dependencies": {
50
- "@provablehq/wasm": "^0.9.9",
50
+ "@provablehq/wasm": "^0.9.10-testnet-rc",
51
51
  "comlink": "^4.4.2",
52
52
  "core-js": "^3.40.0",
53
53
  "mime": "^4.0.6",