Skip to content

Commit

Permalink
🎉 init raito
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelStark committed Jul 31, 2024
1 parent bbb6432 commit 423ae8e
Show file tree
Hide file tree
Showing 16 changed files with 210 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @b-j-roberts
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/01_FEATURE_REQUEST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: Feature request
about: suggest new feature
title: "[feat] "
labels: "feature"
assignees: ""
---

<!-- feature description -->

#### References
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/02_BUG_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: Bug report
about: create bug report
title: "[bug] "
labels: "bug"
assignees: ""
---

**ver:**

<!-- reproducible report(current vs expected behavior) -->

**How to reproduce:**
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/03_CODEBASE_IMPROVEMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: Codebase improvement
about: docs, ci, tooling, other
title: "[dev] "
labels: "dev"
assignees: ""
---
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- enter the gh issue after hash -->

- [ ] issue #
- [ ] follows contribution [guide](https://github.com/keep-starknet-strange/raito/blob/main/CONTRIBUTING.md)
- [ ] code change includes tests

<!-- PR description below -->
4 changes: 4 additions & 0 deletions .github/linter/base_style.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
all
# lame rules
exclude_rule 'MD002'
exclude_rule 'MD041'
12 changes: 12 additions & 0 deletions .github/linter/readme_style.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
all
# allow inline HTML for README fmt
exclude_rule 'MD033'
# badges trigger rule
exclude_rule 'MD034'
# README img serves as 'First Header'
exclude_rule 'MD002'
exclude_rule 'MD041'
# TODO: disable/enable not working for all-contribs
exclude_rule 'MD013'
# Allow no endline at the end
exclude_rule 'MD047'
18 changes: 18 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: build

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
permissions: read-all

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: asdf-vm/actions/install@v3
- run: scarb fmt --check
- run: scarb build
26 changes: 26 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: check

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
permissions: read-all

jobs:
markdown:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
sudo gem install mdl
mdl -s .github/linter/readme_style.rb README.md
mdl -s .github/linter/base_style.rb .github
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: asdf-vm/actions/install@v3
- run: scarb test
65 changes: 63 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,63 @@
# raito
Bitcoin ZK client using Circle STARK proofs.
<div align="center">
<h1>Raito âš¡</h1>
<h2>Bitcoin ZK client written in Cairo.</h2>

<a href="https://github.com/keep-starknet-strange/raito/actions/workflows/check.yaml"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/keep-starknet-strange/raito/check.yml?style=for-the-badge" height=30></a>
<a href="https://bitcoin.org/"> <img alt="Bitcoin" src="https://img.shields.io/badge/Bitcoin-000?style=for-the-badge&logo=bitcoin&logoColor=white" height=30></a>
<a href="https://www.cairo-lang.org/"> <img alt="Cairo" src="https://img.shields.io/badge/Cairo-000?style=for-the-badge" height=30></a>

</div>

## About

Raito is a zero-knowledge Bitcoin client implemented in Cairo. It aims to provide trustless validation of the Bitcoin blockchain through STARK proof verification. It is heavily inspired by [ZeroSync](https://github.com/ZeroSync/ZeroSynchttps://github.com/ZeroSync/ZeroSync) project.

> **Disclaimer:** This project is in the early stages of development and should not be used in production. It will evolve rapidly, expect breaking changes.
Design goals:

- **Usability:** One-click install and run. WebAssembly compatibility for browser-based execution.
- **Maintainability:** Emphasis on simplicity and clean code structure.
- **Performance:** Optimized for speed and efficiency, leveraging STWO's next-generation prover.

## Name reference

Raito is a reference to Light Yagami (夜神月, Yagami Raito) from the manga/anime Death Note.

Why ?

- Raito in Japanese means "Light", which in turns can refer to Lightning âš¡ (and hence both a reference to speed of verification of the Bitcoin blockchain using a ZKP and a reference to the Lightning Network)
- Raito can work in tandem with [Shinigami](https://github.com/keep-starknet-strange/shinigami) that enables verification of Bitcoin Script programs. Raito = Consensus and Shinigami = Execution.

![Raito and Shinigami](./docs/img/memes/raito_shinigami_fusion.jpg)

### Running

```bash
scarb cairo-run --available-gas=200000000
```

This will run the provided Bitcoin Script in Cairo.

### Building

```bash
scarb build
```

This will compile all the components.

### Testing

```bash
scarb test
```

This will run the test-suite for all op-codes, integration, and test Bitcoin Scripts.

## References

- [STWO](https://github.com/starkware-libs/stwo)
- [Cairo](https://www.cairo-lang.org/)
- [Circle STARK paper](https://eprint.iacr.org/2024/278)
- [ZeroSync](https://github.com/ZeroSync/ZeroSync)
6 changes: 6 additions & 0 deletions Scarb.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Code generated by scarb DO NOT EDIT.
version = 1

[[package]]
name = "raito"
version = "0.1.0"
7 changes: 7 additions & 0 deletions Scarb.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "raito"
version = "0.1.0"
edition = "2023_11"

[dependencies]
starknet = "2.6.3"
Binary file added docs/img/memes/raito_shinigami_fusion.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/engine.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// The engine is the main component that coordinates the verification of the Bitcoin consensus rules in Cairo.
#[derive(Destruct)]
pub struct Engine {}

pub trait EngineTrait {
fn new() -> Engine;
fn check_consensus_rules(ref self: Engine) -> Result<ByteArray, felt252>;
}

pub impl EngineTraitImpl of EngineTrait {
fn new() -> Engine {
Engine {}
}


fn check_consensus_rules(ref self: Engine) -> Result<ByteArray, felt252> {
return Result::Ok("");
}
}
3 changes: 3 additions & 0 deletions src/lib.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod engine;

mod main;
13 changes: 13 additions & 0 deletions src/main.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use raito::engine::EngineTrait;
use raito::engine::EngineTraitImpl;

fn main() {
println!("Running Raito Bitcoin ZK client");
let mut engine = EngineTraitImpl::new();
let res = engine.check_consensus_rules();
if res.is_ok() {
println!("Execution successful");
} else {
println!("Execution failed");
}
}

0 comments on commit 423ae8e

Please sign in to comment.