@provablehq/sdk 0.9.1 → 0.9.3

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 (83) hide show
  1. package/dist/mainnet/account.d.ts +36 -1
  2. package/dist/mainnet/browser.d.ts +35 -35
  3. package/dist/mainnet/browser.js +52 -4
  4. package/dist/mainnet/browser.js.map +1 -1
  5. package/dist/mainnet/constants.d.ts +1 -1
  6. package/dist/mainnet/function-key-provider.d.ts +2 -2
  7. package/dist/mainnet/managed-worker.d.ts +1 -1
  8. package/dist/mainnet/models/authorization.d.ts +6 -0
  9. package/dist/mainnet/models/blockJSON.d.ts +3 -3
  10. package/dist/mainnet/models/confirmed_transaction.d.ts +2 -2
  11. package/dist/mainnet/models/deployment/deploymentObject.d.ts +1 -1
  12. package/dist/mainnet/models/execution/executionJSON.d.ts +1 -1
  13. package/dist/mainnet/models/execution/executionObject.d.ts +1 -1
  14. package/dist/mainnet/models/functionObject.d.ts +1 -1
  15. package/dist/mainnet/models/input/inputObject.d.ts +2 -2
  16. package/dist/mainnet/models/inputID.d.ts +4 -0
  17. package/dist/mainnet/models/output/outputObject.d.ts +2 -2
  18. package/dist/mainnet/models/owner/ownerObject.d.ts +1 -1
  19. package/dist/mainnet/models/plaintext/array.d.ts +2 -2
  20. package/dist/mainnet/models/plaintext/plaintext.d.ts +4 -4
  21. package/dist/mainnet/models/plaintext/struct.d.ts +2 -2
  22. package/dist/mainnet/models/request.d.ts +14 -0
  23. package/dist/mainnet/models/transaction/transactionJSON.d.ts +3 -3
  24. package/dist/mainnet/models/transaction/transactionObject.d.ts +3 -3
  25. package/dist/mainnet/models/transition/transitionJSON.d.ts +2 -2
  26. package/dist/mainnet/models/transition/transitionObject.d.ts +3 -3
  27. package/dist/mainnet/network-client.d.ts +5 -19
  28. package/dist/mainnet/node-polyfill.d.ts +5 -5
  29. package/dist/mainnet/node-polyfill.js.map +1 -1
  30. package/dist/mainnet/node.d.ts +2 -2
  31. package/dist/mainnet/node.js +2 -2
  32. package/dist/mainnet/offline-key-provider.d.ts +2 -2
  33. package/dist/mainnet/{program-manager-DMDKstZ8.js → program-manager-BfZnPCKl.js} +119 -18
  34. package/dist/mainnet/program-manager-BfZnPCKl.js.map +1 -0
  35. package/dist/mainnet/program-manager.d.ts +105 -9
  36. package/dist/mainnet/record-provider.d.ts +3 -3
  37. package/dist/mainnet/wasm.d.ts +1 -1
  38. package/dist/mainnet/worker.d.ts +2 -2
  39. package/dist/mainnet/worker.js +1 -1
  40. package/dist/mainnet/worker.js.map +1 -1
  41. package/dist/testnet/account.d.ts +36 -1
  42. package/dist/testnet/browser.d.ts +35 -35
  43. package/dist/testnet/browser.js +52 -4
  44. package/dist/testnet/browser.js.map +1 -1
  45. package/dist/testnet/constants.d.ts +1 -1
  46. package/dist/testnet/function-key-provider.d.ts +2 -2
  47. package/dist/testnet/managed-worker.d.ts +1 -1
  48. package/dist/testnet/models/authorization.d.ts +6 -0
  49. package/dist/testnet/models/blockJSON.d.ts +3 -3
  50. package/dist/testnet/models/confirmed_transaction.d.ts +2 -2
  51. package/dist/testnet/models/deployment/deploymentObject.d.ts +1 -1
  52. package/dist/testnet/models/execution/executionJSON.d.ts +1 -1
  53. package/dist/testnet/models/execution/executionObject.d.ts +1 -1
  54. package/dist/testnet/models/functionObject.d.ts +1 -1
  55. package/dist/testnet/models/input/inputObject.d.ts +2 -2
  56. package/dist/testnet/models/inputID.d.ts +4 -0
  57. package/dist/testnet/models/output/outputObject.d.ts +2 -2
  58. package/dist/testnet/models/owner/ownerObject.d.ts +1 -1
  59. package/dist/testnet/models/plaintext/array.d.ts +2 -2
  60. package/dist/testnet/models/plaintext/plaintext.d.ts +4 -4
  61. package/dist/testnet/models/plaintext/struct.d.ts +2 -2
  62. package/dist/testnet/models/request.d.ts +14 -0
  63. package/dist/testnet/models/transaction/transactionJSON.d.ts +3 -3
  64. package/dist/testnet/models/transaction/transactionObject.d.ts +3 -3
  65. package/dist/testnet/models/transition/transitionJSON.d.ts +2 -2
  66. package/dist/testnet/models/transition/transitionObject.d.ts +3 -3
  67. package/dist/testnet/network-client.d.ts +5 -19
  68. package/dist/testnet/node-polyfill.d.ts +5 -5
  69. package/dist/testnet/node-polyfill.js.map +1 -1
  70. package/dist/testnet/node.d.ts +2 -2
  71. package/dist/testnet/node.js +2 -2
  72. package/dist/testnet/offline-key-provider.d.ts +2 -2
  73. package/dist/testnet/{program-manager-BTHjM8b7.js → program-manager-kuhVcNPN.js} +119 -18
  74. package/dist/testnet/program-manager-kuhVcNPN.js.map +1 -0
  75. package/dist/testnet/program-manager.d.ts +105 -9
  76. package/dist/testnet/record-provider.d.ts +3 -3
  77. package/dist/testnet/wasm.d.ts +1 -1
  78. package/dist/testnet/worker.d.ts +2 -2
  79. package/dist/testnet/worker.js +1 -1
  80. package/dist/testnet/worker.js.map +1 -1
  81. package/package.json +2 -2
  82. package/dist/mainnet/program-manager-DMDKstZ8.js.map +0 -1
  83. package/dist/testnet/program-manager-BTHjM8b7.js.map +0 -1
@@ -1,9 +1,9 @@
1
- import { Account } from "./account";
2
- import { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports } from "./network-client";
3
- import { ImportedPrograms, ImportedVerifyingKeys } from "./models/imports";
4
- import { RecordProvider, RecordSearchParams } from "./record-provider";
5
- import { FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider";
6
- import { ExecutionResponse, OfflineQuery, RecordPlaintext, PrivateKey, Program, ProvingKey, VerifyingKey, Transaction } from "./wasm";
1
+ import { Account } from "./account.js";
2
+ import { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports } from "./network-client.js";
3
+ import { ImportedPrograms, ImportedVerifyingKeys } from "./models/imports.js";
4
+ import { RecordProvider, RecordSearchParams } from "./record-provider.js";
5
+ import { FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider.js";
6
+ import { Authorization, ExecutionResponse, OfflineQuery, RecordPlaintext, PrivateKey, Program, ProvingKey, VerifyingKey, Transaction } from "./wasm.js";
7
7
  /**
8
8
  * Represents the options for executing a transaction in the Aleo network.
9
9
  * This interface is used to specify the parameters required for building and submitting an execution transaction.
@@ -39,6 +39,40 @@ interface ExecuteOptions {
39
39
  program?: string | Program;
40
40
  imports?: ProgramImports;
41
41
  }
42
+ /**
43
+ * Options for building an Authorization for a function.
44
+ *
45
+ * @property programName {string} Name of the program containing the function to build the authorization for.
46
+ * @property functionName {string} Name of the function name to build the authorization for.
47
+ * @property inputs {string[]} The inputs to the function.
48
+ * @property programSource {string | Program} The optional source code for the program to build an execution for.
49
+ * @property privateKey {PrivateKey} Optional private key to use to build the authorization.
50
+ * @property programImports {ProgramImports} The other programs the program imports.
51
+ */
52
+ interface AuthorizationOptions {
53
+ programName: string;
54
+ functionName: string;
55
+ inputs: string[];
56
+ programSource?: string | Program;
57
+ privateKey?: PrivateKey;
58
+ programImports?: ProgramImports;
59
+ }
60
+ /**
61
+ * Options for executing a fee authorization.
62
+ *
63
+ * @property deploymentOrExecutionId {string} The id of a previously built Execution or Authorization.
64
+ * @property baseFeeCredits {number} The number of Aleo Credits to pay for the base fee.
65
+ * @property priorityFeeCredits {number} The number of Aleo Credits to pay for the priority fee.
66
+ * @property privateKey {PrivateKey} Optional private key to specify for the authorization.
67
+ * @property feeRecord {RecordPlaintext} A record to specify to pay the private fee. If this is specified a `fee_private` authorization will be built.
68
+ */
69
+ interface FeeAuthorizationOptions {
70
+ deploymentOrExecutionId: string;
71
+ baseFeeCredits: number;
72
+ priorityFeeCredits?: number;
73
+ privateKey?: PrivateKey;
74
+ feeRecord?: RecordPlaintext;
75
+ }
42
76
  /**
43
77
  * The ProgramManager class is used to execute and deploy programs on the Aleo network and create value transfers.
44
78
  */
@@ -168,7 +202,7 @@ declare class ProgramManager {
168
202
  * /// Import the mainnet version of the sdk.
169
203
  * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
170
204
  *
171
- * // Create a new NetworkClient, KeyProvider, and RecordProvider
205
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
172
206
  * const keyProvider = new AleoKeyProvider();
173
207
  * const recordProvider = new NetworkRecordProvider(account, networkClient);
174
208
  * keyProvider.useCache = true;
@@ -200,7 +234,7 @@ declare class ProgramManager {
200
234
  * /// Import the mainnet version of the sdk.
201
235
  * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
202
236
  *
203
- * // Create a new NetworkClient, KeyProvider, and RecordProvider using official Aleo record, key, and network providers
237
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
204
238
  * const keyProvider = new AleoKeyProvider();
205
239
  * const recordProvider = new NetworkRecordProvider(account, networkClient);
206
240
  * keyProvider.useCache = true;
@@ -228,6 +262,68 @@ declare class ProgramManager {
228
262
  * }, 10000);
229
263
  */
230
264
  buildExecutionTransaction(options: ExecuteOptions): Promise<Transaction>;
265
+ /**
266
+ * Builds a SnarkVM `Authorization` for a specific function.
267
+ *
268
+ * @param {AuthorizationOptions} options - The options for building the `Authorization`
269
+ * @returns {Promise<Authorization>} - A promise that resolves to an `Authorization` or throws an Error.
270
+ *
271
+ * @example
272
+ * /// Import the mainnet version of the sdk.
273
+ * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
274
+ *
275
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
276
+ * const keyProvider = new AleoKeyProvider();
277
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
278
+ * keyProvider.useCache = true;
279
+ *
280
+ * // Initialize a ProgramManager with the key and record providers.
281
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
282
+ *
283
+ * // Build the `Authorization`.
284
+ * const authorization = await programManager.buildAuthorization({
285
+ * programName: "credits.aleo",
286
+ * functionName: "transfer_public",
287
+ * inputs: [
288
+ * "aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
289
+ * "10000000u64",
290
+ * ],
291
+ * });
292
+ */
293
+ buildAuthorization(options: AuthorizationOptions): Promise<Authorization>;
294
+ /**
295
+ * Builds a SnarkVM fee `Authorization` for `credits.aleo/fee_private` or `credits.aleo/fee_public`. If a record is provided `fee_private` will be executed, otherwise `fee_public` will be executed.
296
+ *
297
+ * @param {FeeAuthorizationOptions} options - The options for building the `Authorization`.
298
+ * @returns {Promise<Authorization>} - A promise that resolves to an `Authorization` or throws an Error.
299
+ *
300
+ * @example
301
+ * /// Import the mainnet version of the sdk.
302
+ * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
303
+ *
304
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
305
+ * const keyProvider = new AleoKeyProvider();
306
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
307
+ * keyProvider.useCache = true;
308
+ *
309
+ * // Initialize a ProgramManager with the key and record providers.
310
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
311
+ *
312
+ * // Build a credits.aleo/fee_public `Authorization`.
313
+ * const feePublicAuthorization = await programManager.authorizeFee({
314
+ * deploymentOrExecutionId: "2423957656946557501636078245035919227529640894159332581642187482178647335171field",
315
+ * baseFeeCredits: 0.1,
316
+ * });
317
+ *
318
+ * // Build a credits.aleo/fee_private `Authorization`.
319
+ * const record = "{ owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private, microcredits: 1500000000000000u64.private, _nonce: 3077450429259593211617823051143573281856129402760267155982965992208217472983group.public }";
320
+ * const feePrivateAuthorization = await programManager.authorizeFee({
321
+ * deploymentOrExecutionId: "2423957656946557501636078245035919227529640894159332581642187482178647335171field",
322
+ * baseFeeCredits: 0.1,
323
+ * feeRecord: record,
324
+ * });
325
+ */
326
+ buildFeeAuthorization(options: FeeAuthorizationOptions): Promise<Authorization>;
231
327
  /**
232
328
  * Builds an execution transaction for submission to the Aleo network.
233
329
  *
@@ -891,4 +987,4 @@ declare class ProgramManager {
891
987
  verifyProgram(program: string): boolean;
892
988
  getCreditsRecord(amount: number, nonces: string[], record?: RecordPlaintext | string, params?: RecordSearchParams): Promise<RecordPlaintext>;
893
989
  }
894
- export { ProgramManager };
990
+ export { ProgramManager, AuthorizationOptions, FeeAuthorizationOptions, ExecuteOptions };
@@ -1,6 +1,6 @@
1
- import { RecordPlaintext } from "./wasm";
2
- import { Account } from "./account";
3
- import { AleoNetworkClient } from "./network-client";
1
+ import { RecordPlaintext } from "./wasm.js";
2
+ import { Account } from "./account.js";
3
+ import { AleoNetworkClient } from "./network-client.js";
4
4
  /**
5
5
  * Interface for record search parameters. This allows for arbitrary search parameters to be passed to record provider
6
6
  * implementations.
@@ -1 +1 @@
1
- export { Address, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, Execution, ExecutionResponse, Field, Group, OfflineQuery, Metadata, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager, ProvingKey, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "@provablehq/wasm/mainnet.js";
1
+ export { Address, Authorization, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, Execution, ExecutionResponse, Field, Group, OfflineQuery, Metadata, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager, ProvingKey, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "@provablehq/wasm/mainnet.js";
@@ -1,5 +1,5 @@
1
- import "./polyfill/shared";
2
- import { PrivateKey } from "./browser";
1
+ import "./polyfill/shared.js";
2
+ import { PrivateKey } from "./browser.js";
3
3
  export interface WorkerAPI {
4
4
  run: (localProgram: string, aleoFunction: string, inputs: string[], privateKey: string) => Promise<{
5
5
  outputs: any;
@@ -1,6 +1,6 @@
1
1
  import 'core-js/proposals/json-parse-with-source.js';
2
2
  import { initThreadPool, PrivateKey, verifyFunctionExecution } from '@provablehq/wasm/mainnet.js';
3
- import { P as ProgramManager, A as AleoKeyProvider, a as AleoKeyProviderParams } from './program-manager-DMDKstZ8.js';
3
+ import { P as ProgramManager, A as AleoKeyProvider, a as AleoKeyProviderParams } from './program-manager-BfZnPCKl.js';
4
4
  import { expose } from 'comlink';
5
5
 
6
6
  await initThreadPool();
@@ -1 +1 @@
1
- {"version":3,"file":"worker.js","sources":["../../src/worker.ts"],"sourcesContent":["import \"./polyfill/shared\";\nimport {initThreadPool, ProgramManager, PrivateKey, verifyFunctionExecution, FunctionKeyPair} from \"./browser\";\nimport { AleoKeyProvider, AleoKeyProviderParams} from \"./function-key-provider\";\nimport { expose } from \"comlink\";\n\nawait initThreadPool();\n\nconst defaultHost = \"https://api.explorer.provable.com/v1\";\nconst keyProvider = new AleoKeyProvider();\nconst programManager = new ProgramManager(\n defaultHost,\n keyProvider,\n undefined\n);\n\nkeyProvider.useCache(true);\n\nlet lastLocalProgram: string = \"\";\n\nexport interface WorkerAPI {\n run: (\n localProgram: string,\n aleoFunction: string,\n inputs: string[],\n privateKey: string\n ) => Promise<{ outputs: any; execution: string } | string>;\n\n getPrivateKey: () => Promise<PrivateKey>;\n}\nasync function run(\n localProgram: string,\n aleoFunction: string,\n inputs: string[],\n privateKey: string,\n proveExecution = false\n) {\n console.log(\"Web worker: Executing function locally...\");\n const startTime = performance.now();\n\n // Ensure the program is valid and that it contains the function specified\n let program;\n\n try {\n program = programManager.createProgramFromSource(localProgram);\n } catch (e) {\n throw new Error(\"Error creating program from source\");\n }\n\n const program_id = program.id();\n if (!program.hasFunction(aleoFunction)) {\n throw new Error(`Program ${program_id} does not contain function ${aleoFunction}`);\n }\n const cacheKey = `${program_id}:${aleoFunction}`;\n\n\n // Get the program imports\n let imports;\n\n try {\n imports = await programManager.networkClient.getProgramImports(\n localProgram\n );\n } catch (e) {\n throw new Error(\"Error getting program imports\");\n }\n\n // Get the proving and verifying keys for the function\n if (lastLocalProgram !== localProgram) {\n const keys = <FunctionKeyPair>await programManager.synthesizeKeys(\n localProgram,\n aleoFunction,\n inputs,\n PrivateKey.from_string(privateKey)\n );\n programManager.keyProvider.cacheKeys(cacheKey, keys);\n lastLocalProgram = localProgram;\n }\n\n // Pass the cache key to the execute function\n const keyParams = new AleoKeyProviderParams({\n cacheKey: cacheKey,\n });\n\n // Execute the function locally\n const response = await programManager.run(\n localProgram,\n aleoFunction,\n inputs,\n proveExecution,\n imports,\n keyParams,\n undefined,\n undefined,\n PrivateKey.from_string(privateKey),\n );\n\n // Return the outputs to the main thread\n console.log(\n `Web worker: Local execution completed in ${\n performance.now() - startTime\n } ms`\n );\n const outputs = response.getOutputs();\n const execution = response.getExecution();\n let executionString = \"\";\n\n let keys;\n\n try {\n keys = keyProvider.getKeys(cacheKey);\n } catch (e) {\n throw new Error(\"Could not get verifying key\");\n }\n\n const verifyingKey = keys[1];\n\n if (execution) {\n verifyFunctionExecution(\n execution,\n verifyingKey,\n program,\n \"hello\"\n );\n executionString = execution.toString();\n console.log(\"Execution verified successfully: \" + execution);\n } else {\n executionString = \"\";\n }\n\n console.log(`Function execution response: ${outputs}`);\n\n return { outputs: outputs, execution: executionString };\n}\n\nasync function getPrivateKey() {\n const privateKey = new PrivateKey();\n return privateKey.to_string();\n}\n\nconst workerAPI = { run, getPrivateKey };\nexpose(workerAPI);\n"],"names":[],"mappings":";;;;;AAKA,MAAM,cAAc,EAAE;AAEtB,MAAM,WAAW,GAAG,sCAAsC;AAC1D,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE;AACzC,MAAM,cAAc,GAAG,IAAI,cAAc,CACrC,WAAW,EACX,WAAW,EACX,SAAS,CACZ;AAED,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC;AAE1B,IAAI,gBAA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AAG,EAAE,GAAG,EAAE,aAAa,EAAE;AACxC,MAAM,CAAC,SAAS,CAAC"}
1
+ {"version":3,"file":"worker.js","sources":["../../src/worker.ts"],"sourcesContent":["import \"./polyfill/shared.js\";\nimport {initThreadPool, ProgramManager, PrivateKey, verifyFunctionExecution, FunctionKeyPair} from \"./browser.js\";\nimport { AleoKeyProvider, AleoKeyProviderParams} from \"./function-key-provider.js\";\nimport { expose } from \"comlink\";\n\nawait initThreadPool();\n\nconst defaultHost = \"https://api.explorer.provable.com/v1\";\nconst keyProvider = new AleoKeyProvider();\nconst programManager = new ProgramManager(\n defaultHost,\n keyProvider,\n undefined\n);\n\nkeyProvider.useCache(true);\n\nlet lastLocalProgram: string = \"\";\n\nexport interface WorkerAPI {\n run: (\n localProgram: string,\n aleoFunction: string,\n inputs: string[],\n privateKey: string\n ) => Promise<{ outputs: any; execution: string } | string>;\n\n getPrivateKey: () => Promise<PrivateKey>;\n}\nasync function run(\n localProgram: string,\n aleoFunction: string,\n inputs: string[],\n privateKey: string,\n proveExecution = false\n) {\n console.log(\"Web worker: Executing function locally...\");\n const startTime = performance.now();\n\n // Ensure the program is valid and that it contains the function specified\n let program;\n\n try {\n program = programManager.createProgramFromSource(localProgram);\n } catch (e) {\n throw new Error(\"Error creating program from source\");\n }\n\n const program_id = program.id();\n if (!program.hasFunction(aleoFunction)) {\n throw new Error(`Program ${program_id} does not contain function ${aleoFunction}`);\n }\n const cacheKey = `${program_id}:${aleoFunction}`;\n\n\n // Get the program imports\n let imports;\n\n try {\n imports = await programManager.networkClient.getProgramImports(\n localProgram\n );\n } catch (e) {\n throw new Error(\"Error getting program imports\");\n }\n\n // Get the proving and verifying keys for the function\n if (lastLocalProgram !== localProgram) {\n const keys = <FunctionKeyPair>await programManager.synthesizeKeys(\n localProgram,\n aleoFunction,\n inputs,\n PrivateKey.from_string(privateKey)\n );\n programManager.keyProvider.cacheKeys(cacheKey, keys);\n lastLocalProgram = localProgram;\n }\n\n // Pass the cache key to the execute function\n const keyParams = new AleoKeyProviderParams({\n cacheKey: cacheKey,\n });\n\n // Execute the function locally\n const response = await programManager.run(\n localProgram,\n aleoFunction,\n inputs,\n proveExecution,\n imports,\n keyParams,\n undefined,\n undefined,\n PrivateKey.from_string(privateKey),\n );\n\n // Return the outputs to the main thread\n console.log(\n `Web worker: Local execution completed in ${\n performance.now() - startTime\n } ms`\n );\n const outputs = response.getOutputs();\n const execution = response.getExecution();\n let executionString = \"\";\n\n let keys;\n\n try {\n keys = keyProvider.getKeys(cacheKey);\n } catch (e) {\n throw new Error(\"Could not get verifying key\");\n }\n\n const verifyingKey = keys[1];\n\n if (execution) {\n verifyFunctionExecution(\n execution,\n verifyingKey,\n program,\n \"hello\"\n );\n executionString = execution.toString();\n console.log(\"Execution verified successfully: \" + execution);\n } else {\n executionString = \"\";\n }\n\n console.log(`Function execution response: ${outputs}`);\n\n return { outputs: outputs, execution: executionString };\n}\n\nasync function getPrivateKey() {\n const privateKey = new PrivateKey();\n return privateKey.to_string();\n}\n\nconst workerAPI = { run, getPrivateKey };\nexpose(workerAPI);\n"],"names":[],"mappings":";;;;;AAKA,MAAM,cAAc,EAAE;AAEtB,MAAM,WAAW,GAAG,sCAAsC;AAC1D,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE;AACzC,MAAM,cAAc,GAAG,IAAI,cAAc,CACrC,WAAW,EACX,WAAW,EACX,SAAS,CACZ;AAED,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC;AAE1B,IAAI,gBAAgB,GAAW,EAAE;AAYjC,eAAe,GAAG,CACd,YAAoB,EACpB,YAAoB,EACpB,MAAgB,EAChB,UAAkB,EAClB,cAAc,GAAG,KAAK,EAAA;AAEtB,IAAA,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC;AACxD,IAAA,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE;;AAGnC,IAAA,IAAI,OAAO;AAEX,IAAA,IAAI;AACA,QAAA,OAAO,GAAG,cAAc,CAAC,uBA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AAE,GAAG,SACxB,CAAK,GAAA,CAAA,CACR;AACD,IAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,EAAE;AACrC,IAAA,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,EAAE;IACzC,IAAI,eAAe,GAAG,EAAE;AAExB,IAAA,IAAI,IAAI;AAER,IAAA,IAAI;AACA,QAAA,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC;;IACtC,OAAO,CAAC,EAAE;AACR,QAAA,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC;;AAGlD,IAAA,MAAM,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;IAE5B,IAAI,SAAS,EAAE;QACX,uBAAuB,CACnB,SAAS,EACT,YAAY,EACZ,OAAO,EACP,OAAO,CACV;AACD,QAAA,eAAe,GAAG,SAAS,CAAC,QAAQ,EAAE;AACtC,QAAA,OAAO,CAAC,GAAG,CAAC,mCAAmC,GAAG,SAAS,CAAC;;SACzD;QACH,eAAe,GAAG,EAAE;;AAGxB,IAAA,OAAO,CAAC,GAAG,CAAC,gCAAgC,OAAO,CAAA,CAAE,CAAC;IAEtD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE;AAC3D;AAEA,eAAe,aAAa,GAAA;AACxB,IAAA,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE;AACnC,IAAA,OAAO,UAAU,CAAC,SAAS,EAAE;AACjC;AAEA,MAAM,SAAS,GAAG,EAAE,GAAG,EAAE,aAAa,EAAE;AACxC,MAAM,CAAC,SAAS,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Address, ComputeKey, PrivateKey, Signature, ViewKey, PrivateKeyCiphertext, RecordCiphertext, RecordPlaintext } from "./wasm";
1
+ import { Address, ComputeKey, Field, Group, PrivateKey, Signature, ViewKey, PrivateKeyCiphertext, RecordCiphertext, RecordPlaintext } from "./wasm.js";
2
2
  interface AccountParam {
3
3
  privateKey?: string;
4
4
  seed?: Uint8Array;
@@ -182,6 +182,41 @@ export declare class Account {
182
182
  * const decryptedRecords = account.decryptRecords(records);
183
183
  */
184
184
  decryptRecords(ciphertexts: string[]): RecordPlaintext[];
185
+ /**
186
+ * Generates a record view key from the account owner's view key and the record ciphertext.
187
+ * This key can be used to decrypt the record without revealing the account's view key.
188
+ * @param {RecordCiphertext | string} recordCiphertext The record ciphertext to generate the view key for
189
+ * @returns {Field} The record view key
190
+ *
191
+ * @example
192
+ * // Import the Account class
193
+ * import { Account } from "@provablehq/sdk/testnet.js";
194
+ *
195
+ * // Create an account object from a previously encrypted ciphertext and password.
196
+ * const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);
197
+ *
198
+ * // Generate a record view key from the account's view key and a record ciphertext
199
+ * const recordCiphertext = RecordCiphertext.fromString("your_record_ciphertext_here");
200
+ * const recordViewKey = account.generateRecordViewKey(recordCiphertext);
201
+ */
202
+ generateRecordViewKey(recordCiphertext: RecordCiphertext | string): Field;
203
+ /**
204
+ * Generates a transition view key from the account owner's view key and the transition public key.
205
+ * This key can be used to decrypt the private inputs and outputs of a the transition without
206
+ * revealing the account's view key.
207
+ * @param {string | Group} tpk The transition public key
208
+ * @returns {Field} The transition view key
209
+ *
210
+ * @example
211
+ * // Import the Account class
212
+ * import { Account } from "@provablehq/sdk/testnet.js";
213
+ *
214
+ * // Generate a transition view key from the account's view key and a transition public key
215
+ * const tpk = Group.fromString("your_transition_public_key_here");
216
+ *
217
+ * const transitionViewKey = account.generateTransitionViewKey(tpk);
218
+ */
219
+ generateTransitionViewKey(tpk: string | Group): Field;
185
220
  /**
186
221
  * Determines whether the account owns a ciphertext record.
187
222
  * @param {RecordCiphertext | string} ciphertext The record ciphertext to check ownership of
@@ -1,38 +1,38 @@
1
- import "./polyfill/shared";
2
- import { Account } from "./account";
3
- import { AleoNetworkClient, ProgramImports } from "./network-client";
4
- import { BlockJSON, Header, Metadata } from "./models/blockJSON";
5
- import { ConfirmedTransactionJSON } from "./models/confirmed_transaction";
6
- import { DeploymentJSON, VerifyingKeys } from "./models/deployment/deploymentJSON";
7
- import { DeploymentObject } from "./models/deployment/deploymentObject";
8
- import { ExecutionJSON, FeeExecutionJSON } from "./models/execution/executionJSON";
9
- import { ExecutionObject, FeeExecutionObject } from "./models/execution/executionObject";
10
- import { FinalizeJSON } from "./models/finalizeJSON";
11
- import { FunctionObject } from "./models/functionObject";
12
- import { ImportedVerifyingKeys, ImportedPrograms } from "./models/imports";
13
- import { InputJSON } from "./models/input/inputJSON";
14
- import { InputObject } from "./models/input/inputObject";
15
- import { OutputJSON } from "./models/output/outputJSON";
16
- import { OutputObject } from "./models/output/outputObject";
17
- import { OwnerJSON } from "./models/owner/ownerJSON";
18
- import { PlaintextArray } from "./models/plaintext/array";
19
- import { PlaintextLiteral } from "./models/plaintext/literal";
20
- import { PlaintextObject } from "./models/plaintext/plaintext";
21
- import { PlaintextStruct } from "./models/plaintext/struct";
22
- import { RatificationJSON } from "./models/ratification";
23
- import { SolutionsJSON, SolutionJSON, PartialSolutionJSON } from "./models/solution";
24
- import { TransactionJSON } from "./models/transaction/transactionJSON";
25
- import { TransactionObject } from "./models/transaction/transactionObject";
26
- import { TransitionJSON } from "./models/transition/transitionJSON";
27
- import { TransitionObject } from "./models/transition/transitionObject";
28
- import { AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, CachedKeyPair, FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider";
29
- import { OfflineKeyProvider, OfflineSearchParams } from "./offline-key-provider";
30
- import { BlockHeightSearch, NetworkRecordProvider, RecordProvider, RecordSearchParams } from "./record-provider";
1
+ import "./polyfill/shared.js";
2
+ import { Account } from "./account.js";
3
+ import { AleoNetworkClient, ProgramImports } from "./network-client.js";
4
+ import { BlockJSON, Header, Metadata } from "./models/blockJSON.js";
5
+ import { ConfirmedTransactionJSON } from "./models/confirmed_transaction.js";
6
+ import { DeploymentJSON, VerifyingKeys } from "./models/deployment/deploymentJSON.js";
7
+ import { DeploymentObject } from "./models/deployment/deploymentObject.js";
8
+ import { ExecutionJSON, FeeExecutionJSON } from "./models/execution/executionJSON.js";
9
+ import { ExecutionObject, FeeExecutionObject } from "./models/execution/executionObject.js";
10
+ import { FinalizeJSON } from "./models/finalizeJSON.js";
11
+ import { FunctionObject } from "./models/functionObject.js";
12
+ import { ImportedVerifyingKeys, ImportedPrograms } from "./models/imports.js";
13
+ import { InputJSON } from "./models/input/inputJSON.js";
14
+ import { InputObject } from "./models/input/inputObject.js";
15
+ import { OutputJSON } from "./models/output/outputJSON.js";
16
+ import { OutputObject } from "./models/output/outputObject.js";
17
+ import { OwnerJSON } from "./models/owner/ownerJSON.js";
18
+ import { PlaintextArray } from "./models/plaintext/array.js";
19
+ import { PlaintextLiteral } from "./models/plaintext/literal.js";
20
+ import { PlaintextObject } from "./models/plaintext/plaintext.js";
21
+ import { PlaintextStruct } from "./models/plaintext/struct.js";
22
+ import { RatificationJSON } from "./models/ratification.js";
23
+ import { SolutionsJSON, SolutionJSON, PartialSolutionJSON } from "./models/solution.js";
24
+ import { TransactionJSON } from "./models/transaction/transactionJSON.js";
25
+ import { TransactionObject } from "./models/transaction/transactionObject.js";
26
+ import { TransitionJSON } from "./models/transition/transitionJSON.js";
27
+ import { TransitionObject } from "./models/transition/transitionObject.js";
28
+ import { AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, CachedKeyPair, FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider.js";
29
+ import { OfflineKeyProvider, OfflineSearchParams } from "./offline-key-provider.js";
30
+ import { BlockHeightSearch, NetworkRecordProvider, RecordProvider, RecordSearchParams } from "./record-provider.js";
31
31
  declare function initializeWasm(): Promise<void>;
32
- export { createAleoWorker } from "./managed-worker";
33
- export { ProgramManager } from "./program-manager";
34
- export { logAndThrow } from "./utils";
35
- export { Address, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, Execution as FunctionExecution, ExecutionResponse, Field, Group, OfflineQuery, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Signature, Scalar, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "./wasm";
32
+ export { createAleoWorker } from "./managed-worker.js";
33
+ export { ProgramManager } from "./program-manager.js";
34
+ export { logAndThrow } from "./utils.js";
35
+ export { Address, Authorization, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, Execution as FunctionExecution, ExecutionRequest, ExecutionResponse, EncryptionToolkit, Field, Group, OfflineQuery, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Signature, Scalar, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "./wasm.js";
36
36
  export { initializeWasm };
37
- export { Key, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, VALID_TRANSFER_TYPES, } from "./constants";
37
+ export { Key, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, VALID_TRANSFER_TYPES, } from "./constants.js";
38
38
  export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, CachedKeyPair, ConfirmedTransactionJSON, DeploymentJSON, DeploymentObject, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, RatificationJSON, RecordProvider, RecordSearchParams, SolutionJSON, SolutionsJSON, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, VerifyingKeys, };
@@ -1,8 +1,8 @@
1
1
  import 'core-js/proposals/json-parse-with-source.js';
2
- import { ViewKey, ComputeKey, Address, PrivateKeyCiphertext, PrivateKey, RecordCiphertext, ProvingKey, VerifyingKey } from '@provablehq/wasm/testnet.js';
3
- export { Address, BHP1024, BHP256, BHP512, BHP768, Ciphertext, ComputeKey, ExecutionResponse, Field, Execution as FunctionExecution, Group, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/testnet.js';
4
- import { C as CREDITS_PROGRAM_KEYS, c as PRIVATE_TRANSFER, d as PRIVATE_TO_PUBLIC_TRANSFER, f as PUBLIC_TRANSFER, g as PUBLIC_TRANSFER_AS_SIGNER, h as PUBLIC_TO_PRIVATE_TRANSFER, l as logAndThrow } from './program-manager-BTHjM8b7.js';
5
- export { A as AleoKeyProvider, a as AleoKeyProviderParams, b as AleoNetworkClient, K as KEY_STORE, e as PRIVATE_TRANSFER_TYPES, P as ProgramManager, V as VALID_TRANSFER_TYPES } from './program-manager-BTHjM8b7.js';
2
+ import { ViewKey, ComputeKey, Address, PrivateKeyCiphertext, PrivateKey, RecordCiphertext, EncryptionToolkit, Group, ProvingKey, VerifyingKey } from '@provablehq/wasm/testnet.js';
3
+ export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, ExecutionResponse, Field, Execution as FunctionExecution, Group, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/testnet.js';
4
+ import { C as CREDITS_PROGRAM_KEYS, c as PRIVATE_TRANSFER, d as PRIVATE_TO_PUBLIC_TRANSFER, f as PUBLIC_TRANSFER, g as PUBLIC_TRANSFER_AS_SIGNER, h as PUBLIC_TO_PRIVATE_TRANSFER, l as logAndThrow } from './program-manager-kuhVcNPN.js';
5
+ export { A as AleoKeyProvider, a as AleoKeyProviderParams, b as AleoNetworkClient, K as KEY_STORE, e as PRIVATE_TRANSFER_TYPES, P as ProgramManager, V as VALID_TRANSFER_TYPES } from './program-manager-kuhVcNPN.js';
6
6
  import { wrap } from 'comlink';
7
7
 
8
8
  /**
@@ -230,6 +230,54 @@ class Account {
230
230
  decryptRecords(ciphertexts) {
231
231
  return ciphertexts.map((ciphertext) => this._viewKey.decrypt(ciphertext));
232
232
  }
233
+ /**
234
+ * Generates a record view key from the account owner's view key and the record ciphertext.
235
+ * This key can be used to decrypt the record without revealing the account's view key.
236
+ * @param {RecordCiphertext | string} recordCiphertext The record ciphertext to generate the view key for
237
+ * @returns {Field} The record view key
238
+ *
239
+ * @example
240
+ * // Import the Account class
241
+ * import { Account } from "@provablehq/sdk/testnet.js";
242
+ *
243
+ * // Create an account object from a previously encrypted ciphertext and password.
244
+ * const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);
245
+ *
246
+ * // Generate a record view key from the account's view key and a record ciphertext
247
+ * const recordCiphertext = RecordCiphertext.fromString("your_record_ciphertext_here");
248
+ * const recordViewKey = account.generateRecordViewKey(recordCiphertext);
249
+ */
250
+ generateRecordViewKey(recordCiphertext) {
251
+ if (typeof recordCiphertext === 'string') {
252
+ recordCiphertext = RecordCiphertext.fromString(recordCiphertext);
253
+ }
254
+ if (!(recordCiphertext.isOwner(this._viewKey))) {
255
+ throw new Error("The record ciphertext does not belong to this account");
256
+ }
257
+ return EncryptionToolkit.generateRecordViewKey(this._viewKey, recordCiphertext);
258
+ }
259
+ /**
260
+ * Generates a transition view key from the account owner's view key and the transition public key.
261
+ * This key can be used to decrypt the private inputs and outputs of a the transition without
262
+ * revealing the account's view key.
263
+ * @param {string | Group} tpk The transition public key
264
+ * @returns {Field} The transition view key
265
+ *
266
+ * @example
267
+ * // Import the Account class
268
+ * import { Account } from "@provablehq/sdk/testnet.js";
269
+ *
270
+ * // Generate a transition view key from the account's view key and a transition public key
271
+ * const tpk = Group.fromString("your_transition_public_key_here");
272
+ *
273
+ * const transitionViewKey = account.generateTransitionViewKey(tpk);
274
+ */
275
+ generateTransitionViewKey(tpk) {
276
+ if (typeof tpk === 'string') {
277
+ tpk = Group.fromString(tpk);
278
+ }
279
+ return EncryptionToolkit.generateTvk(this._viewKey, tpk);
280
+ }
233
281
  /**
234
282
  * Determines whether the account owns a ciphertext record.
235
283
  * @param {RecordCiphertext | string} ciphertext The record ciphertext to check ownership of