Skip to content

Commit fc75ade

Browse files
uri-99NicolasRampoldientropidelicglpecile
authored
docs: re enable devnet infra guide in gitbook (#631)
Co-authored-by: NicolasRampoldi <58613770+NicolasRampoldi@users.noreply.github.com> Co-authored-by: Mariano A. Nicolini <mariano.nicolini.91@gmail.com> Co-authored-by: Gian <58370608+glpecile@users.noreply.github.com>
1 parent 5adf6dc commit fc75ade

7 files changed

Lines changed: 532 additions & 333 deletions

File tree

docs/SUMMARY.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
* [Supported Verifiers](architecture/0_supported_verifiers.md)
1515
* [Key Terms](architecture/0b_key_terms.md)
1616
* [Fast mode](architecture/1_fast_mode.md)
17-
* [Batcher](./architecture/components/1_batcher.md)
18-
* [Payment Service Contract](./architecture/components/2_payment_service_contract.md)
19-
* [Service Manager Contract](./architecture/components/3_service_manager_contract.md)
20-
* [Operator](./architecture/components/4_operator.md)
21-
* [Aggregator](./architecture/components/5_aggregator.md)
22-
* [Explorer](./architecture/components/6_explorer.md)
17+
* [Batcher](./architecture/components/1_batcher.md)
18+
* [Payment Service Contract](./architecture/components/2_payment_service_contract.md)
19+
* [Service Manager Contract](./architecture/components/3_service_manager_contract.md)
20+
* [Operator](./architecture/components/4_operator.md)
21+
* [Aggregator](./architecture/components/5_aggregator.md)
22+
* [Explorer](./architecture/components/6_explorer.md)
2323
* [Aggregation mode](architecture/2_aggregation_mode.md)
2424

2525
## Guides
@@ -28,9 +28,9 @@
2828
* [Integrating Aligned into your Application](guides/2_integrating_aligned_into_your_application.md)
2929
* [SDK](guides/1_SDK.md)
3030
* [Generating proofs for Aligned](guides/3_generating_proofs.md)
31-
* [Contract Addresses](guides/4_contract_addresses.md)
32-
33-
<!-- * [Setup Aligned](developer_guides/2_setup_aligned.md) -->
31+
* [Generating & submitting proofs of Rust code with ZKRust](guides/4_using_zkrust.md)
32+
* [Setup Aligned Infrastructure Locally](guides/5_setup_aligned.md)
33+
* [Contract Addresses](guides/6_contract_addresses.md)
3434

3535
## Operators
3636

@@ -41,8 +41,10 @@
4141
* [All the proof aggregation solutions will use RISC-V zkvms](https://mirror.xyz/0x7794D1c55568270A81D8Bf39e1bcE96BEaC10901/5JfikCrjdHsyqGCpqvbakrA8DZHIgj0d90i9tVOTink)
4242
* [Manifesto](https://mirror.xyz/0x7794D1c55568270A81D8Bf39e1bcE96BEaC10901/rOya8TwZvj_8kTpjDPVwTuNc1UcS0VLUr1t2nhCxYj8)
4343

44-
## Contacts
44+
## Socials
4545

4646
* [Telegram Group](https://t.me/aligned_layer)
4747
* [Twitter/X](https://twitter.com/alignedlayer)
4848
* [Discord](https://discord.gg/alignedlayer)
49+
* [Website](https://alignedlayer.com)
50+
* [Github](https://github.com/yetanotherco/aligned_layer)
Lines changed: 62 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
# How to create a Gnark Plonk proof
1+
# How to create a Gnark Plonk proof
22

3-
## Step 1 : Set up your enviroment
3+
## Step 1: Set up your environment
44

5-
- 1 Install Go: Make suere you have Go installed. You can download it from [here](https://go.dev/doc/install)
5+
- 1 Install Go: Make sure you have Go installed. You can download it from [here](https://go.dev/doc/install)
66

7-
- 2 Initialize a Go Module: Create a new directory for your project and initializa a Go module
7+
- 2 Initialize a Go Module: Create a new directory for your project and initialize a Go module
88

99
```bash=
1010
mkdir gnark_plonk_circuit
1111
cd gnark_plonk_circuit
1212
go mod init gnark_plonk_circuit
1313
```
1414

15-
- 3 Install Gnark: Add the library to your project
15+
- 3 Install Gnark: Add the library to your project
1616

1717
```bash=
1818
go get github.com/consensys/gnark@v0.10.0
1919
```
2020

21-
22-
23-
## Step 2: Import dependencies
21+
## Step 2: Import dependencies
2422

2523
```bash=
2624
import (
@@ -36,37 +34,34 @@
3634
)
3735
```
3836

39-
Here's what each package is used for:
40-
41-
37+
Here's what each package is used for:
4238

4339
```fmt```: Standard Go library for formatted input/output.
4440

4541
```log```: Standard Go library for event logging.
4642

47-
```os```: Standard Go library for interacting with the operating system.
48-
49-
```path/filepath```: Standard Go library for portable file path manipulation.
43+
```os```: Standard Go library for interacting with the operating system.
5044

51-
```github.com/consensys/gnark-crypto/ecc```: Provides cryptographic operations over elliptic curves.
45+
```path/filepath```: Standard Go library for portable file path manipulation.
5246

53-
```github.com/consensys/gnark/backend/plonk``` Gnark backend for the PLONK proving system.
47+
```github.com/consensys/gnark-crypto/ecc```: Provides cryptographic operations over elliptic curves.
5448

55-
```github.com/consensys/gnark/constraint/bn254```: Provides types and functions to work with constraint systems specifically for the BN254 curve.
49+
```github.com/consensys/gnark/backend/plonk``` Gnark backend for the PLONK proving system.
5650

57-
```github.com/consensys/gnark/frontend```: Provides the API for defining constraints and creating witness data.
51+
```github.com/consensys/gnark/constraint/bn254```: Provides types and functions to work with constraint systems
52+
specifically for the BN254 curve.
5853

59-
```github.com/consensys/gnark/test/unsafekzg```: Gnark testing utilities for KZG commitments.
60-
61-
```github.com/consensys/gnark/frontend/cs/scs```: Gnark frontend for the SCS (Sparse Constraint System) builder.
54+
```github.com/consensys/gnark/frontend```: Provides the API for defining constraints and creating witness data.
6255

56+
```github.com/consensys/gnark/test/unsafekzg```: Gnark testing utilities for KZG commitments.
6357

64-
## Step 3: Define the circuit
58+
```github.com/consensys/gnark/frontend/cs/scs```: Gnark frontend for the SCS (Sparse Constraint System) builder.
6559

66-
The circuit structure is defined in this case using the equation
60+
## Step 3: Define the circuit
6761

68-
$x^3 + x + 5 = y$
62+
The circuit structure is defined in this case using the equation
6963

64+
$x^3 + x + 5 = y$
7065

7166
```bash=
7267
// CubicCircuit defines a simple circuit
@@ -76,17 +71,20 @@
7671
Y frontend.Variable `gnark:",public"`
7772
}
7873
```
79-
Here
8074

81-
```CubicCircuit```struct contains the variables ```X``` and ```Y```
75+
Here
8276

83-
```X``` is a secret input, annotated as ```'gnark:"x"'```
77+
```CubicCircuit```struct contains the variables ```X``` and ```Y```
8478

85-
```Y``` is a public input, annotated as ```'gnark:",public"'```
79+
```X``` is a secret input, annotated as ```'gnark:"x"'```
8680

87-
## Step 4: Define the circuit constraints:
81+
```Y``` is a public input, annotated as ```'gnark:",public"'```
8882

89-
Establish constraints that the circuit must satisfy. Here you define the logic that relates inputs to outputs, encapsulating the computation:
83+
## Step 4: Define the circuit constraints:
84+
85+
Establish constraints that the circuit must satisfy.
86+
Here you define the logic that relates inputs to outputs,
87+
encapsulating the computation:
9088

9189
```bash=
9290
// Define declares the circuit constraints
@@ -98,27 +96,25 @@
9896
}
9997
```
10098

101-
The ```Define``` method specifies the constraints for the circuit.
102-
103-
```x3 := api.Mul(circuit.X, circuit.X, circuit.X)``` computes X**3
99+
The ```Define``` method specifies the constraints for the circuit.
104100

101+
```x3 := api.Mul(circuit.X, circuit.X, circuit.X)``` computes X**3
105102

106-
```api.AssertIsEqual(circuit.Y, api.Add(x3, circuit.X, 5)``` asserts that X**3 + X + 5 == Y
103+
```api.AssertIsEqual(circuit.Y, api.Add(x3, circuit.X, 5)``` asserts that X**3 + X + 5 == Y
107104

108-
There are other options that we migth use like ```ÀssertDifferent``` ```AssertIsLessOrEqual```
105+
There are other options that we might use like ```ÀssertDifferent``` ```AssertIsLessOrEqual```
109106

110-
## Step 5: Compile the circuit and generate the proof
107+
## Step 5: Compile the circuit and generate the proof
111108

112-
Detail the steps to compile the circuit, generate a witness, create a proof, and verify it:
109+
Detail the steps to compile the circuit, generate a witness, create a proof, and verify it:
113110

114-
115-
we need to specify the directory where the proof, verification key and the public key will be saved
111+
we need to specify the directory where the proof, verification key and the public key will be saved
116112

117113
```bash
118114
outputDir := "gnark_plonk_circuit/"
119115
```
120116

121-
To compile the circuit we do
117+
To compile the circuit, we do
122118

123119
```bash=
124120
var circuit CubicCircuit
@@ -128,17 +124,17 @@
128124
panic("circuit compilation error")
129125
}
130126
```
131-
where
132127

128+
where
133129

134-
The ```frontend.Compile``` function compiles the circuit using the SCS
135-
constraint system.
130+
The ```frontend.Compile``` function compiles the circuit using the SCS
131+
constraint system.
136132

137-
```ecc.BN254.ScalarField()``` specifies the scalar field, in this case for the BN254 curve.
133+
```ecc.BN254.ScalarField()``` specifies the scalar field, in this case for the BN254 curve.
138134

139-
```scs.NewBuilder``` is used to build the sparse constraint system.
135+
```scs.NewBuilder``` is used to build the sparse constraint system.
140136

141-
The we generate the SRS (Structured Reference String)
137+
We generate the SRS (Structured Reference String)
142138

143139
```bash=
144140
// Generate the SRS and its Lagrange interpolation
@@ -149,21 +145,21 @@
149145
}
150146
```
151147

152-
```r1cs := ccs.(*cs.SparseR1CS)``` converts the compiled circuit to a sparse R1CS(Rank-1 Constraint Systems) format required by the SRS generation.
153-
154-
```unsafekzg.NewSRS``` generates the structured reference string (SRS) and its Lagrange interpolation.
148+
```r1cs := ccs.(*cs.SparseR1CS)``` converts the compiled circuit to a sparse R1CS(Rank-1 Constraint Systems) format
149+
required by the SRS generation.
155150

151+
```unsafekzg.NewSRS``` generates the structured reference string (SRS) and its Lagrange interpolation.
156152

157-
Next we need to setup PLONK
153+
Next, we need to set up PLONK
158154

159155
```bash=
160156
pk, vk, _ := plonk.Setup(ccs, srs, srsLagrangeInterpolation)
161157
```
162158

163-
```plonk.Setup``` initializes the PLONK proving system with the constraint system, SRS, and its Lagrange interpolation.
164-
This generates the proving key ```pk``` and verification key ```vk```
159+
```plonk.Setup``` initializes the PLONK proving system with the constraint system, SRS, and its Lagrange interpolation.
160+
This generates the proving key ```pk``` and verification key ```vk```
165161

166-
Then the Witness is created
162+
Then the Witness is created
167163

168164
```bash=
169165
assignment := CubicCircuit{X: 3, Y: 35}
@@ -177,13 +173,14 @@
177173
}
178174
```
179175

180-
An assignment to the circuit variables is created: ```X = 3``` and ```Y = 35```.
176+
An assignment to the circuit variables is created: ```X = 3``` and ```Y = 35```.
181177

182-
```frontend.NewWitness``` creates the full witness including all variables.
178+
```frontend.NewWitness``` creates the full witness including all variables.
183179

184-
```frontend.NewWitness``` with ```frontend.PublicOnly()``` creates the public witness including only the public variables.
180+
```frontend.NewWitness``` with ```frontend.PublicOnly()``` creates the public witness including only the public
181+
variables.
185182

186-
Generate the Proof:
183+
Generate the Proof:
187184

188185
```bash=
189186
proof, err := plonk.Prove(ccs, pk, fullWitness)
@@ -192,9 +189,9 @@
192189
}
193190
```
194191

195-
```plonk.Prove``` generates a proof using the compilated circuit,proving key and full witness
192+
```plonk.Prove``` generates a proof using the compiled circuit, proving key and full witness
196193

197-
Then to Verify
194+
Then to Verify
198195

199196
```bash=
200197
// Verify the proof
@@ -204,9 +201,9 @@
204201
}
205202
```
206203

207-
```plonk.Verify``` verifies the proof using the compilated circuit,proving key and full witness
204+
```plonk.Verify``` verifies the proof using the compiled circuit, proving key and full witness
208205

209-
Finally we have to serialize and save outputs
206+
Finally, we have to serialize and save outputs
210207

211208
```bash=
212209
// Open files for writing the proof, the verification key, and the public witness
@@ -246,13 +243,13 @@
246243
}
247244
```
248245

249-
Files are created for the proof, verification key, and public witness.
246+
Files are created for the proof, verification key, and public witness.
250247

251-
The proof, verification key, and public witness are written to these files.
248+
The proof, verification key, and public witness are written to these files.
252249

253-
This ensures that the proof and related data are saved for later use or verification.
250+
This ensures that the proof and related data are saved for later use or verification.
254251

255-
The complete code is:
252+
The complete code is:
256253

257254
```bash=
258255
package main

0 commit comments

Comments
 (0)