# Zk Bitcoin Block Verification
## Goals
we wanted to verify single block header inclusion in bitcoin blockchain using recusive zksnarks with proof system likes plonky2.
## Assumption
- Verify single block header inclusion in the Bitcoin blockchain using SP1 or Halo2 recursive zk-SNARKs proof system (similar to Plonky2).
- Verify block inclusion and validity in the Entire Bitcoin blockchain.
- Create one proof to verify the entire Bitcoin state.
Minimize storage requirements by avoiding the need to store entire BTC headers onchai.
## Proof of Concept
### Single Block Header Verification Circuit
Input: Block header data
1. Calculate block hash
2. Verify difficulty meets target
3. Verify proof of work
output: proof, blockhash as public inputs
### Blockchain State Circuit:
Input: List of all block proof generated from single block header circuits and combine to build merkle proof out the inputs mentioned
output: Single proof which will be saved on chain

- [reference from zkTree paper](https://eprint.iacr.org/2023/208.pdf)
### Flow
1. We should able fetch all block header from bitcoin.
2. once we have all block header we will pass them into
`Single Block header Verification Circuit` and generate proof and store in offchain
3. we can build `merkle proofs of proofs` from `bitcoin state circuit` and calculate merkle root hash and store in onchain with proof.
4. We can prove block inclusion by calculating the Merkle path and passing it to EVM for Merkle root verification
5. Merkle path calculating, neither we don't want to store each proof onchain or block headers. since we are saving proof we can Calculate merkle root path.
6. whenever there is new block mined we pull latest block and generate proof and submit it onchain to verify it.
#### Research topics
1. how can we do proof aggreation more optimal and can we derive indivual proof from that?
2. folding schemas?
3. SP1 does it support Proof carrying data mechinsm?
4. Btcwrap project used dummy valid on tree. instead of updating?
5. how can we calcuating merkle root path
6. how does proof aggreation sp1 works? is it ivc or pcd?
7. can we use data compression techniques?