Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: re enable devnet infra guide in gitbook #631

Merged
merged 39 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
872f519
docs: add setup_aligned to summary
uri-99 Jul 12, 2024
97f3bb4
docs(wip): polishing setup_aligned.md
uri-99 Jul 12, 2024
372cd13
docs: make targets to send proofs
uri-99 Jul 12, 2024
44fdaf7
docs: moved operator and agg extra info to dropdowns
uri-99 Jul 12, 2024
6f17a1b
docs: rename guides to fit number numeration
uri-99 Jul 15, 2024
e713613
docs: setup aligned devnet
uri-99 Jul 15, 2024
94bcaa1
docs: unattached to gitbook doc of holesky deployment
uri-99 Jul 15, 2024
02d8258
Merge branch 'main' into 630-docs-re-enable-devnet-infra-guide-in-git…
uri-99 Jul 15, 2024
08b3216
fix: remove changes
NicolasRampoldi Jul 15, 2024
64f9f33
fix: remove changes
NicolasRampoldi Jul 15, 2024
07b7e78
fix: remove changes
NicolasRampoldi Jul 15, 2024
4980cd0
docs: setup aligned details
uri-99 Jul 15, 2024
2a2f5cd
Merge branch '630-docs-re-enable-devnet-infra-guide-in-gitbook' of ht…
uri-99 Jul 15, 2024
92eb13f
docs: better explorer docs placement
uri-99 Jul 15, 2024
e3a4ade
docs: remove index
uri-99 Jul 15, 2024
2771ac5
docs: refactor moved 5 to 4.2
uri-99 Jul 15, 2024
6d0472f
Update docs/guides/5_setup_aligned.md
entropidelic Jul 17, 2024
65b379b
Update docs/SUMMARY.md
entropidelic Jul 19, 2024
f5f44a9
Change guides order
entropidelic Jul 19, 2024
af7e311
Change guides order
entropidelic Jul 19, 2024
1f3b305
Fix docs SUMMARY
entropidelic Jul 19, 2024
f635399
Merge branch 'main' into 630-docs-re-enable-devnet-infra-guide-in-git…
entropidelic Jul 19, 2024
44a26ab
docs: add missing config parameters
NicolasRampoldi Jul 19, 2024
08da862
docs: fix install aligned command
NicolasRampoldi Jul 19, 2024
246a67b
docs: fix submit commands
NicolasRampoldi Jul 19, 2024
42ccf29
fix: edit setup holesky docs titles
glpecile Jul 19, 2024
9910833
docs(setup): re order, lint and add missing env variables
glpecile Jul 19, 2024
9ac524b
fix(generating-proofs): broken link
glpecile Jul 19, 2024
bd5fe44
docs: reformat tables
glpecile Jul 19, 2024
e8995a7
docs(setup): language fixes
glpecile Jul 19, 2024
d64c061
docs(summary): replace contacts for social and add github
glpecile Jul 19, 2024
485580f
docs(generate-gnark): fix punctuation
glpecile Jul 19, 2024
f35d5d3
docs(generating-proofs): fix formatting, punctuation, and language
glpecile Jul 19, 2024
9dd8dc7
docs(using-zkrust): fix formatting, punctuation, and language
glpecile Jul 19, 2024
fa3df7a
docs(setup): fix eigenlayer spelling
glpecile Jul 19, 2024
2a9a4ad
Merge branch 'main' into 630-docs-re-enable-devnet-infra-guide-in-git…
glpecile Jul 24, 2024
c774e62
docs(setup): remove batcher_send_groth16_burst command
glpecile Jul 24, 2024
deda2bf
Merge branch 'main' into 630-docs-re-enable-devnet-infra-guide-in-git…
glpecile Jul 29, 2024
a1d54fe
fix: uppercase
NicolasRampoldi Jul 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* [Supported Verifiers](architecture/0_supported_verifiers.md)
* [Key Terms](architecture/0b_key_terms.md)
* [Fast mode](architecture/1_fast_mode.md)
* [Batcher](./architecture/components/1_batcher.md)
* [Payment Service Contract](./architecture/components/2_payment_service_contract.md)
* [Service Manager Contract](./architecture/components/3_service_manager_contract.md)
* [Operator](./architecture/components/4_operator.md)
* [Aggregator](./architecture/components/5_aggregator.md)
* [Explorer](./architecture/components/6_explorer.md)
* [Batcher](./architecture/components/1_batcher.md)
* [Payment Service Contract](./architecture/components/2_payment_service_contract.md)
* [Service Manager Contract](./architecture/components/3_service_manager_contract.md)
* [Operator](./architecture/components/4_operator.md)
* [Aggregator](./architecture/components/5_aggregator.md)
* [Explorer](./architecture/components/6_explorer.md)
* [Aggregation mode](architecture/2_aggregation_mode.md)

## Guides
Expand All @@ -28,9 +28,9 @@
* [Integrating Aligned into your Application](guides/2_integrating_aligned_into_your_application.md)
* [SDK](guides/1_SDK.md)
* [Generating proofs for Aligned](guides/3_generating_proofs.md)
* [Contract Addresses](guides/4_contract_addresses.md)

<!-- * [Setup Aligned](developer_guides/2_setup_aligned.md) -->
* [Generating & submitting proofs of Rust code with ZKRust](guides/4_using_zkrust.md)
* [Setup Aligned Infrastructure Locally](guides/5_setup_aligned.md)
* [Contract Addresses](guides/6_contract_addresses.md)

## Operators

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

## Contacts
## Socials

* [Telegram Group](https://t.me/aligned_layer)
* [Twitter/X](https://twitter.com/alignedlayer)
* [Discord](https://discord.gg/alignedlayer)
* [Website](https://alignedlayer.com)
* [Github](https://github.com/yetanotherco/aligned_layer)
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
# How to create a Gnark Plonk proof
# How to create a Gnark Plonk proof

## Step 1 : Set up your enviroment
## Step 1: Set up your environment

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

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

```bash=
mkdir gnark_plonk_circuit
cd gnark_plonk_circuit
go mod init gnark_plonk_circuit
```

- 3 Install Gnark: Add the library to your project
- 3 Install Gnark: Add the library to your project

```bash=
go get github.com/consensys/[email protected]
```



## Step 2: Import dependencies
## Step 2: Import dependencies

```bash=
import (
Expand All @@ -36,37 +34,34 @@
)
```

Here's what each package is used for:


Here's what each package is used for:

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

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

```os```: Standard Go library for interacting with the operating system.

```path/filepath```: Standard Go library for portable file path manipulation.
```os```: Standard Go library for interacting with the operating system.

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

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

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

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

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

```github.com/consensys/gnark/frontend/cs/scs```: Gnark frontend for the SCS (Sparse Constraint System) builder.
```github.com/consensys/gnark/frontend```: Provides the API for defining constraints and creating witness data.

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

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

The circuit structure is defined in this case using the equation
## Step 3: Define the circuit

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

$x^3 + x + 5 = y$

```bash=
// CubicCircuit defines a simple circuit
Expand All @@ -76,17 +71,20 @@
Y frontend.Variable `gnark:",public"`
}
```
Here

```CubicCircuit```struct contains the variables ```X``` and ```Y```
Here

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

```Y``` is a public input, annotated as ```'gnark:",public"'```
```X``` is a secret input, annotated as ```'gnark:"x"'```

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

Establish constraints that the circuit must satisfy. Here you define the logic that relates inputs to outputs, encapsulating the computation:
## Step 4: Define the circuit constraints:

Establish constraints that the circuit must satisfy.
Here you define the logic that relates inputs to outputs,
encapsulating the computation:

```bash=
// Define declares the circuit constraints
Expand All @@ -98,27 +96,25 @@
}
```

The ```Define``` method specifies the constraints for the circuit.

```x3 := api.Mul(circuit.X, circuit.X, circuit.X)``` computes X**3
The ```Define``` method specifies the constraints for the circuit.

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

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

There are other options that we migth use like ```ÀssertDifferent``` ```AssertIsLessOrEqual```
There are other options that we might use like ```ÀssertDifferent``` ```AssertIsLessOrEqual```

## Step 5: Compile the circuit and generate the proof
## Step 5: Compile the circuit and generate the proof

Detail the steps to compile the circuit, generate a witness, create a proof, and verify it:
Detail the steps to compile the circuit, generate a witness, create a proof, and verify it:


we need to specify the directory where the proof, verification key and the public key will be saved
we need to specify the directory where the proof, verification key and the public key will be saved

```bash
outputDir := "gnark_plonk_circuit/"
```

To compile the circuit we do
To compile the circuit, we do

```bash=
var circuit CubicCircuit
Expand All @@ -128,17 +124,17 @@
panic("circuit compilation error")
}
```
where

where

The ```frontend.Compile``` function compiles the circuit using the SCS
constraint system.
The ```frontend.Compile``` function compiles the circuit using the SCS
constraint system.

```ecc.BN254.ScalarField()``` specifies the scalar field, in this case for the BN254 curve.
```ecc.BN254.ScalarField()``` specifies the scalar field, in this case for the BN254 curve.

```scs.NewBuilder``` is used to build the sparse constraint system.
```scs.NewBuilder``` is used to build the sparse constraint system.

The we generate the SRS (Structured Reference String)
We generate the SRS (Structured Reference String)

```bash=
// Generate the SRS and its Lagrange interpolation
Expand All @@ -149,21 +145,21 @@
}
```

```r1cs := ccs.(*cs.SparseR1CS)``` converts the compiled circuit to a sparse R1CS(Rank-1 Constraint Systems) format required by the SRS generation.

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

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

Next we need to setup PLONK
Next, we need to set up PLONK

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

```plonk.Setup``` initializes the PLONK proving system with the constraint system, SRS, and its Lagrange interpolation.
This generates the proving key ```pk``` and verification key ```vk```
```plonk.Setup``` initializes the PLONK proving system with the constraint system, SRS, and its Lagrange interpolation.
This generates the proving key ```pk``` and verification key ```vk```

Then the Witness is created
Then the Witness is created

```bash=
assignment := CubicCircuit{X: 3, Y: 35}
Expand All @@ -177,13 +173,14 @@
}
```

An assignment to the circuit variables is created: ```X = 3``` and ```Y = 35```.
An assignment to the circuit variables is created: ```X = 3``` and ```Y = 35```.

```frontend.NewWitness``` creates the full witness including all variables.
```frontend.NewWitness``` creates the full witness including all variables.

```frontend.NewWitness``` with ```frontend.PublicOnly()``` creates the public witness including only the public variables.
```frontend.NewWitness``` with ```frontend.PublicOnly()``` creates the public witness including only the public
variables.

Generate the Proof:
Generate the Proof:

```bash=
proof, err := plonk.Prove(ccs, pk, fullWitness)
Expand All @@ -192,9 +189,9 @@
}
```

```plonk.Prove``` generates a proof using the compilated circuit,proving key and full witness
```plonk.Prove``` generates a proof using the compiled circuit, proving key and full witness

Then to Verify
Then to Verify

```bash=
// Verify the proof
Expand All @@ -204,9 +201,9 @@
}
```

```plonk.Verify``` verifies the proof using the compilated circuit,proving key and full witness
```plonk.Verify``` verifies the proof using the compiled circuit, proving key and full witness

Finally we have to serialize and save outputs
Finally, we have to serialize and save outputs

```bash=
// Open files for writing the proof, the verification key, and the public witness
Expand Down Expand Up @@ -246,13 +243,13 @@
}
```

Files are created for the proof, verification key, and public witness.
Files are created for the proof, verification key, and public witness.

The proof, verification key, and public witness are written to these files.
The proof, verification key, and public witness are written to these files.

This ensures that the proof and related data are saved for later use or verification.
This ensures that the proof and related data are saved for later use or verification.

The complete code is:
The complete code is:

```bash=
package main
Expand Down
Loading
Loading