@provablehq/sdk 0.10.2 → 0.10.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.
- package/dist/dynamic/browser.cjs +12 -0
- package/dist/dynamic/browser.d.cts +8 -0
- package/dist/dynamic/browser.d.ts +2 -2
- package/dist/dynamic/node.cjs +12 -0
- package/dist/dynamic/node.d.cts +8 -0
- package/dist/dynamic/node.d.ts +2 -2
- package/dist/mainnet/account.d.cts +347 -0
- package/dist/mainnet/browser.cjs +8507 -0
- package/dist/mainnet/browser.cjs.map +1 -0
- package/dist/mainnet/browser.d.cts +72 -0
- package/dist/mainnet/browser.d.ts +2 -2
- package/dist/mainnet/browser.js +55 -31
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/constants.d.cts +40 -0
- package/dist/mainnet/external-signing.d.cts +76 -0
- package/dist/mainnet/integrations/sealance/merkle-tree.d.cts +192 -0
- package/dist/mainnet/keys/keystore/error.d.cts +24 -0
- package/dist/mainnet/keys/keystore/file.d.cts +177 -0
- package/dist/mainnet/keys/keystore/interface.d.cts +161 -0
- package/dist/mainnet/keys/provider/interface.d.cts +170 -0
- package/dist/mainnet/keys/provider/memory.d.cts +213 -0
- package/dist/mainnet/keys/provider/memory.d.ts +6 -2
- package/dist/mainnet/keys/provider/offline.d.cts +365 -0
- package/dist/mainnet/keys/verifier/interface.d.cts +70 -0
- package/dist/mainnet/keys/verifier/memory.d.cts +37 -0
- package/dist/mainnet/keys/verifier/memory.d.ts +1 -1
- package/dist/mainnet/models/authorization.d.cts +6 -0
- package/dist/mainnet/models/authorization.d.ts +2 -2
- package/dist/mainnet/models/blockJSON.d.cts +33 -0
- package/dist/mainnet/models/confirmed_transaction.d.cts +9 -0
- package/dist/mainnet/models/cryptoBoxPubkey.d.cts +4 -0
- package/dist/mainnet/models/deployment/deploymentJSON.d.cts +6 -0
- package/dist/mainnet/models/deployment/deploymentObject.d.cts +6 -0
- package/dist/mainnet/models/encryptedProvingRequest.d.cts +4 -0
- package/dist/mainnet/models/execution/executionJSON.d.cts +11 -0
- package/dist/mainnet/models/execution/executionObject.d.cts +11 -0
- package/dist/mainnet/models/external-signing.d.cts +123 -0
- package/dist/mainnet/models/finalizeJSON.d.cts +6 -0
- package/dist/mainnet/models/functionInput.d.cts +7 -0
- package/dist/mainnet/models/functionObject.d.cts +8 -0
- package/dist/mainnet/models/imports.d.cts +7 -0
- package/dist/mainnet/models/input/inputJSON.d.cts +10 -0
- package/dist/mainnet/models/input/inputObject.d.cts +15 -0
- package/dist/mainnet/models/inputID.d.cts +4 -0
- package/dist/mainnet/models/keyPair.d.cts +4 -0
- package/dist/mainnet/models/output/outputJSON.d.cts +7 -0
- package/dist/mainnet/models/output/outputObject.d.cts +18 -0
- package/dist/mainnet/models/owner/ownerJSON.d.cts +4 -0
- package/dist/mainnet/models/owner/ownerObject.d.cts +5 -0
- package/dist/mainnet/models/plaintext/array.d.cts +3 -0
- package/dist/mainnet/models/plaintext/literal.d.cts +1 -0
- package/dist/mainnet/models/plaintext/plaintext.d.cts +5 -0
- package/dist/mainnet/models/plaintext/struct.d.cts +5 -0
- package/dist/mainnet/models/provingRequest.d.cts +6 -0
- package/dist/mainnet/models/provingRequest.d.ts +1 -1
- package/dist/mainnet/models/provingResponse.d.cts +51 -0
- package/dist/mainnet/models/ratification.d.cts +4 -0
- package/dist/mainnet/models/record-provider/encryptedRecord.d.cts +58 -0
- package/dist/mainnet/models/record-provider/ownedRecord.d.cts +60 -0
- package/dist/mainnet/models/record-provider/recordSearchParams.d.cts +19 -0
- package/dist/mainnet/models/record-scanner/encryptedRecordsResult.d.cts +7 -0
- package/dist/mainnet/models/record-scanner/encryptedRegistrationRequest.d.cts +8 -0
- package/dist/mainnet/models/record-scanner/error.d.cts +47 -0
- package/dist/mainnet/models/record-scanner/error.d.ts +1 -1
- package/dist/mainnet/models/record-scanner/ownedFilter.d.cts +22 -0
- package/dist/mainnet/models/record-scanner/ownedFilter.d.ts +3 -3
- package/dist/mainnet/models/record-scanner/ownedRecordsResponseFilter.d.cts +42 -0
- package/dist/mainnet/models/record-scanner/ownedRecordsResult.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/recordsFilter.d.cts +35 -0
- package/dist/mainnet/models/record-scanner/recordsFilter.d.ts +2 -2
- package/dist/mainnet/models/record-scanner/recordsResponseFilter.d.cts +42 -0
- package/dist/mainnet/models/record-scanner/registrationRequest.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/registrationResponse.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/registrationResult.d.cts +9 -0
- package/dist/mainnet/models/record-scanner/revokeResult.d.cts +17 -0
- package/dist/mainnet/models/record-scanner/serialNumbersResult.d.cts +15 -0
- package/dist/mainnet/models/record-scanner/statusResponse.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/statusResult.d.cts +13 -0
- package/dist/mainnet/models/record-scanner/tagsResult.d.cts +12 -0
- package/dist/mainnet/models/request.d.cts +14 -0
- package/dist/mainnet/models/request.d.ts +1 -1
- package/dist/mainnet/models/solution.d.cts +14 -0
- package/dist/mainnet/models/transaction/transactionJSON.d.cts +11 -0
- package/dist/mainnet/models/transaction/transactionObject.d.cts +14 -0
- package/dist/mainnet/models/transition/transitionJSON.d.cts +13 -0
- package/dist/mainnet/models/transition/transitionObject.d.cts +15 -0
- package/dist/mainnet/network-client.d.cts +850 -0
- package/dist/mainnet/network-client.d.ts +3 -0
- package/dist/mainnet/node-polyfill.cjs +238 -0
- package/dist/mainnet/node-polyfill.cjs.map +1 -0
- package/dist/mainnet/node-polyfill.d.cts +5 -0
- package/dist/mainnet/node-polyfill.js +1 -1
- package/dist/mainnet/node-polyfill.js.map +1 -1
- package/dist/mainnet/node.cjs +685 -0
- package/dist/mainnet/node.cjs.map +1 -0
- package/dist/mainnet/node.d.cts +3 -0
- package/dist/mainnet/node.js +1 -1
- package/dist/mainnet/polyfill/crypto.d.cts +1 -0
- package/dist/mainnet/polyfill/fetch.d.cts +1 -0
- package/dist/mainnet/polyfill/shared.d.cts +1 -0
- package/dist/mainnet/polyfill/worker.d.cts +1 -0
- package/dist/mainnet/polyfill/xmlhttprequest.d.cts +1 -0
- package/dist/mainnet/program-manager.d.cts +1588 -0
- package/dist/mainnet/record-provider.d.cts +274 -0
- package/dist/mainnet/record-scanner.d.cts +371 -0
- package/dist/mainnet/record-scanner.d.ts +9 -6
- package/dist/mainnet/security.d.cts +62 -0
- package/dist/mainnet/security.d.ts +5 -5
- package/dist/mainnet/utils.d.cts +23 -0
- package/dist/mainnet/utils.d.ts +10 -2
- package/dist/mainnet/wasm.d.cts +1 -0
- package/dist/testnet/account.d.cts +347 -0
- package/dist/testnet/browser.cjs +8507 -0
- package/dist/testnet/browser.cjs.map +1 -0
- package/dist/testnet/browser.d.cts +72 -0
- package/dist/testnet/browser.d.ts +2 -2
- package/dist/testnet/browser.js +55 -31
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/constants.d.cts +40 -0
- package/dist/testnet/external-signing.d.cts +76 -0
- package/dist/testnet/integrations/sealance/merkle-tree.d.cts +192 -0
- package/dist/testnet/keys/keystore/error.d.cts +24 -0
- package/dist/testnet/keys/keystore/file.d.cts +177 -0
- package/dist/testnet/keys/keystore/interface.d.cts +161 -0
- package/dist/testnet/keys/provider/interface.d.cts +170 -0
- package/dist/testnet/keys/provider/memory.d.cts +213 -0
- package/dist/testnet/keys/provider/memory.d.ts +6 -2
- package/dist/testnet/keys/provider/offline.d.cts +365 -0
- package/dist/testnet/keys/verifier/interface.d.cts +70 -0
- package/dist/testnet/keys/verifier/memory.d.cts +37 -0
- package/dist/testnet/keys/verifier/memory.d.ts +1 -1
- package/dist/testnet/models/authorization.d.cts +6 -0
- package/dist/testnet/models/authorization.d.ts +2 -2
- package/dist/testnet/models/blockJSON.d.cts +33 -0
- package/dist/testnet/models/confirmed_transaction.d.cts +9 -0
- package/dist/testnet/models/cryptoBoxPubkey.d.cts +4 -0
- package/dist/testnet/models/deployment/deploymentJSON.d.cts +6 -0
- package/dist/testnet/models/deployment/deploymentObject.d.cts +6 -0
- package/dist/testnet/models/encryptedProvingRequest.d.cts +4 -0
- package/dist/testnet/models/execution/executionJSON.d.cts +11 -0
- package/dist/testnet/models/execution/executionObject.d.cts +11 -0
- package/dist/testnet/models/external-signing.d.cts +123 -0
- package/dist/testnet/models/finalizeJSON.d.cts +6 -0
- package/dist/testnet/models/functionInput.d.cts +7 -0
- package/dist/testnet/models/functionObject.d.cts +8 -0
- package/dist/testnet/models/imports.d.cts +7 -0
- package/dist/testnet/models/input/inputJSON.d.cts +10 -0
- package/dist/testnet/models/input/inputObject.d.cts +15 -0
- package/dist/testnet/models/inputID.d.cts +4 -0
- package/dist/testnet/models/keyPair.d.cts +4 -0
- package/dist/testnet/models/output/outputJSON.d.cts +7 -0
- package/dist/testnet/models/output/outputObject.d.cts +18 -0
- package/dist/testnet/models/owner/ownerJSON.d.cts +4 -0
- package/dist/testnet/models/owner/ownerObject.d.cts +5 -0
- package/dist/testnet/models/plaintext/array.d.cts +3 -0
- package/dist/testnet/models/plaintext/literal.d.cts +1 -0
- package/dist/testnet/models/plaintext/plaintext.d.cts +5 -0
- package/dist/testnet/models/plaintext/struct.d.cts +5 -0
- package/dist/testnet/models/provingRequest.d.cts +6 -0
- package/dist/testnet/models/provingRequest.d.ts +1 -1
- package/dist/testnet/models/provingResponse.d.cts +51 -0
- package/dist/testnet/models/ratification.d.cts +4 -0
- package/dist/testnet/models/record-provider/encryptedRecord.d.cts +58 -0
- package/dist/testnet/models/record-provider/ownedRecord.d.cts +60 -0
- package/dist/testnet/models/record-provider/recordSearchParams.d.cts +19 -0
- package/dist/testnet/models/record-scanner/encryptedRecordsResult.d.cts +7 -0
- package/dist/testnet/models/record-scanner/encryptedRegistrationRequest.d.cts +8 -0
- package/dist/testnet/models/record-scanner/error.d.cts +47 -0
- package/dist/testnet/models/record-scanner/error.d.ts +1 -1
- package/dist/testnet/models/record-scanner/ownedFilter.d.cts +22 -0
- package/dist/testnet/models/record-scanner/ownedFilter.d.ts +3 -3
- package/dist/testnet/models/record-scanner/ownedRecordsResponseFilter.d.cts +42 -0
- package/dist/testnet/models/record-scanner/ownedRecordsResult.d.cts +13 -0
- package/dist/testnet/models/record-scanner/recordsFilter.d.cts +35 -0
- package/dist/testnet/models/record-scanner/recordsFilter.d.ts +2 -2
- package/dist/testnet/models/record-scanner/recordsResponseFilter.d.cts +42 -0
- package/dist/testnet/models/record-scanner/registrationRequest.d.cts +13 -0
- package/dist/testnet/models/record-scanner/registrationResponse.d.cts +13 -0
- package/dist/testnet/models/record-scanner/registrationResult.d.cts +9 -0
- package/dist/testnet/models/record-scanner/revokeResult.d.cts +17 -0
- package/dist/testnet/models/record-scanner/serialNumbersResult.d.cts +15 -0
- package/dist/testnet/models/record-scanner/statusResponse.d.cts +13 -0
- package/dist/testnet/models/record-scanner/statusResult.d.cts +13 -0
- package/dist/testnet/models/record-scanner/tagsResult.d.cts +12 -0
- package/dist/testnet/models/request.d.cts +14 -0
- package/dist/testnet/models/request.d.ts +1 -1
- package/dist/testnet/models/solution.d.cts +14 -0
- package/dist/testnet/models/transaction/transactionJSON.d.cts +11 -0
- package/dist/testnet/models/transaction/transactionObject.d.cts +14 -0
- package/dist/testnet/models/transition/transitionJSON.d.cts +13 -0
- package/dist/testnet/models/transition/transitionObject.d.cts +15 -0
- package/dist/testnet/network-client.d.cts +850 -0
- package/dist/testnet/network-client.d.ts +3 -0
- package/dist/testnet/node-polyfill.cjs +238 -0
- package/dist/testnet/node-polyfill.cjs.map +1 -0
- package/dist/testnet/node-polyfill.d.cts +5 -0
- package/dist/testnet/node-polyfill.js +1 -1
- package/dist/testnet/node-polyfill.js.map +1 -1
- package/dist/testnet/node.cjs +685 -0
- package/dist/testnet/node.cjs.map +1 -0
- package/dist/testnet/node.d.cts +3 -0
- package/dist/testnet/node.js +1 -1
- package/dist/testnet/polyfill/crypto.d.cts +1 -0
- package/dist/testnet/polyfill/fetch.d.cts +1 -0
- package/dist/testnet/polyfill/shared.d.cts +1 -0
- package/dist/testnet/polyfill/worker.d.cts +1 -0
- package/dist/testnet/polyfill/xmlhttprequest.d.cts +1 -0
- package/dist/testnet/program-manager.d.cts +1588 -0
- package/dist/testnet/record-provider.d.cts +274 -0
- package/dist/testnet/record-scanner.d.cts +371 -0
- package/dist/testnet/record-scanner.d.ts +9 -6
- package/dist/testnet/security.d.cts +62 -0
- package/dist/testnet/security.d.ts +5 -5
- package/dist/testnet/utils.d.cts +23 -0
- package/dist/testnet/utils.d.ts +10 -2
- package/dist/testnet/wasm.d.cts +1 -0
- package/package.json +51 -9
package/dist/dynamic/node.d.ts
CHANGED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { Address, ComputeKey, Field, Group, PrivateKey, Signature, ViewKey, PrivateKeyCiphertext, RecordCiphertext, RecordPlaintext } from "./wasm.js";
|
|
2
|
+
interface AccountParam {
|
|
3
|
+
privateKey?: string | PrivateKey;
|
|
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. An Aleo Account is generated
|
|
9
|
+
* from a randomly generated seed (number) from which an account private key, view key, and a public account address are
|
|
10
|
+
* derived. The private key lies at the root of an Aleo account. It is a highly sensitive secret and should be protected
|
|
11
|
+
* as it allows for creation of Aleo Program executions and arbitrary value transfers. The View Key allows for decryption
|
|
12
|
+
* of a user's activity on the blockchain. The Address is the public address to which other users of Aleo can send Aleo
|
|
13
|
+
* credits and other records to. This class should only be used in environments where the safety of the underlying key
|
|
14
|
+
* material can be assured.
|
|
15
|
+
*
|
|
16
|
+
* When an Account is no longer needed, call {@link destroy} to securely zeroize and free all sensitive key material
|
|
17
|
+
* from WASM memory. Alternatively, use `[Symbol.dispose]()` with the `using` declaration in ES2024+ environments.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* import { Account } from "@provablehq/sdk/testnet.js";
|
|
21
|
+
*
|
|
22
|
+
* // Create a new account
|
|
23
|
+
* const myRandomAccount = new Account();
|
|
24
|
+
*
|
|
25
|
+
* // Create an account from a randomly generated seed
|
|
26
|
+
* 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]);
|
|
27
|
+
* const mySeededAccount = new Account({seed: seed});
|
|
28
|
+
*
|
|
29
|
+
* // Create an account from an existing private key
|
|
30
|
+
* const myExistingAccount = new Account({privateKey: process.env.privateKey});
|
|
31
|
+
*
|
|
32
|
+
* // Sign a message
|
|
33
|
+
* const hello_world = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100]);
|
|
34
|
+
* const signature = myRandomAccount.sign(hello_world);
|
|
35
|
+
*
|
|
36
|
+
* // Verify a signature
|
|
37
|
+
* assert(myRandomAccount.verify(hello_world, signature));
|
|
38
|
+
*
|
|
39
|
+
* // Securely destroy the account when done
|
|
40
|
+
* myRandomAccount.destroy();
|
|
41
|
+
*/
|
|
42
|
+
export declare class Account {
|
|
43
|
+
_privateKey: PrivateKey;
|
|
44
|
+
_viewKey: ViewKey;
|
|
45
|
+
_computeKey: ComputeKey;
|
|
46
|
+
_address: Address;
|
|
47
|
+
private _destroyed;
|
|
48
|
+
constructor(params?: AccountParam);
|
|
49
|
+
/**
|
|
50
|
+
* Attempts to create an account from a private key ciphertext
|
|
51
|
+
* @param {PrivateKeyCiphertext | string} ciphertext The encrypted private key ciphertext or its string representation
|
|
52
|
+
* @param {string} password The password used to decrypt the private key ciphertext
|
|
53
|
+
* @returns {Account} A new Account instance created from the decrypted private key
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* import { Account } from "@provablehq/sdk/testnet.js";
|
|
57
|
+
*
|
|
58
|
+
* // Create an account object from a previously encrypted ciphertext and password.
|
|
59
|
+
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
60
|
+
*/
|
|
61
|
+
static fromCiphertext(ciphertext: PrivateKeyCiphertext | string, password: string): Account;
|
|
62
|
+
/**
|
|
63
|
+
* Validates whether the given input is a valid Aleo address.
|
|
64
|
+
* @param {string | Uint8Array} address The address to validate, either as a string or bytes
|
|
65
|
+
* @returns {boolean} True if the address is valid, false otherwise
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* import { Account } from "@provablehq/sdk/testnet.js";
|
|
69
|
+
*
|
|
70
|
+
* const isValid = Account.isValidAddress("aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
|
|
71
|
+
* console.log(isValid); // true
|
|
72
|
+
*
|
|
73
|
+
* const isInvalid = Account.isValidAddress("invalid_address");
|
|
74
|
+
* console.log(isInvalid); // false
|
|
75
|
+
*/
|
|
76
|
+
static isValidAddress(address: string | Uint8Array): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a PrivateKey from the provided parameters.
|
|
79
|
+
* @param {AccountParam} params The parameters containing either a private key string, PrivateKey object, or a seed
|
|
80
|
+
* @returns {PrivateKey} A PrivateKey instance derived from the provided parameters
|
|
81
|
+
*/
|
|
82
|
+
private privateKeyFromParams;
|
|
83
|
+
/**
|
|
84
|
+
* Throws an error if this account has been destroyed.
|
|
85
|
+
*/
|
|
86
|
+
private assertNotDestroyed;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the PrivateKey associated with the account.
|
|
89
|
+
* @returns {PrivateKey} The private key of the account
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* import { Account } from "@provablehq/sdk/testnet.js";
|
|
93
|
+
*
|
|
94
|
+
* const account = new Account();
|
|
95
|
+
* const privateKey = account.privateKey();
|
|
96
|
+
*/
|
|
97
|
+
privateKey(): PrivateKey;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the ViewKey associated with the account.
|
|
100
|
+
* @returns {ViewKey} The view key of the account
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* import { Account } from "@provablehq/sdk/testnet.js";
|
|
104
|
+
*
|
|
105
|
+
* const account = new Account();
|
|
106
|
+
* const viewKey = account.viewKey();
|
|
107
|
+
*/
|
|
108
|
+
viewKey(): ViewKey;
|
|
109
|
+
/**
|
|
110
|
+
* Returns the ComputeKey associated with the account.
|
|
111
|
+
* @returns {ComputeKey} The compute key of the account
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* import { Account } from "@provablehq/sdk/testnet.js";
|
|
115
|
+
*
|
|
116
|
+
* const account = new Account();
|
|
117
|
+
* const computeKey = account.computeKey();
|
|
118
|
+
*/
|
|
119
|
+
computeKey(): ComputeKey;
|
|
120
|
+
/**
|
|
121
|
+
* Returns the Aleo address associated with the account.
|
|
122
|
+
* @returns {Address} The public address of the account
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* import { Account } from "@provablehq/sdk/testnet.js";
|
|
126
|
+
*
|
|
127
|
+
* const account = new Account();
|
|
128
|
+
* const address = account.address();
|
|
129
|
+
*/
|
|
130
|
+
address(): Address;
|
|
131
|
+
/**
|
|
132
|
+
* Deep clones the Account via byte serialization of the private key,
|
|
133
|
+
* avoiding creation of immutable JS string representations of the private key.
|
|
134
|
+
* @returns {Account} A new Account instance with the same private key
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* import { Account } from "@provablehq/sdk/testnet.js";
|
|
138
|
+
*
|
|
139
|
+
* const account = new Account();
|
|
140
|
+
* const clonedAccount = account.clone();
|
|
141
|
+
*/
|
|
142
|
+
clone(): Account;
|
|
143
|
+
/**
|
|
144
|
+
* Returns the address of the account in a string representation.
|
|
145
|
+
*
|
|
146
|
+
* @returns {string} The string representation of the account address
|
|
147
|
+
*/
|
|
148
|
+
toString(): string;
|
|
149
|
+
/**
|
|
150
|
+
* Encrypts the account's private key with a password.
|
|
151
|
+
*
|
|
152
|
+
* @param {string} password Password to encrypt the private key.
|
|
153
|
+
* @returns {PrivateKeyCiphertext} The encrypted private key ciphertext
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* import { Account } from "@provablehq/sdk/testnet.js";
|
|
157
|
+
*
|
|
158
|
+
* const account = new Account();
|
|
159
|
+
* const ciphertext = account.encryptAccount("password");
|
|
160
|
+
* process.env.ciphertext = ciphertext.toString();
|
|
161
|
+
*/
|
|
162
|
+
encryptAccount(password: string): PrivateKeyCiphertext;
|
|
163
|
+
/**
|
|
164
|
+
* Decrypts an encrypted record string into a plaintext record object.
|
|
165
|
+
*
|
|
166
|
+
* @param {string} ciphertext A string representing the ciphertext of a record.
|
|
167
|
+
* @returns {RecordPlaintext} The decrypted record plaintext
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* // Import the AleoNetworkClient and Account classes
|
|
171
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/testnet.js";
|
|
172
|
+
*
|
|
173
|
+
* // Create a connection to the Aleo network and an account
|
|
174
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
|
|
175
|
+
* const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);
|
|
176
|
+
*
|
|
177
|
+
* // Get the record ciphertexts from a transaction.
|
|
178
|
+
* const transaction = await networkClient.getTransactionObject("at1fjy6s9md2v4rgcn3j3q4qndtfaa2zvg58a4uha0rujvrn4cumu9qfazxdd");
|
|
179
|
+
* const records = transaction.records();
|
|
180
|
+
*
|
|
181
|
+
* // Decrypt any records the account owns.
|
|
182
|
+
* const decryptedRecords = [];
|
|
183
|
+
* for (const record of records) {
|
|
184
|
+
* if (account.decryptRecord(record)) {
|
|
185
|
+
* decryptedRecords.push(record);
|
|
186
|
+
* }
|
|
187
|
+
* }
|
|
188
|
+
*/
|
|
189
|
+
decryptRecord(ciphertext: string): RecordPlaintext;
|
|
190
|
+
/**
|
|
191
|
+
* Decrypts an array of Record ciphertext strings into an array of record plaintext objects.
|
|
192
|
+
*
|
|
193
|
+
* @param {string[]} ciphertexts An array of strings representing the ciphertexts of records.
|
|
194
|
+
* @returns {RecordPlaintext[]} An array of decrypted record plaintexts
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* // Import the AleoNetworkClient and Account classes
|
|
198
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/testnet.js";
|
|
199
|
+
*
|
|
200
|
+
* // Create a connection to the Aleo network and an account
|
|
201
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
|
|
202
|
+
* const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);
|
|
203
|
+
*
|
|
204
|
+
* // Get the record ciphertexts from a transaction.
|
|
205
|
+
* const transaction = await networkClient.getTransactionObject("at1fjy6s9md2v4rgcn3j3q4qndtfaa2zvg58a4uha0rujvrn4cumu9qfazxdd");
|
|
206
|
+
* const records = transaction.records();
|
|
207
|
+
*
|
|
208
|
+
* // Decrypt any records the account owns. If the account owns no records, the array will be empty.
|
|
209
|
+
* const decryptedRecords = account.decryptRecords(records);
|
|
210
|
+
*/
|
|
211
|
+
decryptRecords(ciphertexts: string[]): RecordPlaintext[];
|
|
212
|
+
/**
|
|
213
|
+
* Generates a record view key from the account owner's view key and the record ciphertext.
|
|
214
|
+
* This key can be used to decrypt the record without revealing the account's view key.
|
|
215
|
+
* @param {RecordCiphertext | string} recordCiphertext The record ciphertext to generate the view key for
|
|
216
|
+
* @returns {Field} The record view key
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* // Import the Account class
|
|
220
|
+
* import { Account } from "@provablehq/sdk/testnet.js";
|
|
221
|
+
*
|
|
222
|
+
* // Create an account object from a previously encrypted ciphertext and password.
|
|
223
|
+
* const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);
|
|
224
|
+
*
|
|
225
|
+
* // Generate a record view key from the account's view key and a record ciphertext
|
|
226
|
+
* const recordCiphertext = RecordCiphertext.fromString("your_record_ciphertext_here");
|
|
227
|
+
* const recordViewKey = account.generateRecordViewKey(recordCiphertext);
|
|
228
|
+
*/
|
|
229
|
+
generateRecordViewKey(recordCiphertext: RecordCiphertext | string): Field;
|
|
230
|
+
/**
|
|
231
|
+
* Generates a transition view key from the account owner's view key and the transition public key.
|
|
232
|
+
* This key can be used to decrypt the private inputs and outputs of a the transition without
|
|
233
|
+
* revealing the account's view key.
|
|
234
|
+
* @param {string | Group} tpk The transition public key
|
|
235
|
+
* @returns {Field} The transition view key
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* // Import the Account class
|
|
239
|
+
* import { Account } from "@provablehq/sdk/testnet.js";
|
|
240
|
+
*
|
|
241
|
+
* // Generate a transition view key from the account's view key and a transition public key
|
|
242
|
+
* const tpk = Group.fromString("your_transition_public_key_here");
|
|
243
|
+
*
|
|
244
|
+
* const transitionViewKey = account.generateTransitionViewKey(tpk);
|
|
245
|
+
*/
|
|
246
|
+
generateTransitionViewKey(tpk: string | Group): Field;
|
|
247
|
+
/**
|
|
248
|
+
* Determines whether the account owns a ciphertext record.
|
|
249
|
+
* @param {RecordCiphertext | string} ciphertext The record ciphertext to check ownership of
|
|
250
|
+
* @returns {boolean} True if the account owns the record, false otherwise
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* // Import the AleoNetworkClient and Account classes
|
|
254
|
+
* import { AleoNetworkClient, Account } from "@provablehq/sdk/testnet.js";
|
|
255
|
+
*
|
|
256
|
+
* // Create a connection to the Aleo network and an account
|
|
257
|
+
* const networkClient = new AleoNetworkClient("https://api.provable.com/v2");
|
|
258
|
+
* const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);
|
|
259
|
+
*
|
|
260
|
+
* // Get the record ciphertexts from a transaction and check ownership of them.
|
|
261
|
+
* const transaction = await networkClient.getTransactionObject("at1fjy6s9md2v4rgcn3j3q4qndtfaa2zvg58a4uha0rujvrn4cumu9qfazxdd");
|
|
262
|
+
* const records = transaction.records();
|
|
263
|
+
*
|
|
264
|
+
* // Check if the account owns any of the record ciphertexts present in the transaction.
|
|
265
|
+
* const ownedRecords = [];
|
|
266
|
+
* for (const record of records) {
|
|
267
|
+
* if (account.ownsRecordCiphertext(record)) {
|
|
268
|
+
* ownedRecords.push(record);
|
|
269
|
+
* }
|
|
270
|
+
* }
|
|
271
|
+
*/
|
|
272
|
+
ownsRecordCiphertext(ciphertext: RecordCiphertext | string): boolean;
|
|
273
|
+
/**
|
|
274
|
+
* Signs a message with the account's private key.
|
|
275
|
+
* Returns a Signature.
|
|
276
|
+
*
|
|
277
|
+
* @param {Uint8Array} message Message to be signed.
|
|
278
|
+
* @returns {Signature} Signature over the message in bytes.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* // Import the Account class
|
|
282
|
+
* import { Account } from "@provablehq/sdk/testnet.js";
|
|
283
|
+
*
|
|
284
|
+
* // Create a connection to the Aleo network and an account
|
|
285
|
+
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
286
|
+
*
|
|
287
|
+
* // Create an account and a message to sign.
|
|
288
|
+
* const account = new Account();
|
|
289
|
+
* const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
|
|
290
|
+
* const signature = account.sign(message);
|
|
291
|
+
*
|
|
292
|
+
* // Verify the signature.
|
|
293
|
+
* assert(account.verify(message, signature));
|
|
294
|
+
*/
|
|
295
|
+
sign(message: Uint8Array): Signature;
|
|
296
|
+
/**
|
|
297
|
+
* Verifies the Signature on a message.
|
|
298
|
+
*
|
|
299
|
+
* @param {Uint8Array} message Message in bytes to be signed.
|
|
300
|
+
* @param {Signature} signature Signature to be verified.
|
|
301
|
+
* @returns {boolean} True if the signature is valid, false otherwise.
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* // Import the Account class
|
|
305
|
+
* import { Account } from "@provablehq/sdk/testnet.js";
|
|
306
|
+
*
|
|
307
|
+
* // Create a connection to the Aleo network and an account
|
|
308
|
+
* const account = Account.fromCiphertext(process.env.ciphertext, process.env.password);
|
|
309
|
+
*
|
|
310
|
+
* // Sign a message.
|
|
311
|
+
* const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
|
|
312
|
+
* const signature = account.sign(message);
|
|
313
|
+
*
|
|
314
|
+
* // Verify the signature.
|
|
315
|
+
* assert(account.verify(message, signature));
|
|
316
|
+
*/
|
|
317
|
+
verify(message: Uint8Array, signature: Signature): boolean;
|
|
318
|
+
/**
|
|
319
|
+
* Securely destroys the account by zeroizing and freeing all sensitive key material
|
|
320
|
+
* from WASM memory. After calling this method, the account object should not be used.
|
|
321
|
+
*
|
|
322
|
+
* This triggers the Rust-level zeroizing Drop implementation which overwrites private key,
|
|
323
|
+
* view key, and compute key bytes with zeros in WASM linear memory before deallocation.
|
|
324
|
+
*
|
|
325
|
+
* Note: If destroy() is never called, the FinalizationRegistry (set up by wasm-bindgen)
|
|
326
|
+
* will eventually trigger cleanup via GC, but the timing is non-deterministic. For security-
|
|
327
|
+
* sensitive applications, always call destroy() explicitly when the account is no longer needed.
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* const account = new Account();
|
|
331
|
+
* // ... use account ...
|
|
332
|
+
* account.destroy(); // Securely cleans up key material
|
|
333
|
+
*/
|
|
334
|
+
destroy(): void;
|
|
335
|
+
/**
|
|
336
|
+
* Implements the Disposable interface for use with `using` declarations (ES2024+).
|
|
337
|
+
* Calls {@link destroy} to securely clean up key material.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* {
|
|
341
|
+
* using account = new Account();
|
|
342
|
+
* // ... use account ...
|
|
343
|
+
* } // account is automatically destroyed here
|
|
344
|
+
*/
|
|
345
|
+
[Symbol.dispose](): void;
|
|
346
|
+
}
|
|
347
|
+
export {};
|