@provablehq/sdk 0.8.0 → 0.8.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.
Files changed (104) hide show
  1. package/README.md +70 -57
  2. package/package.json +23 -23
  3. package/dist/mainnet/account.d.ts +0 -137
  4. package/dist/mainnet/browser.d.ts +0 -35
  5. package/dist/mainnet/browser.js +0 -934
  6. package/dist/mainnet/browser.js.map +0 -1
  7. package/dist/mainnet/constants.d.ts +0 -34
  8. package/dist/mainnet/function-key-provider.d.ts +0 -349
  9. package/dist/mainnet/managed-worker.d.ts +0 -3
  10. package/dist/mainnet/models/blockJSON.d.ts +0 -21
  11. package/dist/mainnet/models/confirmed_transaction.d.ts +0 -9
  12. package/dist/mainnet/models/deployment/deploymentJSON.d.ts +0 -6
  13. package/dist/mainnet/models/deployment/deploymentObject.d.ts +0 -6
  14. package/dist/mainnet/models/execution/executionJSON.d.ts +0 -11
  15. package/dist/mainnet/models/execution/executionObject.d.ts +0 -11
  16. package/dist/mainnet/models/finalizeJSON.d.ts +0 -6
  17. package/dist/mainnet/models/functionObject.d.ts +0 -8
  18. package/dist/mainnet/models/input/inputJSON.d.ts +0 -9
  19. package/dist/mainnet/models/input/inputObject.d.ts +0 -14
  20. package/dist/mainnet/models/output/outputJSON.d.ts +0 -6
  21. package/dist/mainnet/models/output/outputObject.d.ts +0 -17
  22. package/dist/mainnet/models/owner/ownerJSON.d.ts +0 -4
  23. package/dist/mainnet/models/owner/ownerObject.d.ts +0 -5
  24. package/dist/mainnet/models/plaintext/array.d.ts +0 -3
  25. package/dist/mainnet/models/plaintext/literal.d.ts +0 -1
  26. package/dist/mainnet/models/plaintext/plaintext.d.ts +0 -5
  27. package/dist/mainnet/models/plaintext/struct.d.ts +0 -5
  28. package/dist/mainnet/models/transaction/transactionJSON.d.ts +0 -11
  29. package/dist/mainnet/models/transaction/transactionObject.d.ts +0 -14
  30. package/dist/mainnet/models/transition/transitionJSON.d.ts +0 -13
  31. package/dist/mainnet/models/transition/transitionObject.d.ts +0 -15
  32. package/dist/mainnet/network-client.d.ts +0 -358
  33. package/dist/mainnet/node-polyfill.d.ts +0 -5
  34. package/dist/mainnet/node-polyfill.js +0 -304
  35. package/dist/mainnet/node-polyfill.js.map +0 -1
  36. package/dist/mainnet/node.d.ts +0 -2
  37. package/dist/mainnet/node.js +0 -13
  38. package/dist/mainnet/node.js.map +0 -1
  39. package/dist/mainnet/offline-key-provider.d.ts +0 -348
  40. package/dist/mainnet/polyfill/crypto.d.ts +0 -1
  41. package/dist/mainnet/polyfill/fetch.d.ts +0 -1
  42. package/dist/mainnet/polyfill/shared.d.ts +0 -1
  43. package/dist/mainnet/polyfill/worker.d.ts +0 -1
  44. package/dist/mainnet/polyfill/xmlhttprequest.d.ts +0 -1
  45. package/dist/mainnet/program-manager-D6bnpC8Y.js +0 -2338
  46. package/dist/mainnet/program-manager-D6bnpC8Y.js.map +0 -1
  47. package/dist/mainnet/program-manager.d.ts +0 -640
  48. package/dist/mainnet/record-provider.d.ts +0 -236
  49. package/dist/mainnet/utils.d.ts +0 -4
  50. package/dist/mainnet/wasm.d.ts +0 -1
  51. package/dist/mainnet/worker.d.ts +0 -9
  52. package/dist/mainnet/worker.js +0 -78
  53. package/dist/mainnet/worker.js.map +0 -1
  54. package/dist/testnet/account.d.ts +0 -137
  55. package/dist/testnet/browser.d.ts +0 -35
  56. package/dist/testnet/browser.js +0 -934
  57. package/dist/testnet/browser.js.map +0 -1
  58. package/dist/testnet/constants.d.ts +0 -34
  59. package/dist/testnet/function-key-provider.d.ts +0 -349
  60. package/dist/testnet/managed-worker.d.ts +0 -3
  61. package/dist/testnet/models/blockJSON.d.ts +0 -21
  62. package/dist/testnet/models/confirmed_transaction.d.ts +0 -9
  63. package/dist/testnet/models/deployment/deploymentJSON.d.ts +0 -6
  64. package/dist/testnet/models/deployment/deploymentObject.d.ts +0 -6
  65. package/dist/testnet/models/execution/executionJSON.d.ts +0 -11
  66. package/dist/testnet/models/execution/executionObject.d.ts +0 -11
  67. package/dist/testnet/models/finalizeJSON.d.ts +0 -6
  68. package/dist/testnet/models/functionObject.d.ts +0 -8
  69. package/dist/testnet/models/input/inputJSON.d.ts +0 -9
  70. package/dist/testnet/models/input/inputObject.d.ts +0 -14
  71. package/dist/testnet/models/output/outputJSON.d.ts +0 -6
  72. package/dist/testnet/models/output/outputObject.d.ts +0 -17
  73. package/dist/testnet/models/owner/ownerJSON.d.ts +0 -4
  74. package/dist/testnet/models/owner/ownerObject.d.ts +0 -5
  75. package/dist/testnet/models/plaintext/array.d.ts +0 -3
  76. package/dist/testnet/models/plaintext/literal.d.ts +0 -1
  77. package/dist/testnet/models/plaintext/plaintext.d.ts +0 -5
  78. package/dist/testnet/models/plaintext/struct.d.ts +0 -5
  79. package/dist/testnet/models/transaction/transactionJSON.d.ts +0 -11
  80. package/dist/testnet/models/transaction/transactionObject.d.ts +0 -14
  81. package/dist/testnet/models/transition/transitionJSON.d.ts +0 -13
  82. package/dist/testnet/models/transition/transitionObject.d.ts +0 -15
  83. package/dist/testnet/network-client.d.ts +0 -358
  84. package/dist/testnet/node-polyfill.d.ts +0 -5
  85. package/dist/testnet/node-polyfill.js +0 -304
  86. package/dist/testnet/node-polyfill.js.map +0 -1
  87. package/dist/testnet/node.d.ts +0 -2
  88. package/dist/testnet/node.js +0 -13
  89. package/dist/testnet/node.js.map +0 -1
  90. package/dist/testnet/offline-key-provider.d.ts +0 -348
  91. package/dist/testnet/polyfill/crypto.d.ts +0 -1
  92. package/dist/testnet/polyfill/fetch.d.ts +0 -1
  93. package/dist/testnet/polyfill/shared.d.ts +0 -1
  94. package/dist/testnet/polyfill/worker.d.ts +0 -1
  95. package/dist/testnet/polyfill/xmlhttprequest.d.ts +0 -1
  96. package/dist/testnet/program-manager-DePEqzhz.js +0 -2338
  97. package/dist/testnet/program-manager-DePEqzhz.js.map +0 -1
  98. package/dist/testnet/program-manager.d.ts +0 -640
  99. package/dist/testnet/record-provider.d.ts +0 -236
  100. package/dist/testnet/utils.d.ts +0 -4
  101. package/dist/testnet/wasm.d.ts +0 -1
  102. package/dist/testnet/worker.d.ts +0 -9
  103. package/dist/testnet/worker.js +0 -78
  104. package/dist/testnet/worker.js.map +0 -1
package/README.md CHANGED
@@ -12,20 +12,23 @@
12
12
 
13
13
  ## Tools for Building Zero-Knowledge Web Apps
14
14
 
15
- The Aleo SDK is a collection of JavaScript libraries for building zero-knowledge web applications in both the browser
16
- and Node.js.
15
+ The Aleo SDK is a JavaScript library for building zero-knowledge web applications in both web browsers and Node.js.
17
16
 
18
17
  ## Overview
19
18
 
20
- Aleo provides the ability to run programs with the power of zero-knowledge. The Aleo SDK provides the tools to use these programs
21
- within the browser and all other levels of the web stack to build privacy-preserving applications.
19
+ Aleo provides the ability for users to create programs and execute them in zero knowledge through the usage of the
20
+ [Varuna ZKSnark](https://alphaswapdex.medium.com/part-ii-the-technical-architecture-of-the-aleo-blockchain-marlin-and-varuna-71c6d48eb355).
21
+
22
+ The Aleo SDK provides the tools to use these programs both within Nodejs and web browsers allowing users to build
23
+ privacy-preserving applications throughout the web stack.
22
24
 
23
25
  The Aleo SDK provides the following functionality (Click to see examples):
24
26
  1. [Aleo account management](https://provable.tools/account)
25
27
  2. [Web-based program execution and deployment](https://provable.tools/develop)
26
28
  3. [Aleo credit transfers](https://provable.tools/transfer)
27
- 4. [Management of program state and data](https://provable.tools/record)
28
- 5. [Communication with the Aleo network](https://provable.tools/rest)
29
+ 4. [Management of program state and data](https://provable.tools/protocol)
30
+ 5. [Interaction with the Aleo network](https://provable.tools/rest)
31
+ 6. [Exposure of Core Aleo Cryptographic Primtives](https://provable.tools/algebra)
29
32
 
30
33
  ## Table of Contents
31
34
 
@@ -64,11 +67,15 @@ To clone the repository, run:
64
67
 
65
68
  `git clone git@github.com:ProvableHQ/sdk.git`
66
69
 
67
- ### NPM
70
+ ### NPM & YARN
68
71
 
69
72
  To install the Aleo SDK from NPM run:
70
73
 
71
- `npm install @provablehq/sdk` in your own project's root, or from within this repo run `cd sdk && yarn add @provablehq/sdk`.
74
+ `npm install @provablehq/sdk` in your own project's root,
75
+
76
+ To install the Aleo SDK from Yarn run:
77
+
78
+ `yarn add @provablehq/sdk`.
72
79
 
73
80
  ### Build from source
74
81
 
@@ -90,36 +97,41 @@ In your project's `package.json`, ensure that the following line is added above
90
97
 
91
98
  ### Create Leo App
92
99
  A set of fully functional examples of zero-knowledge web apps can be found in
93
- [create-leo-app](https://github.com/ProvableHQ/sdk/tree/testnet3/create-leo-app). Create Leo App provides several web app
100
+ [create-leo-app](https://github.com/ProvableHQ/sdk/tree/mainnet/create-leo-app). Create Leo App provides several web app
94
101
  templates in common web frameworks such as React that can be used as a starting point for building zero-knowledge web apps.
95
102
 
96
103
  Developers can get started immediately with create-leo-app by running:
97
104
  `npm create leo-app@latest`
98
105
 
99
- ### provable.tools
106
+ ### Provable.tools
100
107
 
101
108
  Additionally, the SDK powers [provable.tools](https://provable.tools) - a React app that provides a graphical interface for most
102
109
  of the functionality provided by the SDK and can be used as a reference for usage of the SDK. Source code for provable.tools
103
- can be found [in the SDK repo here](https://github.com/ProvableHQ/sdk/tree/testnet3/website).
110
+ can be found [in the website directory of the SDK repo](https://github.com/ProvableHQ/sdk/tree/mainnet/website).
104
111
 
105
112
  ## Usage
106
113
 
107
114
  ## 1. Create an Aleo Account
108
115
 
109
116
  The first step in operating a zero-knowledge web application is creating a private key which serves as a cryptographic
110
- identity for a user. After a private key is generated, several keys that enable specialized methods of interacting with
111
- Aleo programs can be derived.
117
+ identity for a user. From it, the user's address and several other useful cryptographic keys that comprise the user's
118
+ identity are derived.
119
+
120
+ The total list of keys which comprise an Aleo account are as follows:
112
121
 
113
- These keys include:
114
122
  #### Private Key
115
- The `Private Key` can be treated as the identity of a user. It is used for critical functions like authorizing zero-knowledge
116
- program execution, decrypting private data, and proving ownership of user data.
123
+ The `Private Key` can be thought of as the identity of a user and is the most sensitive of the keys within an Aleo account.
124
+ It is used to sign and create new program executions, to encrypt & decrypt private data within a zero knowledge function
125
+ execution, and to generate signatures, commitments, and other key material used in zero-knowledge proofs.
117
126
 
118
127
  #### View Key
119
128
  The `View Key` is derived from the private key and can be used to both decrypt encrypted data owned by a user and prove
120
- ownership of that data.
129
+ ownership of that data. Specific usages of this key include, determining ownership of records, decrypting records,
130
+ and decrypting private inputs or outputs of a zero-knowledge program generated by the owner of the private key.
131
+
121
132
  #### Compute Key
122
133
  The `Compute Key` can be used to trustlessly run applications and generate transactions on a user's behalf.
134
+
123
135
  #### Address
124
136
  The `Address` is a user's unique public identifier. It serves as an address for a user to receive both Aleo
125
137
  credits and data from other zero-knowledge Aleo programs.
@@ -142,15 +154,15 @@ Please note that all keys are considered sensitive information and should be sto
142
154
 
143
155
  ### 2.1 Aleo Programs
144
156
 
145
- Aleo programs provide the ability for users to make any input or output of a program private and prove that the program
146
- was run correctly. Keeping program inputs and outputs private allows developers to build privacy into their applications.
157
+ Aleo programs provide the ability for users to make any input or output of a program function private and prove that the
158
+ function was run correctly without exposing the values of these inputs or outputs. This allows developers to build
159
+ applications with complete data privacy.
147
160
 
148
- Zero-knowledge programs are written in one of two languages:
149
- 1. [Leo](https://docs.leo-lang.org/leo/language): A high-level, developer-friendly language for developing
150
- zero-knowledge programs.
161
+ Zero-knowledge programs on Aleo are written in one of two languages:
162
+ 1. [Leo](https://docs.leo-lang.org/leo/language): A high-level, developer-friendly language for developing zero-knowledge programs.
151
163
 
152
- 2. [Aleo Instructions](https://docs.leo-lang.org/aleo/language): A low-level language that provides developers with fine-grained control over the execution flow of zero-knowledge programs. Leo code is compiled into Aleo Instructions
153
- under the hood.
164
+ 2. [Aleo Instructions](https://docs.leo-lang.org/aleo/language): A low-level language that provides developers with fine-grained control over the execution
165
+ flow of zero-knowledge programs. Leo code is compiled into Aleo Instructions under the hood.
154
166
 
155
167
  Documentation for both languages can be found at [docs.leo-lang.org](https://docs.leo-lang.org/).
156
168
 
@@ -179,44 +191,45 @@ function hello:
179
191
 
180
192
  ### 2.2 Program Execution Model
181
193
 
182
- The SDK provides the ability to execute Aleo programs 100% client-side within the browser.
194
+ #### Lifecycle of a Program Execution
195
+
196
+ When an Aleo program is executed, the following steps occur:
197
+
198
+ 1. **Compilation into an R1CS Circuit:** The function code is compiled into an R1CS circuit and checked for correctness
199
+ (or more formally, satisfiability).
200
+ 2. **Proof of Satisfiability:** The valid R1CS circuit is encoded into a polynomial representation that is then turned
201
+ into a Varuna ZKSnark proof which proves both that the executor is executing the correct function and that the inputs
202
+ lead to the stated outputs.
203
+ 3. **Transaction Generation:** The zero knowledge proof is stored within an `Execution Transaction` and sent to the Aleo
204
+ network. This transaction is then verified by the Aleo network's validator nodes.
205
+ 4. **Optional Execution of On-Chain Logic:** Any Aleo function can optionally contain on-chain logic to be executed by
206
+ the Aleo Network's validator nodes. This logic can be used to do further computations and update on-chain key-value
207
+ stores called `mappings` which store a program's public on-chain state.
208
+ 5. **Addition to the Ledger**: If the proof is valid, the transaction is added to the Aleo ledger within a
209
+ specific block and all changes the execution made to the program's state are recorded within the Aleo blockchain.
210
+
211
+
212
+ #### Program Execution with the Aleo SDK
213
+
214
+ The SDK provides the ability to execute Aleo programs 100% client-side within the browser or Node.js.
183
215
 
184
216
  The `ProgramManager` object encapsulates the functionality for executing programs and making zero-knowledge proofs about
185
217
  them. Under the hood it uses cryptographic code compiled from [SnarkVM](https://docs.leo-lang.org/aleo) into WebAssembly
186
- with JavaScript bindings that allow for the execution of Aleo programs fully within the browser. Users interested in lower-level
187
- details on how this is achieved can visit the [aleo-wasm](https://www.npmjs.com/package/@provablehq/wasm) crate.
188
-
189
- The basic execution flow of a program is as follows:
190
- 1. A web app is loaded with an instance of the `ProgramManager` object.
191
- 2. The SDK wasm modules are loaded into the browser's WebAssembly runtime.
192
- 2. An Aleo program in `Aleo Instructions` format is loaded into the `ProgramManager` as a wasm object.
193
- 3. The web app provides a user input form for the program.
194
- 4. The user submits the inputs and the zero-knowledge execution is performed entirely within the browser via WebAssembly.
195
- 5. The result is returned to the user.
196
- 6. A fully encrypted zero-knowledge transcript of the execution is optionally sent to the Aleo network.
197
-
198
- A diagramatic representation of the program execution flow is shown below:
199
- ```mermaid
200
- graph LR
201
- p1[Leo Program]
202
- p2[Aleo Instructions]
203
-
204
- subgraph Browser Web-App
205
- subgraph ProgramManager
206
- subgraph Aleo-Wasm-Module
207
- in-memory-program
208
- end
209
- end
210
- end
218
+ with JavaScript bindings that allow for the execution of Aleo programs fully within the browser.
211
219
 
212
- p1-->p2--load program--oin-memory-program-.ZK result.->user
213
- user-.user input.->in-memory-program
214
- in-memory-program-."ZK result (Optional)".->Aleo-Network
215
- ```
220
+ The basic execution flow of a program within the SDK is as follows:
221
+ 1. A web app creates an instance of the `ProgramManager` object.
222
+ 2. The SDK wasm modules are loaded into the `WebAssembly` runtime.
223
+ 3. An Aleo program in `Aleo Instructions` format is loaded into `WebAssembly` via the `ProgramManager` object.
224
+ 4. The web or node app takes user input and begins execution of a program.
225
+ 5. The execution is performed entirely within Node.js or the browser via WebAssembly.
226
+ 6. The result is returned to the javascript environment in the form of an `Execution Transaction`.
227
+ 7. The execution is sent to the Aleo network.
216
228
 
217
- ### 2.3 Multithreading
229
+ ### 2.3 WebAssembly Initialization
218
230
 
219
- You can enable multithreading by calling the `initThreadPool` function. This will run the SDK on multiple workers, which significantly speeds up performance:
231
+ You can enable multithreading by calling the `initThreadPool` function. This will run the SDK on multiple workers,
232
+ which significantly speeds up performance:
220
233
 
221
234
  ```typescript
222
235
  import { Account, initThreadPool } from '@provablehq/sdk';
@@ -421,7 +434,7 @@ Program execution is a computationally-expensive process. For this reason, it is
421
434
  web workers. Create-Leo-App will automatically create a web worker for you that performs the execution called `worker.js`.
422
435
 
423
436
 
424
- A full example of this implementation can be found [here](https://github.com/ProvableHQ/sdk/tree/testnet3/create-leo-app/template-vanilla)
437
+ A full example of this implementation can be found [here](https://github.com/ProvableHQ/sdk/tree/mainnet/create-leo-app/template-vanilla)
425
438
 
426
439
  ## 3. Aleo Credit Transfers
427
440
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@provablehq/sdk",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "A Software Development Kit (SDK) for Zero-Knowledge Transactions",
5
5
  "collaborators": [
6
6
  "The Provable Team"
@@ -48,34 +48,34 @@
48
48
  "homepage": "https://github.com/ProvableHQ/sdk#readme",
49
49
  "dependencies": {
50
50
  "@provablehq/wasm": "^0.8.0",
51
- "comlink": "^4.4.1",
52
- "core-js": "^3.38.1",
53
- "mime": "^3.0.0",
54
- "sync-request": "^6.1.0"
51
+ "comlink": "^4.4.2",
52
+ "core-js": "^3.40.0",
53
+ "mime": "^4.0.6",
54
+ "sync-request": "^6.1.0",
55
+ "xmlhttprequest-ssl": "^3.1.0"
55
56
  },
56
57
  "devDependencies": {
57
- "@rollup/plugin-replace": "^5.0.5",
58
- "@types/chai": "^4.3.16",
59
- "@types/mime": "^3.0.1",
60
- "@types/mocha": "^10.0.7",
58
+ "@rollup/plugin-replace": "^6.0.2",
59
+ "@types/chai": "^5.0.1",
60
+ "@types/mocha": "^10.0.10",
61
61
  "@types/sinon": "^17.0.3",
62
- "@typescript-eslint/eslint-plugin": "^5.41.0",
63
- "@typescript-eslint/parser": "^5.41.0",
62
+ "@typescript-eslint/eslint-plugin": "^8.22.0",
63
+ "@typescript-eslint/parser": "^8.22.0",
64
64
  "better-docs": "^2.7.3",
65
- "chai": "^5.1.1",
65
+ "chai": "^5.1.2",
66
66
  "clean-jsdoc-theme": "^4.3.0",
67
67
  "cpr": "^3.0.1",
68
- "eslint": "^8.26.0",
69
- "eslint-config-prettier": "^8.5.0",
70
- "eslint-plugin-import": "^2.26.0",
71
- "glob": "^10.4.5",
72
- "jsdoc": "^3.6.11",
73
- "mocha": "^10.7.0",
74
- "prettier": "2.7.1",
75
- "rimraf": "^5.0.1",
76
- "rollup": "^3.27.2",
68
+ "eslint": "^9.19.0",
69
+ "eslint-config-prettier": "^10.0.1",
70
+ "eslint-plugin-import": "^2.31.0",
71
+ "glob": "^11.0.1",
72
+ "jsdoc": "^4.0.4",
73
+ "mocha": "^11.1.0",
74
+ "prettier": "3.4.2",
75
+ "rimraf": "^6.0.1",
76
+ "rollup": "^4.32.0",
77
77
  "rollup-plugin-typescript2": "^0.36.0",
78
- "sinon": "^18.0.0",
79
- "typescript": "^5.2.2"
78
+ "sinon": "^19.0.2",
79
+ "typescript": "^5.7.3"
80
80
  }
81
81
  }
@@ -1,137 +0,0 @@
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 {};
@@ -1,35 +0,0 @@
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 { InputJSON } from "./models/input/inputJSON";
13
- import { InputObject } from "./models/input/inputObject";
14
- import { OutputJSON } from "./models/output/outputJSON";
15
- import { OutputObject } from "./models/output/outputObject";
16
- import { OwnerJSON } from "./models/owner/ownerJSON";
17
- import { PlaintextArray } from "./models/plaintext/array";
18
- import { PlaintextLiteral } from "./models/plaintext/literal";
19
- import { PlaintextObject } from "./models/plaintext/plaintext";
20
- import { PlaintextStruct } from "./models/plaintext/struct";
21
- import { TransactionJSON } from "./models/transaction/transactionJSON";
22
- import { TransactionObject } from "./models/transaction/transactionObject";
23
- import { TransitionJSON } from "./models/transition/transitionJSON";
24
- import { TransitionObject } from "./models/transition/transitionObject";
25
- import { AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, CachedKeyPair, FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider";
26
- import { OfflineKeyProvider, OfflineSearchParams } from "./offline-key-provider";
27
- import { BlockHeightSearch, NetworkRecordProvider, RecordProvider, RecordSearchParams } from "./record-provider";
28
- declare function initializeWasm(): Promise<void>;
29
- export { createAleoWorker } from "./managed-worker";
30
- export { ProgramManager } from "./program-manager";
31
- export { logAndThrow } from "./utils";
32
- export { Address, Ciphertext, Execution as FunctionExecution, ExecutionResponse, Field, Group, OfflineQuery, Plaintext, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Signature, Scalar, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "./wasm";
33
- export { initializeWasm };
34
- 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";
35
- export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, CachedKeyPair, ConfirmedTransactionJSON, DeploymentJSON, DeploymentObject, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, InputJSON, InputObject, KeySearchParams, Metadata, NetworkRecordProvider, ProgramImports, OfflineKeyProvider, OfflineSearchParams, OwnerJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, OutputJSON, OutputObject, RecordProvider, RecordSearchParams, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, VerifyingKeys, };