- Cairo 81.3%
- Python 18.7%
|
|
||
|---|---|---|
| .github/workflows | ||
| cairo | ||
| cairo-vm@b72f5a93ff | ||
| .gitignore | ||
| .gitmodules | ||
| bootloader_input.json | ||
| cairo1.cairo | ||
| compile.py | ||
| install.py | ||
| LICENSE | ||
| README.md | ||
| run.py | ||
Cairo1->Cairo0Bootloader
This project implements a modified version of the Cairo0 bootloader to facilitate the loading and execution of Cairo1 compiled PIE zip files. This enables interoperability between Cairo1 and Cairo0, allowing Cairo1 tasks to run within the Cairo0 bootloader environment.
Getting Started
To set up the project environment and run the bootloader, follow these steps:
-
Clone Repository: Clone the repository and initialize submodules:
git clone https://github.com/Okm165/cairo1-cairo0bootloader.git cd cairo1-cairo0bootloader git submodule update --init -
Setup Python Environment: Ensure you have a Python 3.9.0 environment set up &
pip install coloramafor pretty outputs. -
Installation: Run
python install.pyto install the necessary dependencies and set up the project. -
Compile Cairo1: Compile Cairo1 files into the Cairo PIE format by running
python compile.py. -
Run Bootloader: Start the bootloader by running
python run.py, which will initiate the loading and execution of Cairo1 tasks within the Cairo0 environment.
This example demonstrates running a simple Cairo1 program within the Cairo0 provable environment:
use core::{
hash::{HashStateTrait, HashStateExTrait, Hash},
integer::U128BitAnd,
pedersen::PedersenTrait,
};
use poseidon::{hades_permutation, poseidon_hash_span};
fn main(index_a: u32, array_a: Array<u32>, index_b: u32, array_b: Array<u32>) -> (bool, felt252, u128, felt252) {
let range_check = *array_a.at(index_a) + *array_b.at(index_b) > 10;
let mut state = PedersenTrait::new(2);
state = state.update_with(2);
let pedersen = state.finalize();
assert(pedersen == 1180550645873507273865212362837104046225859416703538577277065670066180087996, 'Invalid value');
let bitwise = U128BitAnd::bitand(0x4, 0x5);
assert(bitwise == 4, 'Invalid value');
let (poseidon, _, _) = hades_permutation(1, 2, 3);
assert(poseidon == 442682200349489646213731521593476982257703159825582578145778919623645026501, 'Invalid value');
(range_check, pedersen, bitwise, poseidon)
}
The execution of Cairo0 bootloader can then be proven using a STARK prover like stone-prover.
Work in Progress
At the moment, the following builtins are supported: [output, range_check, pedersen, bitwise, poseidon]. Stay tuned for more additions!