You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<ahref="https://www.npmjs.com/package/@provablehq/wasm"> <imgalt="Create Leo App"src="https://img.shields.io/npm/l/%40provablehq%2Fwasm?label=NPM%20-%20Aleo%20Wasm&labelColor=green&color=blue"></a>
47
-
<ahref="https://www.npmjs.com/package/@provablehq/nodejs"> <imgalt="Create Leo App"src="https://img.shields.io/npm/l/%40provablehq%2Fnodejs?label=NPM%20-%20Aleo%20Nodejs&labelColor=green&color=blue"></a>
Copy file name to clipboardExpand all lines: create-leo-app/template-react-leo/README.md
+1-6Lines changed: 1 addition & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,16 +2,11 @@
2
2
3
3
[](https://stackblitz.com/fork/github/ProvableHQ/sdk/tree/mainnet/create-leo-app/template-react-leo)
4
4
5
-
This template provides a minimal setup to get React and Aleo working in Vite
6
-
with HMR and some ESLint rules.
5
+
This template provides a minimal setup to get React and Aleo working in Webpack or Vite with HMR and some ESLint rules.
7
6
8
7
This template includes a Leo program that is loaded by the web app located in
9
8
the `helloworld` directory.
10
9
11
-
Note: Webpack is currently used for production builds due to a
12
-
[bug](https://github.com/vitejs/vite/issues/13367) with Vite related to nested
Copy file name to clipboardExpand all lines: create-leo-app/template-react-ts/README.md
+1-6Lines changed: 1 addition & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,16 +2,11 @@
2
2
3
3
[](https://stackblitz.com/fork/github/ProvableHQ/sdk/tree/mainnet/create-leo-app/template-react)
4
4
5
-
This template provides a minimal setup to get React and Aleo working in Vite
6
-
with HMR and some ESLint rules.
5
+
This template provides a minimal setup to get React and Aleo working in Webpack or Vite with HMR and some ESLint rules.
7
6
8
7
This template includes a Leo program that is loaded by the web app located in
9
8
the `helloworld` directory.
10
9
11
-
Note: Webpack is currently used for production builds due to a
12
-
[bug](https://github.com/vitejs/vite/issues/13367) with Vite related to nested
`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
@@ -96,30 +103,35 @@ templates in common web frameworks such as React that can be used as a starting
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/mainnet/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.
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,
0 commit comments