|
1 | | -# <h1 align="center">Hello World Tangle Blueprint 🌐</h1> |
2 | | - |
3 | | -## 📚 Overview |
4 | | - |
5 | | -This Tangle Blueprint provides a simple Hello World job. |
6 | | -Blueprints are specifications for <abbr title="Actively Validated Services">AVS</abbr>s on the Tangle Network. An AVS is |
7 | | -an off-chain service that runs arbitrary computations for a user-specified period of time. |
8 | | - |
9 | | -Blueprints provide a useful abstraction, allowing developers to create reusable service infrastructures as if they were |
10 | | -smart contracts. This enables developers to monetize their work and align long-term incentives with the success of their |
11 | | -creations, benefiting proportionally to their Blueprint's usage. |
12 | | - |
13 | | -For more details, please refer to the [project documentation](https://docs.tangle.tools/developers/blueprints/introduction). |
14 | | - |
15 | | -## 🚀 Features |
16 | | - |
17 | | -- Custom greeting messages |
18 | | -- Default "Hello World!" messages |
19 | | -- ... |
20 | | - |
21 | | -## 📋 Prerequisites |
22 | | - |
23 | | -Before you can run this project, you will need to have the following software installed on your machine: |
24 | | - |
25 | | -- [Rust](https://www.rust-lang.org/tools/install) |
26 | | -- [Forge](https://getfoundry.sh) |
27 | | - |
28 | | -You will also need to install [cargo-tangle](https://crates.io/crates/cargo-tangle), our CLI tool for creating and |
29 | | -deploying Tangle Blueprints: |
30 | | - |
31 | | -To install the Tangle CLI, run the following command: |
32 | | - |
33 | | -> Supported on Linux, MacOS, and Windows (WSL2) |
34 | | -
|
35 | | -```bash |
36 | | -cargo install cargo-tangle --git https://github.com/tangle-network/blueprint |
37 | | -``` |
38 | | - |
39 | | -## ⭐ Getting Started |
40 | | - |
41 | | -Once `cargo-tangle` is installed, you can create a new project with the following command: |
42 | | - |
43 | | -```sh |
44 | | -cargo tangle blueprint create --name <project-name> |
45 | | -``` |
46 | | - |
47 | | -and follow the instructions to create a new project. |
48 | | - |
49 | | -## 🛠️ Development |
50 | | - |
51 | | -Once you have created a new project, you can run the following command to start the project: |
52 | | - |
53 | | -```sh |
54 | | -cargo build |
55 | | -``` |
56 | | - |
57 | | -to build the project, and |
58 | | - |
59 | | -```sh |
60 | | -cargo tangle blueprint deploy |
61 | | -``` |
62 | | - |
63 | | -to deploy the blueprint to the Tangle network. |
64 | | - |
65 | | -## 📜 License |
66 | | - |
67 | | -Licensed under either of |
68 | | - |
69 | | -* Apache License, Version 2.0 |
70 | | - ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) |
71 | | -* MIT license |
72 | | - ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) |
73 | | - |
74 | | -at your option. |
75 | | - |
76 | | -## 📬 Feedback and Contributions |
77 | | - |
78 | | -We welcome feedback and contributions to improve this blueprint. |
79 | | -Please open an issue or submit a pull request on our GitHub repository. |
80 | | -Please let us know if you fork this blueprint and extend it too! |
81 | | - |
82 | | -Unless you explicitly state otherwise, any contribution intentionally submitted |
83 | | -for inclusion in the work by you, as defined in the Apache-2.0 license, shall be |
84 | | -dual licensed as above, without any additional terms or conditions. |
| 1 | +# Pico Verifiable Computation Service - Tangle Blueprint |
| 2 | + |
| 3 | +This project implements a reusable Tangle Blueprint that provides Verifiable Computation as a Service, powered by the [Pico zkVM](https://github.com/brevis-network/pico). |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The service allows developers to submit arbitrary RISC-V programs (compiled for the Pico zkVM) along with their inputs and receive Zero-Knowledge Proofs (ZKPs) of the execution trace. This enables trustless verification of computations performed off-chain. |
| 8 | + |
| 9 | +Key Features: |
| 10 | + |
| 11 | +- **Generic Computation:** Supports proving arbitrary RISC-V programs compatible with Pico. |
| 12 | +- **On-Chain Program Registry:** Uses an EVM smart contract (`ProgramRegistry.sol`) to store program metadata (SHA256 hash and download location - e.g., IPFS, HTTPS), enabling program reuse and discovery. |
| 13 | +- **Flexible Proving:** Supports different proving modes via the Pico SDK: |
| 14 | + - `Fast`: RISC-V execution proof only (for testing/debugging, **not secure**). |
| 15 | + - `Full`: Complete recursive STARK proof generation. |
| 16 | + - `FullWithEvm`: Generates a Groth16 proof verifiable on EVM chains using generated Solidity verifiers. |
| 17 | +- **Tangle Blueprint Integration:** Built using the [Tangle Blueprint SDK](https://github.com/TangleLabs/blueprint-sdk), allowing the service to run as a decentralized backend service within the Tangle network ecosystem. Jobs can be triggered via Tangle messages. |
| 18 | +- **Decentralized Storage:** Program binaries are intended to be stored off-chain (e.g., IPFS, Arweave, HTTPS), referenced by the on-chain registry. |
| 19 | + |
| 20 | +## Architecture |
| 21 | + |
| 22 | +1. **Tangle Blueprint Runner (`bin/`):** The main service executable that runs the Blueprint. It listens for incoming job requests (e.g., from the Tangle network). |
| 23 | +2. **Core Logic Library (`lib/`):** Contains the Rust implementation of the service: |
| 24 | + - **Jobs:** Defines the available service functions (`say_hello` example, `generate_proof` core job). |
| 25 | + - **Context:** Manages shared resources like HTTP clients and EVM provider configurations. |
| 26 | + - **EVM Interaction:** Handles communication with the `ProgramRegistry` smart contract using `alloy`. |
| 27 | + - **Program Handling:** Fetches program ELF binaries from specified locations (URL, local path) and verifies their integrity using SHA256 hashes. |
| 28 | + - **Pico Integration:** Uses the `pico-sdk` to load ELFs, provide inputs, and execute the different proving flows (`prove_fast`, `prove`, `prove_evm`). |
| 29 | + - **Types & Errors:** Defines data structures for requests, results, and custom errors. |
| 30 | +3. **Program Registry Contract (`contracts/`):** A Solidity smart contract (`ProgramRegistry.sol`) deployed on an EVM-compatible chain. It stores `programHash -> {location, owner}` mappings. |
| 31 | +4. **Program Storage (External):** A separate system (e.g., IPFS, web server) hosts the actual program ELF binaries. |
| 32 | + |
| 33 | +## Workflow |
| 34 | + |
| 35 | +1. **Program Registration (Developer):** |
| 36 | + - Compile RISC-V code to a Pico zkVM ELF binary. |
| 37 | + - Calculate the SHA256 hash of the ELF file. |
| 38 | + - Upload the ELF file to a persistent storage location (e.g., IPFS) and get its URI/URL. |
| 39 | + - Call the `registerProgram` function on the `ProgramRegistry` smart contract with the program hash and location URI. |
| 40 | +2. **Proof Request (User/Application):** |
| 41 | + - Construct a `ProofRequest` containing: |
| 42 | + - `program_hash`: The hash of the registered program to execute. |
| 43 | + - `inputs`: Hex-encoded input data for the program. |
| 44 | + - `proving_type`: `Fast`, `Full`, or `FullWithEvm`. |
| 45 | + - Optional overrides for program location or EVM configuration. |
| 46 | + - Submit the `ProofRequest` as a job call to the running Tangle Blueprint service (e.g., via a Tangle message targeting the service ID and `GENERATE_PROOF_JOB_ID`). |
| 47 | +3. **Proof Generation (Service):** |
| 48 | + - The Blueprint Runner receives the job call. |
| 49 | + - The `generate_proof` job function executes: |
| 50 | + - Retrieves the program location from the `ProgramRegistry` contract (unless overridden). |
| 51 | + - Downloads the ELF binary from the location. |
| 52 | + - Verifies the downloaded ELF hash against the requested `program_hash`. |
| 53 | + - Initializes the Pico `DefaultProverClient` (KoalaBear). |
| 54 | + - Executes the requested proving type (`prove_fast`, `prove`, or `prove_evm`). |
| 55 | + - For `prove_evm`, runs external Docker commands via the SDK to generate the final Groth16 proof and EVM verifier inputs. |
| 56 | + - Parses and collects the proof data and public values. |
| 57 | + - Returns the `ProofResult` (containing proof data, public values, etc.) back through the Blueprint SDK (e.g., as a response Tangle message). |
| 58 | + |
| 59 | +## Setup & Usage |
| 60 | + |
| 61 | +_(TODO: Add instructions on how to build, configure (environment variables for RPC URL, registry address, etc.), deploy the contract, and run the blueprint service.)_ |
| 62 | + |
| 63 | +## Development |
| 64 | + |
| 65 | +_(TODO: Add details on building the code, running tests, contributing guidelines.)_ |
0 commit comments