No description
  • Cairo 81.3%
  • Python 18.7%
Find a file
2024-04-20 15:08:11 +02:00
.github/workflows rustflags 2024-04-16 17:10:55 +02:00
cairo fix 2024-04-18 17:03:53 +02:00
cairo-vm@b72f5a93ff cairo-lang-2.6.3 cairo-vm branch 2024-04-15 12:51:39 +02:00
.gitignore recursive layot bootloader version 2024-04-17 13:18:53 +02:00
.gitmodules scripts 2024-04-16 08:25:14 +02:00
bootloader_input.json scripts 2024-04-16 08:25:14 +02:00
cairo1.cairo program inputs tested 2024-04-16 16:52:49 +02:00
compile.py program inputs tested 2024-04-16 16:52:49 +02:00
install.py ci 2024-04-16 16:59:03 +02:00
LICENSE Create LICENSE 2024-04-16 21:41:33 +02:00
README.md README 2024-04-16 17:15:46 +02:00
run.py recursive layot bootloader version 2024-04-17 13:18:53 +02:00

Cairo1->Cairo0Bootloader

Continuous Integration - run

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:

  1. Clone Repository: Clone the repository and initialize submodules:

    git clone https://github.com/Okm165/cairo1-cairo0bootloader.git
    cd cairo1-cairo0bootloader
    git submodule update --init
    
  2. Setup Python Environment: Ensure you have a Python 3.9.0 environment set up & pip install colorama for pretty outputs.

  3. Installation: Run python install.py to install the necessary dependencies and set up the project.

  4. Compile Cairo1: Compile Cairo1 files into the Cairo PIE format by running python compile.py.

  5. 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!