Skip to content

Commit c4fa1f2

Browse files
Update docs (#892)
* update tables * fix errors * add more on pairings * fix rendering * fix * fix * fixes * fix parentheses * render * fix * add and reorg references
1 parent f552f63 commit c4fa1f2

File tree

12 files changed

+110
-72
lines changed

12 files changed

+110
-72
lines changed

README.md

+22-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# lambdaworks
2+
23
> From the heights of these towers of fields, forty centuries of mathematics look down on us.
34
45
This library provides efficient implementation of cryptographic primitives used to build proving systems. Along with it, many backends for proving systems are shipped, and compatibility with different frontends is supported.
@@ -32,6 +33,7 @@ So, we decided to build our library, focusing on performance, with clear documen
3233
- [Groth 16](https://github.com/lambdaclass/lambdaworks/tree/main/provers/groth16)
3334

3435
### Crypto
36+
3537
- [Elliptic curves](https://github.com/lambdaclass/lambdaworks/tree/main/math/src/elliptic_curve)
3638
- [Multiscalar multiplication](https://github.com/lambdaclass/lambdaworks/tree/main/math/src/msm)
3739
- [Hashes](https://github.com/lambdaclass/lambdaworks/tree/main/crypto/src/hash)
@@ -41,12 +43,15 @@ Most of math and crypto crates supports no-std without allocation with `no-defau
4143
Both Math and Crypto support wasm with target `wasm32-unknown-unknown`. To see an example of how to use this to deploy a verifier in a browser, check the Cairo Prover wasm-pack verifier.
4244

4345
## Examples - mini apps
46+
4447
- [Merkle Tree CLI](https://github.com/lambdaclass/lambdaworks/tree/main/examples/merkle-tree-cli)
4548
- [Proving Miden](https://github.com/lambdaclass/lambdaworks/tree/main/examples/prove-miden)
4649
- [Shamir's secret sharing](https://github.com/lambdaclass/lambdaworks/tree/main/examples/shamir_secret_sharing)
4750
- [BabySNARK](https://github.com/lambdaclass/lambdaworks/tree/main/examples/baby-snark)
51+
- [Pinocchio](https://github.com/lambdaclass/lambdaworks/tree/main/examples/pinocchio)
4852

4953
## Exercises and Challenges
54+
5055
- [lambdaworks exercises and challenges](https://github.com/lambdaclass/lambdaworks_exercises/tree/main)
5156
- [Roadmap for Sparkling Water Bootcamp](https://github.com/lambdaclass/sparkling_water_bootcamp/blob/main/README.md)
5257

@@ -85,9 +90,9 @@ List of symbols:
8590
| **Elliptic Curves** | **Lambdaworks** | **Arkworks** | **Halo2** | **gnark** | **Constantine** |
8691
| BLS12-381 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
8792
| BLS12-377 | 🏗️ | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: |
88-
| BN-254 | 🏗️ | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
89-
| Pallas | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :heavy_check_mark: |
90-
| Vesta | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :heavy_check_mark: |
93+
| BN-254 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
94+
| Pallas | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :heavy_check_mark: |
95+
| Vesta | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :heavy_check_mark: |
9196
| Bandersnatch | 🏗️ | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: |
9297
| **STARKs** | **Lambdaworks** | **Arkworks** | **Halo2** | **gnark** | **Constantine** |
9398
| STARK Prover | :heavy_check_mark: | :x: | :x: | :x: | :x: |
@@ -158,26 +163,34 @@ To serve the documentation locally, first install both [mdbook](https://rust-lan
158163
make docs
159164
```
160165

161-
## 📚 References
166+
## 📚 References and acknowledgements
162167

163-
The following links, repos and projects have been important in the development of this library and we want to thank and acknowledge them.
168+
The following links, repos, companies and projects have been important in the development of this library and we want to thank and acknowledge them.
164169

165170
- [Starkware](https://starkware.co/)
171+
- [Polygon](https://polygon.technology/)
172+
- [Mina](https://minaprotocol.com/)
173+
- [zcash](https://z.cash/)
174+
- [Matter Labs](https://matter-labs.io/)
175+
- [o1Labs](https://www.o1labs.org/)
176+
- [zkSync](https://zksync.io/)
177+
- [Aleo](https://aleo.org/)
178+
- [Risc0](https://github.com/risc0/risc0)
179+
- [Aztec](https://github.com/AztecProtocol)
180+
- [Ingonyama](https://www.ingonyama.com/)
181+
- [Neptune](https://github.com/Neptune-Crypto)
166182
- [Winterfell](https://github.com/facebook/winterfell)
167183
- [Anatomy of a Stark](https://aszepieniec.github.io/stark-anatomy/overview)
168184
- [Giza](https://github.com/maxgillett/giza)
169185
- [Ministark](https://github.com/andrewmilson/ministark)
170186
- [Sandstorm](https://github.com/andrewmilson/sandstorm)
171187
- [STARK-101](https://starkware.co/stark-101/)
172188
- [starknet-rs](https://github.com/xJonathanLEI/starknet-rs/)
173-
- [Risc0](https://github.com/risc0/risc0)
174-
- [Neptune](https://github.com/Neptune-Crypto)
175189
- [Summary on FRI low degree test](https://eprint.iacr.org/2022/1216)
176190
- [STARKs paper](https://eprint.iacr.org/2018/046)
177191
- [DEEP FRI](https://eprint.iacr.org/2019/336)
178192
- [BrainSTARK](https://aszepieniec.github.io/stark-brainfuck/)
179193
- [Plonky2](https://github.com/mir-protocol/plonky2)
180-
- [Aztec](https://github.com/AztecProtocol)
181194
- [Arkworks](https://github.com/arkworks-rs)
182195
- [Thank goodness it's FRIday](https://vitalik.ca/general/2017/11/22/starks_part_2.html)
183196
- [Diving DEEP FRI](https://blog.lambdaclass.com/diving-deep-fri/)
@@ -190,3 +203,4 @@ The following links, repos and projects have been important in the development o
190203
- [CAIRO whitepaper](https://eprint.iacr.org/2021/1063.pdf)
191204
- [Gnark](https://github.com/Consensys/gnark)
192205
- [Constantine](https://github.com/mratsim/constantine)
206+
- [Plonky3](https://github.com/Plonky3/Plonky3)

bootcamp/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Public repository for exercises, challenges and all the needs of the Sparkling W
77
This first week will be focused on the development of one of the building blocks of Cryptography: Finite Fields.
88

99
### Recommended material:
10+
1011
- [An introduction to mathematical cryptography](https://books.google.com.ar/books/about/An_Introduction_to_Mathematical_Cryptogr.html?id=BHuTQgAACAAJ&source=kp_book_description&redir_esc=y) - Chapter 1.
1112
- [Finite Fields](https://www.youtube.com/watch?v=MAhmV_omOwA&list=PLFX2cij7c2PynTNWDBzmzaD6ij170ILbQ&index=8)
1213
- [Constructing finite fields](https://www.youtube.com/watch?v=JPiXFn9WA5Y&list=PLFX2cij7c2PynTNWDBzmzaD6ij170ILbQ&index=6)
@@ -15,12 +16,14 @@ This first week will be focused on the development of one of the building blocks
1516
- [Mersenne primes](https://eprint.iacr.org/2023/824.pdf)
1617

1718
### Challenges:
19+
1820
- [Implement Montgomery backend for 32 bit fields](https://github.com/lambdaclass/lambdaworks/issues/538).
1921
- [Implement efficient Mersenne prime backend](https://github.com/lambdaclass/lambdaworks/issues/540).
2022
- [Implement efficient backend for pseudo-Mersenne primes](https://github.com/lambdaclass/lambdaworks/issues/393).
2123
- Compare specific field implementations with ordinary Montgomery arithmetic.
2224

2325
### Cryptography content:
26+
2427
- [Serious Cryptography](https://books.google.com.ar/books/about/Serious_Cryptography.html?id=1D-QEAAAQBAJ&source=kp_book_description&redir_esc=y), Chapters 9 & 10.
2528

2629
### Exercises

crypto/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
[Latest Version]: https://img.shields.io/crates/v/lambdaworks-crypto.svg
44
[crates.io]: https://crates.io/crates/lambdaworks-crypto
55

6-
76
## Usage
87

98
Add this to your `Cargo.toml`

docs/src/plonk/SUMMARY.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
- [Recap](./recap.md)
44
- [Protocol](./protocol.md)
55
- [Implementation](./implementation.md)
6-
- [Circuit API](./constraint_system.md)
7-
6+
- [Circuit API](./constraint_system.md)

docs/src/plonk/constraint_system.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Circuit API
2+
23
In this section, we'll discuss how to build your own constraint system to prove the execution of a particular program.
34

45
## Simple Example
@@ -99,5 +100,4 @@ fn main() {
99100
}
100101
```
101102

102-
You can keep composing these functions in order to create more complex systems.
103-
103+
You can keep composing these functions in order to create more complex systems.

docs/src/plonk/implementation.md

+21-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# Implementation
2+
23
In this section we discuss the implementation details of the PLONK algorithm. We use the notation and terminology of the [protocol](./protocol.md) and [recap](./recap.md) sections.
34

4-
At the moment our API supports the backend of PLONK. That is, all the setup, prove and verify algorithms. We temporarily rely on external sources for the definition of a circuit and the creation of the $Q$ and $V$ matrices, as well as the execution of it to obtain the trace matrix $T$. We mainly use gnark temporarily for that purpose.
5+
At the moment our API supports the backend of PLONK, that is, all the setup, prove and verify algorithms. We temporarily rely on external sources for the definition of a circuit and the creation of the $Q$ and $V$ matrices, as well as the execution of it to obtain the trace matrix $T$. We mainly use gnark temporarily for that purpose.
6+
7+
To generate proofs and validate them, we need to feed the algorithms with precomputed values of the $Q$, $V$ and $T$ matrices, and the primitive root of unity $\omega$.
58

6-
So to generate proofs and validate them, we need to feed the algorithms with precomputed values of the $Q$, $V$ and $T$ matrices, and the primitive root of unity $\omega$.
9+
Let's see our API on a test circuit that provides all these values. The program in this case is the one that takes an input $x$, a private input $e$ and computes $y = xe + 5$. As in the toy example of the recap, the output of the program is added to the public inputs and the circuit actually asserts that the output is the claimed value. So more precisely, the prover will generate a proof for the statement `ASSERT(x*e+5==y)`, where both $x,y$ are public inputs.
710

8-
Let us see our API on a test circuit that provides all these values. The program in this case is the one that takes an input $x$, a private input $e$ and computes $y = xe +5$. As in the toy example of the recap, the output of the program is added to the public inputs and the circuit actually asserts that the output is the claimed value. So more precisely, the prover will generate a proof for the statement `ASSERT(x*e+5==y)`, where both $x,y$ are public inputs.
911
# Usage
12+
1013
Here is the happy path.
1114

1215
```rust
@@ -90,16 +93,21 @@ pub struct Witness<F: IsField> {
9093
pub c: Vec<FieldElement<F>>,
9194
}
9295
```
96+
9397
Next the commitment scheme KZG (Kate-Zaverucha-Goldberg) is instantiated.
98+
9499
```rust
95100
let srs = test_srs(common_preprocessed_input.n);
96101
let kzg = KZG::new(srs);
97102
```
98103
The `setup` function performs the setup phase. It only needs the common preprocessed input and the commitment scheme.
104+
99105
```rust
100106
let verifying_key = setup(&common_preprocessed_input, &kzg);
101107
```
102-
It outputs an instance of the struct `VerificationKey`.
108+
109+
It outputs an instance of the struct `VerificationKey`:
110+
103111
```rust
104112
pub struct VerificationKey<G1Point> {
105113
pub qm_1: G1Point,
@@ -113,6 +121,7 @@ pub struct VerificationKey<G1Point> {
113121
pub s3_1: G1Point,
114122
}
115123
```
124+
116125
It stores the commitments of the eight polynomials of the common preprocessed input. The suffix `_1` means it is a commitment. It comes from the notation $[f]_1$, where $f$ is a polynomial.
117126

118127
Then a prover is instantiated
@@ -133,6 +142,7 @@ where
133142
phantom: PhantomData<F>,
134143
}
135144
```
145+
136146
It stores an instance of a commitment scheme and a random field element generator needed for blinding polynomials.
137147

138148
Then the public input is defined. As we mentioned in the recap, the public input contains the output of the program.
@@ -149,7 +159,9 @@ let proof = prover.prove(
149159
&verifying_key,
150160
);
151161
```
162+
152163
The output is an instance of the struct `Proof`.
164+
153165
```rust
154166
pub struct Proof<F: IsField, CS: IsCommitmentScheme<F>> {
155167
// Round 1.
@@ -222,6 +234,7 @@ assert!(verifier.verify(
222234
```
223235

224236
## Padding
237+
225238
All the matrices $Q, V, T, PI$ are padded with dummy rows so that their length is a power of two. To be able to interpolate their columns, we need a primitive root of unity $\omega$ of that order. Given the particular field used in our implementation, that means that the maximum possible size for a circuit is $2^{32}$.
226239

227240
The entries of the dummy rows are filled in with zeroes in the $Q$, $V$ and $PI$ matrices. The $T$ matrix needs to be consistent with the $V$ matrix. Therefore it is filled with the value of the variable with index $0$.
@@ -233,6 +246,7 @@ Some other rows in the $V$ matrix have also dummy values. These are the rows cor
233246
The implementation pretty much follows the rounds as are described in the [protocol](./protocol.md) section. There are a few details that are worth mentioning.
234247

235248
## Commitment Scheme
249+
236250
The commitment scheme we use is the [Kate-Zaverucha-Goldberg](https://www.iacr.org/archive/asiacrypt2010/6477178/6477178.pdf) scheme with the `BLS 12 381` curve and the ate pairing. It can be found in the `commitments` module of the `lambdaworks_crypto` package.
237251

238252
The order $r$ of the cyclic subgroup is
@@ -271,12 +285,14 @@ The internal state of the hasher at the end of this exercise is `message_4 || Ha
271285
The underlying hasher function we use is `h=sha3`.
272286

273287
### Field elements
288+
274289
The result of every challenge is a $256$-bit string, which is interpreted as an integer in big-endian order. A field element is constructed out of it by taking modulo the field order. The prime field used in this implementation has a $255$-bit order. Therefore some field elements are more probable to occur than others because they have more representatives as 256-bit integers.
275290

276291
### Strong Fiat-Shamir
292+
277293
The first messages added to the transcript are all commitments of the polynomials of the common preprocessed input and the values of the public inputs. This prevents a known vulnerability called "weak Fiat-Shamir".
278294
Check out the following resources to learn more about it.
279295

280296
- [What can go wrong (zkdocs)](https://www.zkdocs.com/docs/zkdocs/protocol-primitives/fiat-shamir/#what-can-go-wrong)
281297
- [How not to Prove Yourself: Pitfalls of the Fiat-Shamir Heuristic and Applications to Helios](https://eprint.iacr.org/2016/771.pdf)
282-
- [Weak Fiat-Shamir Attacks on Modern Proof Systems](https://eprint.iacr.org/2023/691)
298+
- [Weak Fiat-Shamir Attacks on Modern Proof Systems](https://eprint.iacr.org/2023/691)

docs/src/plonk/plonk.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ We have written this document with the aim of making it accessible to both novic
88

99
- [Recap](./recap.md)
1010
- [Protocol](./protocol.md)
11-
- [Implementation](./implementation.md)
12-
11+
- [Implementation](./implementation.md)

0 commit comments

Comments
 (0)