|
1 |
| -# Overview |
| 1 | +# Cyferio SDK |
2 | 2 |
|
3 |
| -This package is a convenient starting point for building a rollup using the Sovereign SDK: |
| 3 | +> [!IMPORTANT] |
| 4 | +> To try out the FHE module, please visit [`feat/confidential-token`](https://github.com/cyferio-labs/cyferio-sdk/tree/feat/confidential-token) branch |
4 | 5 |
|
5 |
| -## The repo structure: |
| 6 | +## Overview |
6 | 7 |
|
7 |
| -- `crates/stf`: The `STF` is derived from the `Runtime` and is used in the `rollup` and `provers` crates. |
8 |
| -- `crates/provers`: This crate is responsible for creating proofs for the `STF`. |
9 |
| -- `crates/rollup`: This crate runs the `STF` and offers additional full-node functionalities. |
| 8 | +Cyferio SDK is a modular rollup framework with Fully Homomorphic Encryption (FHE) integration that simplifies the creation and management of confidential rollups, providing developers with the necessary tools to build privacy-preserving applications. |
10 | 9 |
|
11 |
| -(!) Note for using WIP repo. |
12 |
| -This repo utilizes private [Sovereign SDK repo](https://github.com/Sovereign-Labs/sovereign-sdk-wip) and default cargo needs this environment variable to use an SSH key: |
| 10 | +By leveraging FHE, advanced modular rollup designs, and parallelism in computational proofs within a trustless computing layer, Cyferio SDK enables secure, near real-time computations on both public and private on-chain states while preserving composability and interoperability. |
| 11 | + |
| 12 | +## Key Features |
| 13 | + |
| 14 | +- **Modular Architecture**: Highly adaptable zk-rollup framework integrating state-of-the-art privacy-preserving solutions like FHE and Zero-Knowledge Proofs (ZKPs). |
| 15 | + |
| 16 | +- **Module System Interface**: |
| 17 | + - Supports both stateless and stateful modules, enhancing composability. |
| 18 | + - Incorporates FHE-powered modules using the TFHE-rs library for computations on encrypted data. |
| 19 | + |
| 20 | +- **Data Availability Interface**: |
| 21 | + - Integrates with various data availability solutions (e.g., Celestia, Avail). |
| 22 | + - Compatible with mainstream Layer 1 blockchains for settlement layers. |
| 23 | + |
| 24 | +- **zkVM Interface**: |
| 25 | + - Supports optimistic, zero-knowledge, and verifiable FHE virtual machines. |
| 26 | + - Compatible with various zkVMs, including RISC Zero and SP1. |
| 27 | + - Produces succinct verifiable proofs for transaction executions. |
| 28 | + |
| 29 | +- **Threshold Service Network**: |
| 30 | + - Secure key management for FHE keys. |
| 31 | + - Robust FHE key generation and threshold decryption using MPC protocols. |
| 32 | + |
| 33 | +<p align="center"> |
| 34 | + <img src="assets/Cyferio SDK Arch.png" alt="TMC architecture"/> |
| 35 | + <br> |
| 36 | + <em>The Architecture of Cyferio SDK</em> |
| 37 | +</p> |
| 38 | + |
| 39 | +## Use Cases |
| 40 | + |
| 41 | +- **DeFi**: |
| 42 | + - **Dark Pools**: Enable private large trades to reduce market impact. |
| 43 | + - **Blind Auctions**: Conduct auctions with hidden bids to prevent manipulation. |
| 44 | + - **MEV-Resistant DEXs**: Build exchanges where transactions can't be front-run. |
| 45 | + - **Private Prediction Markets**: Enable on-chain prediction markets with confidential betting. |
| 46 | + |
| 47 | +- **Social Applications**: |
| 48 | + - **Efficient Identity Verification**: Perform identity checks without constant off-chain data retrieval. |
| 49 | + - **Privacy-Preserving Interactions**: Ensure all user interactions remain private. |
| 50 | + |
| 51 | +- **Gaming**: |
| 52 | + - **Real-Time Response**: Enable near real-time transaction responses in distributed systems. |
| 53 | + - **Secure Interactions**: Operate nodes in a "dark forest" state for enhanced security. |
| 54 | + - **Asset Integration**: Flexible combination of DeFi and GameFi assets. |
| 55 | + - **Flexible Gas Fees**: Implement dynamic gas fee structures to lower entry barriers. |
| 56 | + |
| 57 | +<p align="center"> |
| 58 | + <img src="assets/Cyferio SDK flow.png" alt="Cyferio SDK flow"/> |
| 59 | + <br> |
| 60 | + <em>The Workflow of Cyferio SDK</em> |
| 61 | +</p> |
| 62 | + |
| 63 | +## Getting Started |
| 64 | + |
| 65 | +Cyferio SDK is integrated with the [`Cyferio Hub`](https://github.com/cyferio-labs/cyferio-hub-node) in default. That means for local development environment, you have to run the Cyferio Hub node as DA layer before creating your confidential rollup with Cyferio SDK. Please refer to the [Cyferio Hub README](https://github.com/cyferio-labs/cyferio-hub-node/blob/main/README.md) for more details. |
| 66 | + |
| 67 | +Note that for local debugging, you can simply switch to `mock_da` by changing the feature flag in `crates/rollup/Cargo.toml` |
13 | 68 |
|
14 | 69 | ```
|
15 |
| -export CARGO_NET_GIT_FETCH_WITH_CLI=true |
| 70 | +[features] |
| 71 | +default = ["mock_da", "risc0"] |
16 | 72 | ```
|
17 | 73 |
|
18 |
| -# Running the sov-rollup-starter |
19 |
| - |
20 |
| -## How to run the sov-rollup-starter with mock-da |
| 74 | +## How to run the demo rollup with mock-da |
21 | 75 |
|
22 | 76 | 1. Change the working directory:
|
23 | 77 |
|
@@ -46,14 +100,16 @@ $ make test-create-token
|
46 | 100 | ```
|
47 | 101 |
|
48 | 102 | 5. Note the transaction hash from the output of the above command
|
49 |
| - ```text |
50 |
| - Submitting tx: 0: 0xc4a09c4bc4e0a2425384de1f9d468070f4616f03d503367287774c7191ef25db |
51 |
| - Transaction 0xc4a09c4bc4e0a2425384de1f9d468070f4616f03d503367287774c7191ef25db has been submitted: AcceptTxResponse { data: TxInfo { id: TxHash("0xa02ed59b5c698d49ad088584b86aff2134fd8e96746c1fce57b2518eb7c843e2"), status: Submitted }, meta: {} } |
52 |
| - Triggering batch publishing |
53 |
| - Your batch was submitted to the sequencer for publication. Response: SubmittedBatchInfo { da_height: 2, num_txs: 1 } |
54 |
| - Going to wait for target slot number 2 to be processed, up to 300s |
55 |
| - Rollup has processed target DA height=2! |
56 |
| - ``` |
| 103 | + |
| 104 | +```text |
| 105 | +Submitting tx: 0: 0xc4a09c4bc4e0a2425384de1f9d468070f4616f03d503367287774c7191ef25db |
| 106 | +Transaction 0xc4a09c4bc4e0a2425384de1f9d468070f4616f03d503367287774c7191ef25db has been submitted: AcceptTxResponse { data: TxInfo { id: TxHash("0xa02ed59b5c698d49ad088584b86aff2134fd8e96746c1fce57b2518eb7c843e2"), status: Submitted }, meta: {} } |
| 107 | +Triggering batch publishing |
| 108 | +Your batch was submitted to the sequencer for publication. Response: SubmittedBatchInfo { da_height: 2, num_txs: 1 } |
| 109 | +Going to wait for target slot number 2 to be processed, up to 300s |
| 110 | +Rollup has processed target DA height=2! |
| 111 | +``` |
| 112 | + |
57 | 113 | 6. To get the token address, fetch the events of the transaction hash from #5
|
58 | 114 |
|
59 | 115 | ```bash,test-ci
|
@@ -126,67 +182,4 @@ $ curl -Ss http://127.0.0.1:12346/modules/bank/tokens/token_17zrpsyv06x7wmf2hg87
|
126 | 182 | {"data":{"amount":1000000,"token_id":"token_17zrpsyv06x7wmf2hg878gg5szwurckr3e2u77fvrdmanjhve8r2sj4jy42"},"meta":{}}
|
127 | 183 | ```
|
128 | 184 |
|
129 |
| -## How to run the sov-rollup-starter using Celestia Da |
130 |
| - |
131 |
| -1. Change the working directory: |
132 |
| - ```bash |
133 |
| - $ cd crates/rollup/ |
134 |
| - ``` |
135 |
| -2. If you want to run a fresh rollup, clean the database: |
136 |
| - ```bash |
137 |
| - $ make clean |
138 |
| - ``` |
139 |
| -3. Start the Celestia local docker service. (make sure you have docker daemon running). |
140 |
| - ```bash |
141 |
| - $ make start |
142 |
| - ``` |
143 |
| -4. Start the rollup node with the feature flag building with the celestia adapter. To build with the sp1 prover, you may replace `risc0` with `sp1`. |
144 |
| - This will compile and start the rollup node: |
145 |
| - ```bash |
146 |
| - $ cargo run --bin node --no-default-features --features celestia_da,risc0 |
147 |
| - ``` |
148 |
| -5. Submit a token creation transaction to the `bank` module. |
149 |
| - To build with the sp1 prover, you may replace `risc0` with `sp1`. |
150 |
| - Using `CELESTIA=1` will enable the client to be built with Celestia support and submit the test token |
151 |
| - ```bash |
152 |
| - $ CELESTIA=1 ZKVM=risc0 make test-create-token |
153 |
| - ``` |
154 |
| -6. Note the transaction hash from the output of the above command |
155 |
| - ```text |
156 |
| - Submitting tx: 0: 0xc4a09c4bc4e0a2425384de1f9d468070f4616f03d503367287774c7191ef25db |
157 |
| - Transaction 0xc4a09c4bc4e0a2425384de1f9d468070f4616f03d503367287774c7191ef25db has been submitted: AcceptTxResponse { data: TxInfo { id: TxHash("0xa02ed59b5c698d49ad088584b86aff2134fd8e96746c1fce57b2518eb7c843e2"), status: Submitted }, meta: {} } |
158 |
| - Triggering batch publishing |
159 |
| - Your batch was submitted to the sequencer for publication. Response: SubmittedBatchInfo { da_height: 2, num_txs: 1 } |
160 |
| - Going to wait for target slot number 2 to be processed, up to 300s |
161 |
| - Rollup has processed target DA height=2! |
162 |
| - ``` |
163 |
| -7. To get the token address, fetch the events of the transaction hash from #5 |
164 |
| - |
165 |
| - ```bash |
166 |
| - $ curl -sS http://127.0.0.1:12346/ledger/txs/0xc4a09c4bc4e0a2425384de1f9d468070f4616f03d503367287774c7191ef25db |
167 |
| - # Output omitted, should be similar to what has been seen in mock-da section |
168 |
| - ``` |
169 |
| - |
170 |
| -8. Get a total supply of the token: |
171 |
| - |
172 |
| -```bash,test-ci,bashtestmd:compare-output |
173 |
| -$ curl -Ss http://127.0.0.1:12346/modules/bank/tokens/token_17zrpsyv06x7wmf2hg878gg5szwurckr3e2u77fvrdmanjhve8r2sj4jy42/total-supply | jq -c -M |
174 |
| -{"data":{"amount":1000000,"token_id":"token_17zrpsyv06x7wmf2hg878gg5szwurckr3e2u77fvrdmanjhve8r2sj4jy42"},"meta":{}} |
175 |
| -``` |
176 |
| - |
177 |
| -## Enabling the prover |
178 |
| - |
179 |
| -By default, demo-rollup disables proving (i.e. the default behavior is. If we want to enable proving, several options are available: |
180 |
| - |
181 |
| -- `export SOV_PROVER_MODE=skip` Skips verification logic. |
182 |
| -- `export SOV_PROVER_MODE=simulate` Run the rollup verification logic inside the current process. |
183 |
| -- `export SOV_PROVER_MODE=execute` Run the rollup verifier in a zkVM executor. |
184 |
| -- `export SOV_PROVER_MODE=prove` Run the rollup verifier and create a SNARK of execution. |
185 |
| - |
186 |
| -#### Note: Check that users and sequencers have enough tokens to pay for the transactions. |
187 |
| - |
188 |
| -For the transaction to be processed successfully, you have to ensure that the sender account has enough funds to pay for the transaction fees and the sequencer has staked enough tokens to pay for the pre-execution checks. This `README` file uses addresses from the `./test-data/genesis/demo/mock` folder, which are pre-populated with enough funds. |
189 |
| - |
190 |
| -To be able to execute most simple transactions, the transaction sender should have about `1_000_000_000` tokens on their account and the sequencer should have staked `100_000_000` tokens in the registry. |
191 |
| - |
192 |
| -More details can be found in the Sovereign book [available here](https://github.com/Sovereign-Labs/sovereign-book). |
| 185 | +Feel free to explore and contribute to the project. For any questions or issues, please open an issue or contact the maintainers. |
0 commit comments