keep-starknet-strange / raito

Bitcoin ZK client written in Cairo.
https://raito.wtf
MIT License
40 stars 34 forks source link

[feat] Integrate new Utreexo scheme into the client #290

Open m-kus opened 12 hours ago

m-kus commented 12 hours ago

Currently client::main program which we use for integration tests supports vanilla Utreexo proofs, we need to swap it with the new Stump scheme.

Updating the client

Utreexo data is currently optional: if it's not provided via args, the program will skip proof verification. This is done through a custom Serde implementation.

What needs to be done:

Updating data scripts

Data generation script has a special mode "utreexo" which utilises Utreexo backend in Python for generating proofs. Since we cannot get full Utreexo tree data for arbitrary blocks we need to start from the very beginning (genesis) and apply all blocks till the one we interested in, capture Utreexo state before/after + proof, and then discard all the blocks except the latest one.

For the new scheme we are going to use the Bridge node in Rust https://github.com/Davidson-Souza/bridge/tree/shinigami-compat-patch-1 which dumps Utreexo state + batch proof for every block in JSON format. So now we are able to get the necessary info for arbitrary blocks, we just assume we can access a folder which contains data for all the Bitcoin history (pretty much how it works for timestamps or utxo in fast mode).

The expected folder structure:

raito
    \ scripts
        \ data
            \ .utreexo
                \ 0
                    \ 170.json

What needs to be done: