Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/testnet' into update_to_0_7
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbosio committed Sep 19, 2024
2 parents 05eccaf + 1876fd0 commit f72fa7b
Show file tree
Hide file tree
Showing 39 changed files with 819 additions and 398 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ You can use the link to the explorer to check the status of your transaction.
aligned verify-proof-onchain \
--aligned-verification-data ~/.aligned/aligned_verification_data/*.json \
--rpc_url https://ethereum-holesky-rpc.publicnode.com \
--chain holesky
--chain holesky \
--payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003
```
This is reading the result of the verification of the proof in Ethereum.
Expand All @@ -92,7 +93,7 @@ If the proof wasn't verified you should get this result:
Aligned works in:
- MacOS Arm64 (M1 or higher)
- Linux x86 with GLIBC_2.32 or superior (For example, Ubuntu 22.04 or higher)
If you don't meet these requirements, clone the repository, install rust, and then run:
If you don't meet these requirements, clone the repository, install rust, and then run:
```bash
make uninstall_aligned
Expand Down Expand Up @@ -170,13 +171,13 @@ If you want to run an operator, check our [Operator Guide](./docs/operator_guide
## Aligned Infrastructure Guide
If you are developing on Aligned, or want to run your own devnet, check our [setup Aligned guide](docs/guides/6_setup_aligned.md).
If you are developing on Aligned, or want to run your own devnet, check our [setup Aligned guide](docs/3_guides/6_setup_aligned.md).
## Submitting Proofs to Aligned
For submitting proofs generated by your own project to the network via CLI, see the documentation on [submitting proofs to Aligned](docs/guides/0_submitting_proofs.md).
For submitting proofs generated by your own project to the network via CLI, see the documentation on [submitting proofs to Aligned](docs/3_guides/0_submitting_proofs.md).
## Integrating Aligned into your Project
If you are developing applications using Aligned, we offer a [Rust-SDK](docs/guides/1_SDK.md) for submitting proofs directly to the network within your applications.
If you are developing applications using Aligned, we offer a [Rust-SDK](docs/3_guides/1_SDK_how_to.md) for submitting proofs directly to the network within your applications.
Original file line number Diff line number Diff line change
@@ -1,28 +1,55 @@
## What is Aligned?

Aligned is a decentralized network that verifies zero-knowledge/validity proofs and posts the results to Ethereum. It is designed to provide high throughput, cheap proof verification with low latency.
Aligned is a decentralized network that verifies Zero-Knowledge/validity proofs and posts the results to Ethereum. It is designed to provide high throughput, cheap proof verification with low latency.

{% hint style="info" %}
If you are unfamiliar with ZK and why this is useful, see [Why ZK and Aligned?](./5_why_zk.md)
{% endhint %}

## Mission

Our mission is to accelerate Ethereum's roadmap and the adoption of verifiable computation by enabling fast and economical verification of ZK and validity proofs.

## What real value does Aligned bring to the table?

Blockchains are verifiable computers. We live in a chaotic world where there will be a huge demand for computation that does not need to be trusted. Current blockchain models are inefficient: each node must re-execute each transaction/operation, making the weakest devices the bottleneck. Besides, adding more hardware does not make the system faster (contrary to what happens in Web2), just more reliable. Alternative L1s to Ethereum make trade-offs, accepting bigger hardware or changing the consensus to be faster but with fewer guarantees. In other words, we reduce costs at the expense of lower security guarantees. Zero-knowledge/validity proofs (ZK) provide a new framework where we do not have to make such compromises. The basic premise is that a party can generate a very short proof of a computation, and the nodes can quickly verify that proof instead of re-executing the computation. The computation can be quite large, comprising many different transactions. This enables the delegation of execution off-chain with the same guarantees, leading to increased throughput and lower operational costs. This led to the rollup-centric roadmap of Ethereum, featuring multiple L2s, but at the expense of fragmented liquidity and complex user experience. Many of these problems could be solved by ZK bridges, but they remain expensive, and the go-to-market time is high.
Blockchains are verifiable computers.
We live in a chaotic world where there will be a huge demand for computation that needs to be trusted.

Current blockchain models are inefficient: each node must re-execute each transaction or operation, making the weakest and slowest devices the bottleneck. Unlike in Web2, where adding more hardware can increase performance, in these systems, additional hardware primarily enhances reliability rather than speed. Alternative L1s to Ethereum make trade-offs, accepting bigger hardware or changing the consensus to be faster but with fewer security guarantees. In other words, they reduce costs and increase speed at a great expense of lower security guarantees.

On the other hand, Zero-knowledge/validity proofs (ZK) provide a new framework where we do not have to make such compromises. The basic premise is that a party can generate a very short proof of a computation, and the nodes can quickly verify that proof instead of re-executing the computation. The computation can be quite large, comprising many different transactions. This enables the delegation of execution off-chain with the same guarantees, leading to increased throughput and lower operational costs. This led to the rollup-centric roadmap of Ethereum, featuring multiple L2s, but at the expense of fragmented liquidity and complex user experience. Many of these problems could be solved by ZK bridges, but they remain expensive, and the go-to-market time is high.

Still, nodes have to verify those proofs, which can be quite expensive since this is done on-chain: current proof systems can cost between 10 and several hundred dollars (which is strongly dependent on network congestion).
Anyhow, nodes still have to verify those proofs, which can be quite expensive since this is done on-chain: current proof systems can cost between 10 and several hundred dollars (which is strongly dependent on network congestion).

In addition, ZK lets us build other verifiable applications where users do not have to trust the party performing the computation, with impact in areas such as artificial intelligence (AI), the Internet of Things (IoT), and fighting misinformation. This is not clear to most people since proving technologies were not mature enough and verification costs were high.

## What limits the development of more complex applications on top of blockchains?

The main limitation for building complex applications on top of blockchains has been that the computation can run only a few milliseconds on chain and even then this can be very expensive. You can't have millions of daily active users using Ethereum or any blockchain at the same time.
The main limitation for building complex applications on top of blockchains has been that the computation can run only a few milliseconds on chain, and even then, this can be costly. You can't have millions of daily active users using Ethereum or any blockchain at the same time.

ZK solves this but due to slow and complex-to-use proving, and expensive verification, progress has been limited. In the case of proving, before the development of general-purpose zero-knowledge virtual machines (zkvms), users had to express their computation as arithmetic circuits, making the developer experience something like coding in assembler, error-prone, and complex. Moreover, proof systems depended on trusted setups, adding additional trust guarantees, the need to carry out special ceremonies to initialize parameters, and delaying go-to-market times. Besides, having high verification costs (on the order of 10's to 100's of dollars per proof) meant that only those projects with a lot of capital could afford to build such applications.
ZK solves this, but due to slow and complex-to-use proving and expensive verification, progress has been limited.
In the case of proving, before the development of general-purpose zero-knowledge virtual machines (zkVMs),
users had to express their computation as arithmetic circuits,
making the developer experience something like coding in assembler, error-prone, and complex.
Moreover, proof systems depended on trusted setups,
adding additional trust guarantees, the need to carry out special ceremonies to initialize parameters,
and delaying go-to-market times.
Besides,
having high verification costs (on the order of 10's to 100's of dollars per proof)
meant that only those projects with a huge capital could afford to build such applications.

## Why didn't anybody do it before?

To build Aligned, we needed several pieces in place. First, we needed EigenLayer, which allows building services and applications on top of Ethereum without competing for blockspace. In our case, we could bootstrap the economic security for a decentralized network of verifiers, avoiding the limitations of running proof verification on-chain. Second, proving technology had to improve. We currently have general-purpose zkvms (which means we can code in Rust and other high-level languages and prove it), proof systems are faster, and several improvements and developments are on the way. This makes writing applications easier (providing a higher demand for proof verification), and enables faster and simpler proof recursion (for proof compression).
To build Aligned, we needed several pieces in place.
First, we needed EigenLayer,
which allows building services and applications on top of Ethereum without competing for blockspace.
In our case, we could bootstrap the economic security for a decentralized network of verifiers,
avoiding the limitations of running proof verification on-chain.
Second, proving technology had to improve.
We currently have general-purpose zkVMs (which means we can code in Rust and other high-level languages and prove it),
proof systems are faster, and several improvements and developments are on the way.
This makes writing applications easier (providing a higher demand for proof verification),
and enables faster and simpler proof recursion (for proof compression).

## How much can Aligned reduce costs?

Expand All @@ -32,15 +59,25 @@ Aligned operates using two operation modes: fast and aggregation. The cost reduc

Aligned has created a new category in crypto: ZK verification layer. It is the only solution for now offering fast and aggregation modes while being linked to Ethereum via EigenLayer. The fast mode provides very high throughput (over two orders of magnitude more than Ethereum), low latency, and lower costs than the aggregation mode. The security is provided by restaking, and this mode is well suited for applications with tight limits on latency and costs. The aggregation mode works using the slower proof recursion strategy, also used in rollups to compress proofs. Another key feature is that Aligned is stateless, simplifying the process greatly.

Other solutions focus on building a separate L1 for proof verification (which sets them apart from Ethereum and requires bootstrapping the economic security, which can be lower and subject to volatility, as opposed to that provided by restaking) or focus on the aggregation of proofs from a few proof systems. This last approach adds latency, higher operational costs, and constrains the developer's choice of the proof system.
Other solutions focus on building a separate L1 for proof verification (which sets them apart from Ethereum and requires bootstrapping the economic security, which can be lowered and subject to volatility, as opposed to that provided by restaking) or focus on the aggregation of proofs from a few proof systems. This last approach adds latency, higher operational costs, and constrains the developer's choice of the proof system.

The following table contains costs estimates for Aligned, assuming a batch size of 20 proofs.

| Proof system | Ethereum | Aligned - Fast mode | Aligned - Aggregation |
| -------- | -------- | -------- | ---------- |
| Groth16 | 250,000 | 40,000 | TBD |
| STARKs | >1,000,000 | 40,000 | TBD |
| Kimchi-IPA | ?????? | 40,000 | TBD |
| Halo2-KZG | 350,000 | 40,000 | TBD |
| Binius. | ?????? | 40,000 | TBD |

## Why are we building Aligned?

In recent months, we have witnessed the development and enhancement of general proving virtual machines such as Risc0, Valida, Jolt, and SP1. These innovations allow users to write ordinary code in languages like Rust or C and generate proofs demonstrating the integrity of computations. This evolution is poised to transform application development, provided we have verification networks with high throughput and low cost. This is the core vision of Aligned and the reason we are building it: the future belongs to provable applications.

Currently, proof verification in Ethereum is expensive and throughput is limited to around 10 proofs per second. The cost depends on the proof system used, and the availability of precompiles. Groth16 costs around 250,000 gas, STARKs, over 1,000,000, and other proof systems are too expensive to be used in Ethereum.

Proof technology has been evolving over the last decade, with new arguments, fields, commitments and other tools appearing every day. It is hard to try new ideas if verification costs are high and there is a considerable go-to-market time, as a consequence of development time of new, gas-optimized smart contracts, or the inclusion of new precompiles to make them affordable.
Proof technology has been evolving over the last decade, with new arguments, fields, commitments and other tools appearing every day. It is hard to try new ideas if verification costs are high, and there is a considerable go-to-market time, as a consequence of development time of new, gas-optimized smart contracts, or the inclusion of new precompiles to make them affordable.

Aligned provides an alternative to reduce costs and increase throughput significantly. This is achieved by two different modes: **fast mode** and **aggregation mode**.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Getting started!

In this tutorial you will learn how to send your first SP1 proofs to get verified in Aligned in under 3 minutes.
In this tutorial, you will learn how to send your first SP1 proofs to get verified in Aligned in under 3 minutes.

## Quickstart

We will download a previously generated SP1 proof, send it to Aligned for verification, and retrieve the results from Ethereum Holesky testnet.

1. Download and install Aligned to send proofs in the testnet:
Expand Down Expand Up @@ -51,27 +52,27 @@ Use the link in the response to check the status of your transaction in the Alig
aligned verify-proof-onchain \
--aligned-verification-data ~/.aligned/aligned_verification_data/*.json \
--rpc_url https://ethereum-holesky-rpc.publicnode.com \
--chain holesky
--payment_service_addr 0x815aeCA64a974297942D2Bbf034ABEe22a38A003
```
This is reading the result of the verification of the proof in Ethereum.
This is reading the result of the proof verification in Ethereum.
7. You should get this result:
```bash
[2024-06-17T21:58:43Z INFO aligned] Your proof was verified in Aligned and included in the batch!
```
If the proof wasn't verified you should get this result:
If the proof wasn't verified, you should get this result:
```bash
[2024-06-17T21:59:09Z INFO aligned] Your proof was not included in the batch.
```
Aligned works in:
- MacOS Arm64 (M1 or higher)
- macOS Arm64 (M1 or higher)
- Linux x86 with GLIBC_2.32 or superior (For example, Ubuntu 22.04 or higher)
If you don't meet these requirements, you can compile the binaries yourself following the [README](https://github.com/yetanotherco/aligned_layer)
To try Aligned with other proving systems, check [this](https://docs.alignedlayer.com/guides/0_submitting_proofs) guide
To try Aligned with other proving systems, check [this](../3_guides/0_submitting_proofs.md) guide
59 changes: 59 additions & 0 deletions docs/1_introduction/2_zkquiz.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# ZK Quiz

## Introduction

This program leverages Aligned's ZK verification infrastructure to run a small quiz. The proof allows any party to check that the quiz was answered right or wrong. If answered correctly, the user receives an NFT.

The process is as follows:

1. The user runs ZKQuiz and answers the questions.
2. ZKQuiz generates a ZK Proof of correct answers.
3. The proof is posted on Aligned.
4. Upon verification, ZKQuiz mints an NFT via a Smart Contract.

The NFT is only granted if the user's answers correctly.
Incorrect answers or tampering with the ZKQuiz code will result in proof generation failure or mismatched checksums,
preventing NFT minting.

Next, we will see how to execute ZKQuiz to get your own ZKQuiz NFT!

## Requirements

1. [Rust](https://www.rust-lang.org/tools/install)
2. [Foundry](https://getfoundry.sh)

## Usage

### 1 - Create Keystore

You can use cast to create a local keystore.
If you already have one, you can skip this step.

```bash
cast wallet new-mnemonic
```

Then you can import your created keystore using:

```bash
cast wallet import --interactive <path_to_keystore.json>
```

Then you need to get some funds to pay for gas and proof verification.
You can do this by using this [faucet](https://cloud.google.com/application/web3/faucet/ethereum/holesky)

### 2 - Answer Quiz

To answer quiz questions run:

```bash
make answer_quiz KEYSTORE_PATH=<path_to_keystore.json>
```

This will:

1. Ask quiz questions
2. Generate ZK proof
3. Pay & submit proof to aligned for verification
4. Wait for proof to be verified in aligned
5. Claim NFT if proof is verified
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
- Verifiable Machine Learning (ML): with general-purpose zkvms we can prove code written in Rust, solving part of the problem of using ML. However, most zkVMs use STARK-based proof systems, which leads to high on-chain costs or expensive wrapping. With Aligned, you can directly verify your proof from the zkVM for much less than Ethereum.
- Cheap verification and interoperability for Identity Protocols.
- ZK Oracles: With ZK oracles we can show that we have a piece of information off-chain and produce a ZK proof doing some computation with that data. Aligned reduces the cost of using those oracles. For more background, see the [following post](https://minaprotocol.com/blog/what-are-zkoracles).
- New credential protocols such as zkTLS based systems.
- ZK Coprocessor.
- New credential protocols such as zkTLS based systems: you can create proofs of data shown on your web browser and have the result verified in Ethereum. See the following thread for an [ELI5 on TLS](https://x.com/dabit3/status/1830022029195501799)
- ZK Coprocessor: ZK allows complex computations to be delegated from the blockchain to a coprocessor. This can retrieve information from the blockchain and perform the computations securely in a more efficient way.
- Encrypted Mempools using SNARKs to show the correctness of the encryption.
- Protocols against misinformation and fake news.
- Protocols against misinformation and fake news: you can generate proofs that an image or audio comes from a given device, and show that a published image is the result of certain transformations performed on the original image.
- On-chain gaming.

## Projects built using Aligned

- The Mina <> Ethereum bridge (in development) uses Aligned's fast mode for ZK proof verification. See the [github repo](https://github.com/lambdaclass/mina_bridge) for more information.
Loading

0 comments on commit f72fa7b

Please sign in to comment.