LeastAuthority/Aligned-Layer
GitHub: LeastAuthority/Aligned-Layer
Aligned Layer 是一个去中心化的零知识证明验证网络,通过批量聚合和 EigenLayer AVS 机制将以太坊上的 ZK 证明验证成本降低至十分之一并实现极低延迟。
Stars: 0 | Forks: 0
# Aligned
## 项目介绍
Aligned 是一个去中心化的节点网络,用于验证零知识证明(Zero-Knowledge)和有效性证明(Validity Proof),并将结果发布到 Ethereum 中。
这些证明的生成和使用成本仅为原来的十分之一,且具有极低的延迟,从而催生了以前在 Ethereum 上无法实现的新型应用。
## 如何使用测试网
1. 下载并安装 Aligned,以便在测试网中发送证明:
```
curl -L https://raw.githubusercontent.com/yetanotherco/aligned_layer/main/batcher/aligned/install_aligned.sh | bash
```
2. 然后运行 shell 中显示的 ```source``` 命令
3. 使用以下命令下载示例 SP1 证明文件及其 ELF 文件:
```
curl -L https://raw.githubusercontent.com/yetanotherco/aligned_layer/main/batcher/aligned/get_proof_test_files.sh | bash
```
我们正在下载一个预先生成的证明,将其发送到 Aligned,并从 Ethereum Holesky 测试网检索结果。Aligned 正在使用 EigenLayer 每秒进行超过一千个证明的快速且低成本的验证。
4. 让我们将证明发送到 Aligned 进行验证:
```
rm -rf ~/.aligned/aligned_verification_data/ &&
aligned submit \
--proving_system SP1 \
--proof ~/.aligned/test_files/sp1_fibonacci.proof \
--vm_program ~/.aligned/test_files/sp1_fibonacci.elf \
--aligned_verification_data_path ~/.aligned/aligned_verification_data \
--conn wss://batcher.alignedlayer.com
```
5. 您应该会收到如下响应:
```
[2024-07-01T19:17:54Z WARN aligned] Missing keystore used for payment. This proof will not be included if sent to Eth Mainnet
[2024-07-01T19:17:54Z INFO aligned] Submitting proofs to the Aligned batcher...
[2024-07-01T19:19:18Z INFO aligned] Batch inclusion data written into ./aligned_verification_data/e367d76e_0.json
[2024-07-01T19:19:18Z INFO aligned] Proofs submitted to aligned. See the batch in the explorer:
[2024-07-01T19:19:18Z INFO aligned] https://explorer.alignedlayer.com/batches/0xe367d76e832edec893d3a9027b3c231b2e3994c47acfac2e67197c13c9be0c4c
```
您可以使用指向浏览器的链接来检查交易的状态。
6. 经过三个 Ethereum 区块后,您可以使用以下命令检查它是否已被验证:
```
aligned verify-proof-onchain \
--aligned-verification-data ~/.aligned/aligned_verification_data/*.json \
--rpc https://ethereum-holesky-rpc.publicnode.com \
--chain holesky
```
这将读取 Ethereum 中该证明的验证结果。
7. 您应该会得到以下结果:
```
[2024-06-17T21:58:43Z INFO aligned] Your proof was verified in Aligned and included in the batch!
```
如果证明未被验证,您将会得到以下结果:
```
[2024-06-17T21:59:09Z INFO aligned] Your proof was not included in the batch.
```
Aligned 可以在以下平台上运行:
- MacOS Arm64(M1 或更高版本)
- 带有 GLIBC_2.32 或更高版本的 Linux x86(例如,Ubuntu 22.04 或更高版本)
如果您不满足这些要求,请克隆该代码仓库,安装 rust,然后运行:
```
make uninstall_aligned
make install_aligned_compiling
```
### 在 Ethereum 中读取证明验证结果
#### 使用 CURL 和 Ethereum RPC
在上一节的第 6 步中,我们使用 `aligned verify-proof-onchain` 来检查我们的证明是否已在 Aligned 中得到验证。
在内部,这会调用我们的 Aligned 合约,验证承诺(commitments)是否正确,以及该证明是否包含在批次中。
该命令执行的操作与对 Ethereum 节点进行以下 `curl` 调用相同。
```
curl -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_call","id":1, "params":[{"to": "0x58F280BeBE9B34c9939C3C39e0890C81f163B623", "data": ""}]}' \
-X POST https://ethereum-holesky-rpc.publicnode.com
```
如果证明及其相关数据正确并在 Aligned 中通过验证,这将返回 0x1,否则返回 0x0。
例如,这是一个已验证证明的正确 calldata:
```
curl -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_call","id":1,"params":[{"to": "0x58F280BeBE9B34c9939C3C39e0890C81f163B623", "data": "0xfa534dc0c181e470901eecf693bfa6f0e89e837dcf35700cdd91c210a0ce0660e86742080000000000000000000000000000000000000000000000000000000000000000836371a502bf5ad67be837b21fa99bc381f7e8124f02042ffb80fa7ce27bc8f6f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000007553cb14bff387c06e016cb3e7946e91d9fe44a54ad5d888ce8343ddb16116a700000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000007600000000000000000000000000000000000000000000000000000000000001007b2f4966c3ab3e59d213eda057734df28c323055a2a02f50bd286585cc80128c967250f2b9ad990485338fd2d49e83f47917983f5566da551d4c32e9063ea5641d94b04bac222e06ea18cbb617d0d52c7007cc8f8b30c435b8b8101bdff0ea8482436acf251652f00397f4cefa0bb8eea1c8addb6cf2ca843004b89d80c7e1e41344fd2387535fe4afcaafde27b04543d993bbbc7286154044913e5bd65b86d7cc4d47a90132a95d9ffecb913b414ba2d2f0b1d7b826eb5025a27bcadcc0d94cb125c9c9d556eac08dd6b0f5f55f68afe699f3c529442dbf1b47e968b3705ee2e1be4acb884d184a139a390cb94e9e5806686605dc0a025269bc3afd990c8302"}]}' \
-X POST https://ethereum-holesky-rpc.publicnode.com
```
要自行生成 calldata,请按照以下步骤操作:
1. 克隆该代码仓库并进入其中
2. 创建一个 Python 虚拟环境并使用以下命令安装依赖项
```
python3 -m venv .aligned_venv
source .aligned_venv/bin/activate
python3 -m pip install -r examples/verify/requirements.txt
```
3. 使用以下命令对您的证明验证数据进行编码
```
python3 examples/verify/encode_verification_data.py --aligned-verification-data ~/.aligned/aligned_verification_data/*.json
```
如果您的验证数据位于其他路径,只需更改 `--aligned-verification-data` 参数即可。
#### 使用调用者合约
要在您自己的合约中验证证明,请对 Aligned 合约使用 static call。您可以使用以下[调用者合约](examples/verify/src/VerifyBatchInclusionCaller.sol)作为示例。代码如下所示:
```
(bool callWasSuccessfull, bytes memory proofIsIncluded) = targetContract.staticcall(
abi.encodeWithSignature(
"verifyBatchInclusion(bytes32,bytes32,bytes32,bytes20,bytes32,bytes,uint256)",
proofCommitment,
pubInputCommitment,
provingSystemAuxDataCommitment,
proofGeneratorAddr,
batchMerkleRoot,
merkleProof,
verificationDataBatchIndex
)
);
require(callWasSuccessfull, "static_call failed");
```
## Operator 指南
如果您想运行一个 operator,请查看我们的 [Operator 指南](./docs/operator_guides/0_running_an_operator.md)
## Aligned 基础设施指南
如果您正在为 Aligned 进行开发,或者想运行您自己的 devnet,请查看我们的 [Aligned 配置指南](docs/guides/5_setup_aligned.md)
标签:AVS, EigenLayer, 以太坊, 区块链, 可视化界面, 智能合约, 逆向工具, 通知系统, 零知识证明, 验证网络