@provablehq/sdk 0.6.13 → 0.7.1
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.
- package/README.md +20 -20
- package/dist/{account.d.ts → mainnet/account.d.ts} +10 -10
- package/dist/mainnet/browser.d.ts +20 -0
- package/dist/mainnet/browser.js +934 -0
- package/dist/mainnet/browser.js.map +1 -0
- package/dist/mainnet/constants.d.ts +34 -0
- package/dist/{function-key-provider.d.ts → mainnet/function-key-provider.d.ts} +58 -57
- package/dist/{network-client.d.ts → mainnet/network-client.d.ts} +29 -26
- package/dist/{node-polyfill.d.ts → mainnet/node-polyfill.d.ts} +1 -0
- package/dist/{node-polyfill.js → mainnet/node-polyfill.js} +1 -0
- package/dist/mainnet/node-polyfill.js.map +1 -0
- package/dist/mainnet/node.d.ts +2 -0
- package/dist/mainnet/node.js +13 -0
- package/dist/{node.js.map → mainnet/node.js.map} +1 -1
- package/dist/{offline-key-provider.d.ts → mainnet/offline-key-provider.d.ts} +23 -22
- package/dist/mainnet/polyfill/shared.d.ts +1 -0
- package/dist/mainnet/program-manager-6a377210.js +2200 -0
- package/dist/mainnet/program-manager-6a377210.js.map +1 -0
- package/dist/{program-manager.d.ts → mainnet/program-manager.d.ts} +63 -59
- package/dist/{record-provider.d.ts → mainnet/record-provider.d.ts} +22 -22
- package/dist/{utils.d.ts → mainnet/utils.d.ts} +2 -0
- package/dist/mainnet/wasm.d.ts +1 -0
- package/dist/{worker.d.ts → mainnet/worker.d.ts} +2 -1
- package/dist/mainnet/worker.js +78 -0
- package/dist/mainnet/worker.js.map +1 -0
- package/dist/testnet/account.d.ts +137 -0
- package/dist/testnet/browser.d.ts +20 -0
- package/dist/testnet/browser.js +934 -0
- package/dist/testnet/browser.js.map +1 -0
- package/dist/testnet/constants.d.ts +34 -0
- package/dist/testnet/function-key-provider.d.ts +349 -0
- package/dist/testnet/managed-worker.d.ts +3 -0
- package/dist/testnet/models/block.d.ts +21 -0
- package/dist/testnet/models/confirmed_transaction.d.ts +6 -0
- package/dist/testnet/models/execution.d.ts +5 -0
- package/dist/testnet/models/input.d.ts +10 -0
- package/dist/testnet/models/output.d.ts +6 -0
- package/dist/testnet/models/transactionModel.d.ts +6 -0
- package/dist/testnet/models/transition.d.ts +13 -0
- package/dist/testnet/network-client.d.ts +270 -0
- package/dist/testnet/node-polyfill.d.ts +5 -0
- package/dist/testnet/node-polyfill.js +303 -0
- package/dist/testnet/node-polyfill.js.map +1 -0
- package/dist/testnet/node.d.ts +2 -0
- package/dist/testnet/node.js +13 -0
- package/dist/testnet/node.js.map +1 -0
- package/dist/testnet/offline-key-provider.d.ts +348 -0
- package/dist/testnet/polyfill/crypto.d.ts +1 -0
- package/dist/testnet/polyfill/fetch.d.ts +1 -0
- package/dist/testnet/polyfill/shared.d.ts +1 -0
- package/dist/testnet/polyfill/worker.d.ts +1 -0
- package/dist/testnet/polyfill/xmlhttprequest.d.ts +1 -0
- package/dist/{index.js → testnet/program-manager-97ade0e6.js} +362 -1278
- package/dist/testnet/program-manager-97ade0e6.js.map +1 -0
- package/dist/testnet/program-manager.d.ts +640 -0
- package/dist/testnet/record-provider.d.ts +236 -0
- package/dist/testnet/utils.d.ts +4 -0
- package/dist/testnet/wasm.d.ts +1 -0
- package/dist/testnet/worker.d.ts +9 -0
- package/dist/testnet/worker.js +78 -0
- package/dist/testnet/worker.js.map +1 -0
- package/package.json +23 -13
- package/dist/index.d.ts +0 -52
- package/dist/index.js.map +0 -1
- package/dist/node-polyfill.js.map +0 -1
- package/dist/node.d.ts +0 -2
- package/dist/node.js +0 -11
- package/dist/worker.js +0 -74
- package/dist/worker.js.map +0 -1
- /package/dist/{managed-worker.d.ts → mainnet/managed-worker.d.ts} +0 -0
- /package/dist/{models → mainnet/models}/block.d.ts +0 -0
- /package/dist/{models → mainnet/models}/confirmed_transaction.d.ts +0 -0
- /package/dist/{models → mainnet/models}/execution.d.ts +0 -0
- /package/dist/{models → mainnet/models}/input.d.ts +0 -0
- /package/dist/{models → mainnet/models}/output.d.ts +0 -0
- /package/dist/{models → mainnet/models}/transactionModel.d.ts +0 -0
- /package/dist/{models → mainnet/models}/transition.d.ts +0 -0
- /package/dist/{polyfill → mainnet/polyfill}/crypto.d.ts +0 -0
- /package/dist/{polyfill → mainnet/polyfill}/fetch.d.ts +0 -0
- /package/dist/{polyfill → mainnet/polyfill}/worker.d.ts +0 -0
- /package/dist/{polyfill → mainnet/polyfill}/xmlhttprequest.d.ts +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import 'core-js/proposals/json-parse-with-source.js';
|
|
2
|
+
import { initThreadPool, PrivateKey, verifyFunctionExecution } from '@provablehq/wasm/mainnet.js';
|
|
3
|
+
import { P as ProgramManager, A as AleoKeyProvider, a as AleoKeyProviderParams } from './program-manager-6a377210.js';
|
|
4
|
+
import { expose } from 'comlink';
|
|
5
|
+
|
|
6
|
+
await initThreadPool();
|
|
7
|
+
const defaultHost = "https://api.explorer.provable.com/v1";
|
|
8
|
+
const keyProvider = new AleoKeyProvider();
|
|
9
|
+
const programManager = new ProgramManager(defaultHost, keyProvider, undefined);
|
|
10
|
+
keyProvider.useCache(true);
|
|
11
|
+
let lastLocalProgram = "";
|
|
12
|
+
async function run(localProgram, aleoFunction, inputs, privateKey, proveExecution = false) {
|
|
13
|
+
console.log("Web worker: Executing function locally...");
|
|
14
|
+
const startTime = performance.now();
|
|
15
|
+
// Ensure the program is valid and that it contains the function specified
|
|
16
|
+
let program;
|
|
17
|
+
try {
|
|
18
|
+
program = programManager.createProgramFromSource(localProgram);
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
throw new Error("Error creating program from source");
|
|
22
|
+
}
|
|
23
|
+
const program_id = program.id();
|
|
24
|
+
if (!program.hasFunction(aleoFunction)) {
|
|
25
|
+
throw new Error(`Program ${program_id} does not contain function ${aleoFunction}`);
|
|
26
|
+
}
|
|
27
|
+
const cacheKey = `${program_id}:${aleoFunction}`;
|
|
28
|
+
// Get the program imports
|
|
29
|
+
let imports;
|
|
30
|
+
try {
|
|
31
|
+
imports = await programManager.networkClient.getProgramImports(localProgram);
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
throw new Error("Error getting program imports");
|
|
35
|
+
}
|
|
36
|
+
// Get the proving and verifying keys for the function
|
|
37
|
+
if (lastLocalProgram !== localProgram) {
|
|
38
|
+
const keys = await programManager.synthesizeKeys(localProgram, aleoFunction, inputs, PrivateKey.from_string(privateKey));
|
|
39
|
+
programManager.keyProvider.cacheKeys(cacheKey, keys);
|
|
40
|
+
lastLocalProgram = localProgram;
|
|
41
|
+
}
|
|
42
|
+
// Pass the cache key to the execute function
|
|
43
|
+
const keyParams = new AleoKeyProviderParams({
|
|
44
|
+
cacheKey: cacheKey,
|
|
45
|
+
});
|
|
46
|
+
// Execute the function locally
|
|
47
|
+
const response = await programManager.run(localProgram, aleoFunction, inputs, proveExecution, imports, keyParams, undefined, undefined, PrivateKey.from_string(privateKey));
|
|
48
|
+
// Return the outputs to the main thread
|
|
49
|
+
console.log(`Web worker: Local execution completed in ${performance.now() - startTime} ms`);
|
|
50
|
+
const outputs = response.getOutputs();
|
|
51
|
+
const execution = response.getExecution();
|
|
52
|
+
let executionString = "";
|
|
53
|
+
let keys;
|
|
54
|
+
try {
|
|
55
|
+
keys = keyProvider.getKeys(cacheKey);
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
throw new Error("Could not get verifying key");
|
|
59
|
+
}
|
|
60
|
+
const verifyingKey = keys[1];
|
|
61
|
+
if (execution) {
|
|
62
|
+
verifyFunctionExecution(execution, verifyingKey, program, "hello");
|
|
63
|
+
executionString = execution.toString();
|
|
64
|
+
console.log("Execution verified successfully: " + execution);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
executionString = "";
|
|
68
|
+
}
|
|
69
|
+
console.log(`Function execution response: ${outputs}`);
|
|
70
|
+
return { outputs: outputs, execution: executionString };
|
|
71
|
+
}
|
|
72
|
+
async function getPrivateKey() {
|
|
73
|
+
const privateKey = new PrivateKey();
|
|
74
|
+
return privateKey.to_string();
|
|
75
|
+
}
|
|
76
|
+
const workerAPI = { run, getPrivateKey };
|
|
77
|
+
expose(workerAPI);
|
|
78
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +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,CAAC;AAEvB,MAAM,WAAW,GAAG,sCAAsC,CAAC;AAC3D,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;AAC1C,MAAM,cAAc,GAAG,IAAI,cAAc,CACrC,WAAW,EACX,WAAW,EACX,SAAS,CACZ,CAAC;AAEF,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAE3B,IAAI,gBAAgB,GAAW,EAAE,CAAC;AAYlC,eAAe,GAAG,CACd,YAAoB,EACpB,YAAoB,EACpB,MAAgB,EAChB,UAAkB,EAClB,cAAc,GAAG,KAAK,EAAA;AAEtB,IAA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,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;AACpC,IAAA,OAAO,UAAU,CAAC,SAAS,EAAE,CAAC;AAClC,CAAC;AAED,MAAM,SAAS,GAAG,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;AACzC,MAAM,CAAC,SAAS,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Address, PrivateKey, Signature, ViewKey, PrivateKeyCiphertext, RecordCiphertext } from "./wasm";
|
|
2
|
+
interface AccountParam {
|
|
3
|
+
privateKey?: string;
|
|
4
|
+
seed?: Uint8Array;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from
|
|
8
|
+
* an existing private key or seed, and message signing and verification functionality.
|
|
9
|
+
*
|
|
10
|
+
* An Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,
|
|
11
|
+
* and a public account address are derived. The private key lies at the root of an Aleo account. It is a highly
|
|
12
|
+
* sensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value
|
|
13
|
+
* transfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public
|
|
14
|
+
* address to which other users of Aleo can send Aleo credits and other records to. This class should only be used
|
|
15
|
+
* environments where the safety of the underlying key material can be assured.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Create a new account
|
|
19
|
+
* const myRandomAccount = new Account();
|
|
20
|
+
*
|
|
21
|
+
* // Create an account from a randomly generated seed
|
|
22
|
+
* const seed = new Uint8Array([94, 91, 52, 251, 240, 230, 226, 35, 117, 253, 224, 210, 175, 13, 205, 120, 155, 214, 7, 169, 66, 62, 206, 50, 188, 40, 29, 122, 40, 250, 54, 18]);
|
|
23
|
+
* const mySeededAccount = new Account({seed: seed});
|
|
24
|
+
*
|
|
25
|
+
* // Create an account from an existing private key
|
|
26
|
+
* const myExistingAccount = new Account({privateKey: 'myExistingPrivateKey'})
|
|
27
|
+
*
|
|
28
|
+
* // Sign a message
|
|
29
|
+
* const hello_world = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
|
|
30
|
+
* const signature = myRandomAccount.sign(hello_world)
|
|
31
|
+
*
|
|
32
|
+
* // Verify a signature
|
|
33
|
+
* myRandomAccount.verify(hello_world, signature)
|
|
34
|
+
*/
|
|
35
|
+
export declare class Account {
|
|
36
|
+
_privateKey: PrivateKey;
|
|
37
|
+
_viewKey: ViewKey;
|
|
38
|
+
_address: Address;
|
|
39
|
+
constructor(params?: AccountParam);
|
|
40
|
+
/**
|
|
41
|
+
* Attempts to create an account from a private key ciphertext
|
|
42
|
+
* @param {PrivateKeyCiphertext | string} ciphertext
|
|
43
|
+
* @param {string} password
|
|
44
|
+
* @returns {PrivateKey}
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const ciphertext = PrivateKey.newEncrypted("password");
|
|
48
|
+
* const account = Account.fromCiphertext(ciphertext, "password");
|
|
49
|
+
*/
|
|
50
|
+
static fromCiphertext(ciphertext: PrivateKeyCiphertext | string, password: string): Account;
|
|
51
|
+
private privateKeyFromParams;
|
|
52
|
+
privateKey(): PrivateKey;
|
|
53
|
+
viewKey(): ViewKey;
|
|
54
|
+
address(): Address;
|
|
55
|
+
toString(): any;
|
|
56
|
+
/**
|
|
57
|
+
* Encrypt the account's private key with a password
|
|
58
|
+
* @param {string} ciphertext
|
|
59
|
+
* @returns {PrivateKeyCiphertext}
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const account = new Account();
|
|
63
|
+
* const ciphertext = account.encryptAccount("password");
|
|
64
|
+
*/
|
|
65
|
+
encryptAccount(password: string): any;
|
|
66
|
+
/**
|
|
67
|
+
* Decrypts a Record in ciphertext form into plaintext
|
|
68
|
+
* @param {string} ciphertext
|
|
69
|
+
* @returns {Record}
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* const account = new Account();
|
|
73
|
+
* const record = account.decryptRecord("record1ciphertext");
|
|
74
|
+
*/
|
|
75
|
+
decryptRecord(ciphertext: string): any;
|
|
76
|
+
/**
|
|
77
|
+
* Decrypts an array of Records in ciphertext form into plaintext
|
|
78
|
+
* @param {string[]} ciphertexts
|
|
79
|
+
* @returns {Record[]}
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* const account = new Account();
|
|
83
|
+
* const record = account.decryptRecords(["record1ciphertext", "record2ciphertext"]);
|
|
84
|
+
*/
|
|
85
|
+
decryptRecords(ciphertexts: string[]): any[];
|
|
86
|
+
/**
|
|
87
|
+
* Determines whether the account owns a ciphertext record
|
|
88
|
+
* @param {RecordCipherText | string} ciphertext
|
|
89
|
+
* @returns {boolean}
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* // Create a connection to the Aleo network and an account
|
|
93
|
+
* const connection = new AleoNetworkClient("https://api.explorer.provable.com/v1");
|
|
94
|
+
* const account = Account.fromCiphertext("ciphertext", "password");
|
|
95
|
+
*
|
|
96
|
+
* // Get a record from the network
|
|
97
|
+
* const record = connection.getBlock(1234);
|
|
98
|
+
* const recordCipherText = record.transactions[0].execution.transitions[0].id;
|
|
99
|
+
*
|
|
100
|
+
* // Check if the account owns the record
|
|
101
|
+
* if account.ownsRecord(recordCipherText) {
|
|
102
|
+
* // Then one can do something like:
|
|
103
|
+
* // Decrypt the record and check if it's spent
|
|
104
|
+
* // Store the record in a local database
|
|
105
|
+
* // Etc.
|
|
106
|
+
* }
|
|
107
|
+
*/
|
|
108
|
+
ownsRecordCiphertext(ciphertext: RecordCiphertext | string): any;
|
|
109
|
+
/**
|
|
110
|
+
* Signs a message with the account's private key.
|
|
111
|
+
* Returns a Signature.
|
|
112
|
+
*
|
|
113
|
+
* @param {Uint8Array} message
|
|
114
|
+
* @returns {Signature}
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* const account = new Account();
|
|
118
|
+
* const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
|
|
119
|
+
* account.sign(message);
|
|
120
|
+
*/
|
|
121
|
+
sign(message: Uint8Array): any;
|
|
122
|
+
/**
|
|
123
|
+
* Verifies the Signature on a message.
|
|
124
|
+
*
|
|
125
|
+
* @param {Uint8Array} message
|
|
126
|
+
* @param {Signature} signature
|
|
127
|
+
* @returns {boolean}
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* const account = new Account();
|
|
131
|
+
* const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
|
|
132
|
+
* const signature = account.sign(message);
|
|
133
|
+
* account.verify(message, signature);
|
|
134
|
+
*/
|
|
135
|
+
verify(message: Uint8Array, signature: Signature): any;
|
|
136
|
+
}
|
|
137
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "./polyfill/shared";
|
|
2
|
+
import { Account } from "./account";
|
|
3
|
+
import { AleoNetworkClient, ProgramImports } from "./network-client";
|
|
4
|
+
import { Block } from "./models/block";
|
|
5
|
+
import { Execution } from "./models/execution";
|
|
6
|
+
import { Input } from "./models/input";
|
|
7
|
+
import { Output } from "./models/output";
|
|
8
|
+
import { TransactionModel } from "./models/transactionModel";
|
|
9
|
+
import { Transition } from "./models/transition";
|
|
10
|
+
import { AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, CachedKeyPair, FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider";
|
|
11
|
+
import { OfflineKeyProvider, OfflineSearchParams } from "./offline-key-provider";
|
|
12
|
+
import { BlockHeightSearch, NetworkRecordProvider, RecordProvider, RecordSearchParams } from "./record-provider";
|
|
13
|
+
declare function initializeWasm(): Promise<void>;
|
|
14
|
+
export { createAleoWorker } from "./managed-worker";
|
|
15
|
+
export { ProgramManager } from "./program-manager";
|
|
16
|
+
export { logAndThrow } from "./utils";
|
|
17
|
+
export { Address, Execution as FunctionExecution, ExecutionResponse, Field, OfflineQuery, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Signature, Transaction, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "./wasm";
|
|
18
|
+
export { initializeWasm };
|
|
19
|
+
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";
|
|
20
|
+
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, Block, BlockHeightSearch, CachedKeyPair, Execution, FunctionKeyPair, FunctionKeyProvider, Input, KeySearchParams, NetworkRecordProvider, ProgramImports, OfflineKeyProvider, OfflineSearchParams, Output, RecordProvider, RecordSearchParams, TransactionModel, Transition, };
|