Skip to content

keep-starknet-strange/raito

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

raito-logo

Bitcoin ZK client written in Cairo.

GitHub Workflow Status Bitcoin Cairo Exploration Team

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

client

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

components

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:

  • block hash computation
  • proof-of-work validation/computation
  • block time validation/computation
  • block difficulty adjustment
  • script for fetching arbitrary block data
  • script for preparing program arguments
  • 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:

  • reassess validation check list (analyze Bitcoin core codebase)
  • generate & run integration tests e2e instead of Cairo codegen
  • transaction ID calculation
  • transaction root computation
  • validate transaction fee
  • validate coinbase transaction
  • validate that transaction can be mined (locktime, sequence, coinbase maturity)
  • validate segwit specific data (wtxid commitment)
  • validate block weight
  • script that fetches blocks extended with references UTXOs
  • 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:

  • Integrate Shinigami-script

Milestone 4 - UTXO set verification

Add inclusion proofs for the UTXOs included in the block.

Tasks:

  • isolate unspendable outputs (OP_RETURN, etc)
  • implement cache for UTXOs spent in the same block they are created (*)
  • implement transaction outpoint hashing
  • implement Utreexo accumulator (addition)
  • Utreexo backend that maintains utxo set and Utreexo roots
  • implement Utreexo single inclusion proof verification
  • implement Utreexo single output removal
  • implement Utreexo bridge node that generates individual inclusion proofs
  • implement script that runs the program e2e for a span of blocks
  • implement Utreexo accumulator version compatible with rustreexo

Milestone 5 - Full consensus validation

Validate full block execution over large number of blocks, including the Bitcoin scripts checks and Utreexo proofs.

  • 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

Usage

This will compile all the packages:

scarb build

This will run tests for all the packages:

scarb test

Build dependencies

Install necessary packages required by Python scripts:

pip install -r scripts/data/requirements.txt

References

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Aβ‚Ώdel ∞/21M 🐺 - 🐱
Aβ‚Ώdel ∞/21M 🐺 - 🐱

πŸ’»
Maciej KamiΕ„ski @ StarkWare
Maciej KamiΕ„ski @ StarkWare

πŸ’»
Brandon R
Brandon R

πŸ’»
Tristan
Tristan

πŸ’»
Jean-Michel
Jean-Michel

πŸ’»
lomasson
lomasson

πŸ’»
Michael Zaikin
Michael Zaikin

πŸ’»
Harsh Pratap Singh
Harsh Pratap Singh

πŸ’»
Xavek
Xavek

πŸ’»
Olufemi Olumaiyegun
Olufemi Olumaiyegun

πŸ’»
MSG
MSG

πŸ’»
Mubarak Muhammad Aminu
Mubarak Muhammad Aminu

πŸ’»
oluwapeski
oluwapeski

πŸ’»
Steven
Steven

πŸ’»
Yusuf Habib
Yusuf Habib

πŸ’»
Gerson
Gerson

πŸ’»
PavitraAgarwal21
PavitraAgarwal21

πŸ’»
Nguyen Dao
Nguyen Dao

πŸ’»
Hunter001
Hunter001

πŸ’»
feltroid Prime
feltroid Prime

πŸ’»
Mexes
Mexes

πŸ’»
BlockyJ
BlockyJ

πŸ’»
Maksim Strebkov
Maksim Strebkov

πŸ’»
Herbie Wildwood
Herbie Wildwood

πŸ’»
Fishon Amos
Fishon Amos

πŸ’»
Wolf
Wolf

πŸ’»
Ilia Batii
Ilia Batii

πŸ’»
Thomas Marchand
Thomas Marchand

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!