Skip to content

Commit 9b01578

Browse files
Merge pull request #965 from ProvableHQ/docs/doc-fixes
[Documentation] Fix inconsistencies in SDK documentation
2 parents 928a7d9 + a94a092 commit 9b01578

File tree

7 files changed

+75
-76
lines changed

7 files changed

+75
-76
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ several TypeScript & JavaScript libraries which provide the following functional
1313
1. [Aleo account management](https://provable.tools/account)
1414
2. [Web-based program execution and deployment](https://provable.tools/develop)
1515
3. [Aleo credit transfers](https://provable.tools/transfer)
16-
4. [Management of program state and data](https://provable.tools/record)
16+
4. [Management of program state and data](https://provable.tools/protocol)
1717
5. [Communication with the Aleo network](https://provable.tools/rest)
18+
6. [Aleo Cryptographic Primitives](https://provable.tools/algebra)
1819

1920
All of this functionality is demonstrated on [Provable.tools](https://provable.tools).
2021

@@ -44,8 +45,6 @@ start with working examples should start here.
4445

4546
## 3. Aleo Wasm - Zero-Knowledge Algorithms in JavaScript + WebAssembly
4647
<a href="https://www.npmjs.com/package/@provablehq/wasm"> <img alt="Create Leo App" src="https://img.shields.io/npm/l/%40provablehq%2Fwasm?label=NPM%20-%20Aleo%20Wasm&labelColor=green&color=blue"></a>
47-
<a href="https://www.npmjs.com/package/@provablehq/nodejs"> <img alt="Create Leo App" src="https://img.shields.io/npm/l/%40provablehq%2Fnodejs?label=NPM%20-%20Aleo%20Nodejs&labelColor=green&color=blue"></a>
48-
<a href="https://crates.io/crates/aleo-wasm"> <img alt="Aleo-Wasm" src="https://img.shields.io/crates/v/aleo-wasm.svg?color=neon"></a>
4948

5049
Aleo Wasm is a Rust crate which compiles the Aleo source code responsible for creating and executing zero-knowledge programs into
5150
WebAssembly.

create-leo-app/template-react-leo/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22

33
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/ProvableHQ/sdk/tree/mainnet/create-leo-app/template-react-leo)
44

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.
76

87
This template includes a Leo program that is loaded by the web app located in
98
the `helloworld` directory.
109

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
13-
workers.
14-
1510
### Start in development mode
1611

1712
```bash

create-leo-app/template-react-managed-worker/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@
33
> [!NOTE]
44
> This is an experimental template not recommended for use
55
6-
This template provides a minimal setup to get React and Aleo working in Vite with HMR and some ESLint rules.
7-
8-
Note: Webpack is currently used for production builds due to a [bug](https://github.com/vitejs/vite/issues/13367) with Vite related to nested workers.
6+
This template provides a minimal setup to get React and Aleo working in Webpack or Vite with HMR and some ESLint rules.

create-leo-app/template-react-ts/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22

33
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/ProvableHQ/sdk/tree/mainnet/create-leo-app/template-react)
44

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.
76

87
This template includes a Leo program that is loaded by the web app located in
98
the `helloworld` directory.
109

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
13-
workers.
14-
1510
### Start in development mode
1611

1712
```bash

sdk/README.md

Lines changed: 68 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,23 @@
1212

1313
## Tools for Building Zero-Knowledge Web Apps
1414

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.
1716

1817
## Overview
1918

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.
2224

2325
The Aleo SDK provides the following functionality (Click to see examples):
2426
1. [Aleo account management](https://provable.tools/account)
2527
2. [Web-based program execution and deployment](https://provable.tools/develop)
2628
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)
2932

3033
## Table of Contents
3134

@@ -64,11 +67,15 @@ To clone the repository, run:
6467

6568
`git clone [email protected]:ProvableHQ/sdk.git`
6669

67-
### NPM
70+
### NPM & YARN
6871

6972
To install the Aleo SDK from NPM run:
7073

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`.
7279

7380
### Build from source
7481

@@ -96,30 +103,35 @@ templates in common web frameworks such as React that can be used as a starting
96103
Developers can get started immediately with create-leo-app by running:
97104
`npm create leo-app@latest`
98105

99-
### provable.tools
106+
### Provable.tools
100107

101108
Additionally, the SDK powers [provable.tools](https://provable.tools) - a React app that provides a graphical interface for most
102109
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).
104111

105112
## Usage
106113

107114
## 1. Create an Aleo Account
108115

109116
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:
112121

113-
These keys include:
114122
#### 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.
117126

118127
#### View Key
119128
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+
121132
#### Compute Key
122133
The `Compute Key` can be used to trustlessly run applications and generate transactions on a user's behalf.
134+
123135
#### Address
124136
The `Address` is a user's unique public identifier. It serves as an address for a user to receive both Aleo
125137
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
142154

143155
### 2.1 Aleo Programs
144156

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.
147160

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.
151163

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.
154166

155167
Documentation for both languages can be found at [docs.leo-lang.org](https://docs.leo-lang.org/).
156168

@@ -179,44 +191,45 @@ function hello:
179191

180192
### 2.2 Program Execution Model
181193

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.
183215

184216
The `ProgramManager` object encapsulates the functionality for executing programs and making zero-knowledge proofs about
185217
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.
211219

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.
216228

217-
### 2.3 Multithreading
229+
### 2.3 WebAssembly Initialization
218230

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:
220233

221234
```typescript
222235
import { Account, initThreadPool } from '@provablehq/sdk';

sdk/docs/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

wasm/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
[![Crates.io](https://img.shields.io/crates/v/aleo-wasm.svg?color=neon)](https://crates.io/crates/aleo-wasm)
21
[![Authors](https://img.shields.io/badge/authors-Aleo-orange.svg)](https://provable.com)
32
[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](./LICENSE.md)
43

5-
[![github]](https://github.com/ProvableHQ/sdk)&ensp;[![crates-io]](https://crates.io/crates/aleo-wasm)&ensp;[![docs-rs]](https://docs.rs/aleo-wasm/latest/aleo-wasm/)
4+
[![github]](https://github.com/ProvableHQ/sdk)
65

76
[github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
87
[crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust

0 commit comments

Comments
 (0)