https://github.com/keep-starknet-strange/raito
Bitcoin ZK client written in Cairo.
https://github.com/keep-starknet-strange/raito
bitcoin cairo stark zero-knowledge-proofs
Last synced: about 2 months ago
JSON representation
Bitcoin ZK client written in Cairo.
- Host: GitHub
- URL: https://github.com/keep-starknet-strange/raito
- Owner: keep-starknet-strange
- License: mit
- Created: 2024-07-31T06:31:36.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-01-05T21:45:31.000Z (5 months ago)
- Last Synced: 2025-03-31T11:06:29.916Z (about 2 months ago)
- Topics: bitcoin, cairo, stark, zero-knowledge-proofs
- Language: Cairo
- Homepage: https://raito.wtf
- Size: 63.4 MB
- Stars: 57
- Watchers: 5
- Forks: 42
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
## Overview
Shinigami 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/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.
![]()
At its core, consensus client accepts two inputs: a batch of consecutive blocks n to m and a STARK proof of the state of the chain up to block nβ1. It ensures that the historical chain state is valid by verifying the STARK proof. Then, it produces a new chain state by applying the new blocks on top of the historical state. As a result, a proof of the new state is generated.
## Applications
Although this is a highly experimental project without immediate plans for deployment, there are many potential applications:
* light clients
* IBD speedup
* non custodial bridges
* layer 2s## Roadmap
![]()
### Milestone 1 - Block header validation
Implement a reduced light client that can verify a range of blocks starting at genesis.
It does not have to validate execution, just check that the block header fields follow the protocol.Tasks:
* [x] block hash computation
* [x] proof-of-work validation/computation
* [x] block time validation/computation
* [x] block difficulty adjustment
* [x] script for fetching arbitrary block data
* [x] script for preparing program arguments
* [x] script for running the program e2e for multiple blocks### Milestone 2 - Partial transaction validation
Extend light client with partial transaction validation, but without UTXO checks.
Tasks:
* [x] reassess validation check list (analyze Bitcoin core codebase)
* [x] generate & run integration tests e2e instead of Cairo codegen
* [x] transaction ID calculation
* [x] transaction root computation
* [x] validate transaction fee
* [x] validate coinbase transaction
* [x] validate that transaction can be mined (locktime, sequence, coinbase maturity)
* [x] validate segwit specific data (wtxid commitment)
* [x] validate block weight
* [x] script that fetches blocks extended with references UTXOs
* [x] script that runs the program e2e for a span of blocks### Milestone 3 - Bitcoin script validation
Try to run script validation with external Cairo crate.
Tasks:
* [x] Integrate Shinigami-script
### Milestone 4 - UTXO set verification
Add inclusion proofs for the UTXOs included in the block.
Tasks:
* [x] isolate unspendable outputs (OP_RETURN, etc)
* [x] implement cache for UTXOs spent in the same block they are created (*)
* [x] implement transaction outpoint hashing
* [x] implement Utreexo accumulator (addition)
* [x] Utreexo backend that maintains utxo set and Utreexo roots
* [x] implement Utreexo single inclusion proof verification
* [x] implement Utreexo single output removal
* [x] implement Utreexo bridge node that generates individual inclusion proofs
* [x] implement script that runs the program e2e for a span of blocks
* [x] implement Utreexo accumulator version compatible with [rustreexo](https://github.com/mit-dci/rustreexo)### Milestone 5 - Full consensus validation
Validate full block execution over large number of blocks, including the Bitcoin scripts checks and Utreexo proofs.
* [x] consensus logic
* [ ] consensus logic + utreexo proofs
* [ ] consensus logic + utreexo proofs + scripts### Milestone 6 - Proving
Recursively verify STARK proofs of chain state updates. Still largely tbd. From initial observations it is clear that a series of optimizations will be necessary.
* [ ] sha256 optimization
* [ ] don't use ByteArray when serializing data
* [ ] blocklevel recursion
* [ ] consider using garaga msm to batch signature verifications
* [ ] identify other Cairo code botlenecks# Contact
* [Telegram](https://t.me/ShinigamiStarknet)
* [OnlyDust](https://app.onlydust.com/p/raito---bitcoin-zk-client)## Usage
This will compile all the packages:
```bash
scarb build
```This will run tests for all the packages:
```bash
scarb test
```## Build dependencies
Install necessary packages required by Python scripts:
```bash
pip install -r scripts/data/requirements.txt
```## References
* [Data processing notes](./docs/data.md)
* [Utreexo implementation notes](./docs/utreexo.md)
* [ZeroSync](https://github.com/ZeroSync/ZeroSync)
* [Shinigami Script](https://github.com/keep-starknet-strange/shinigami)
* [STWO](https://github.com/starkware-libs/stwo)
* [Cairo](https://www.cairo-lang.org/)
* [Circle STARK paper](https://eprint.iacr.org/2024/278)## Contributors β¨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
AβΏdel β/21M πΊ - π±
π»
Maciej KamiΕski @ StarkWare
π»
Brandon R
π»
Tristan
π»
Jean-Michel
π»
lomasson
π»
Michael Zaikin
π»
Harsh Pratap Singh
π»
Xavek
π»
Olufemi Olumaiyegun
π»
MSG
π»
Mubarak Muhammad Aminu
π»
oluwapeski
π»
Steven
π»
Yusuf Habib
π»
Gerson
π»
PavitraAgarwal21
π»
Nguyen Dao
π»
Hunter001
π»
feltroid Prime
π»
Mexes
π»
BlockyJ
π»
Maksim Strebkov
π»
Herbie Wildwood
π»
Fishon Amos
π»
Wolf
π»
Ilia Batii
π»
Thomas Marchand
π»
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!