Lukas George
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    1
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # A light introduction to ZeroSync As easy as setting up a Bitcoin node may be it requires downloading a massive amount of blocks from other peers in the network - often for multiple days. This process is necessary to ensure that the newly spun-up node eventually holds the correct state of the Bitcoin chain. However, by utilizing zero-knowledge proofs you would able to verify the latest state of the chain in an instant. At least as long as someone supplies such proof... [ZeroSync](https://github.com/ZeroSync/ZeroSync) tries to fill the aforementioned gap as a tool to generate a proof attesting to the correct validation of a chain of Bitcoin blocks. It resembles a full node implementation that does not only yield you the final state after all transactions of the blocks were applied but also a way to verify this validation process at a later time. We are first going to look into the light client version of ZeroSync that only validates block headers (which is everything not related to transactions) before we move on to the measures taken to allow the validation of entire blocks. ## Bitcoin's Block Header Validation The chain of block headers provides everything a light client needs to validate the proof of work and the correct arrangement of blocks in the chain. When receiving a block header the light client checks it against Bitcoin's consensus rules: 1. The block hash has to be below the current target - a number that represents a hash with a certain amount of leading zeros. Often also referred to as the difficulty. 2. The encoded previous block hash of the current block is indeed the previous block's hash. 3. The block's timestamp is not below the median of the preceding eleven blocks' timestamps and not above the network time plus two hours. 4. The correct target is encoded in the block. In case a retarget happened the new target was correctly derived from the epoch timestamps. While rules 1 and 2 directly enforce the correct formation and mining of the chain, rules 3 and 4 are required so that no one can adjust the target to their own will. Otherwise, they were able to mine new blocks at a faster rate than honest nodes by increasing the target (which can be done by decreasing the epoch's timestamp delta) or they could decrease the target to make it artificially harder to mine blocks. ## Verifiable Computation for Block Header Validation By implementing the above rules in [Cairo](https://www.cairo-lang.org/), a language used to create provable programs, we can create a program that validates a single block and can generate a proof for it if, and only if, the validation was successful. We make use of an open-source prover for Cairo called [giza](https://github.com/maxgillett/giza) (and contribute to its implementation for recursive proofs) for proving the generated program and its execution trace. Due to the underlying STARK protocol, forging a proof of execution that attests to the correct validation of the block header is infeasible. A correct proof has a size of a few hundred kilobytes and can be verified on other blockchains, off-chain (e.g. for node syncing) or even in another STARK proof. To generate a proof for multiple successive block headers we can batch their validation together in a [single Cairo program](https://github.com/lucidLuckylee/LightSync) as long as the underlying prover machine has enough processing power. A proof for the entire Bitcoin chain can be created by verifying several batch validation proofs in a new STARK proof - making use of so-called [recursive proofs](https://medium.com/@starkware/recursive-starks-78f8dd401025). ![Batching batches: Reducing chain proofs to a single proof](https://i.imgur.com/9Gnq5ax.png) <p style="text-align: center;"><i> Batching batches: </i>Multiple batch proofs can be reduced into a single proof by verifying them recursively.</p> ## Approaching Entire Blocks Hashing the block header twice with SHA256 is by far the most expensive operation of the block header validation. Current Bitcoin blocks can contain more than 2000 transactions and, therefore, validating them in a full node fashion is magnitudes more computationally expensive than validating the header - every transaction has to be hashed. We can no longer validate reasonable batches of blocks in a single proof without proof recursion and additionally have to keep track of a chain state (mostly composed of the UTXO set after each block) that has to be carried over between every block's validation. ### Coping with the UTXO Set While STARK proofs are succinct such that they are easier to verify than validating the respective blocks, the chain state has to be part of each proof's public input and would blow up its size by multiple gigabytes. The Bitcoin UTXO set has two interesting properties: First of all, UTXOs can be later deleted from the set (a block uses them in a transaction) and each block only needs the information of a small subset of the UTXO set (because there is only a certain total amount of transaction inputs in a block). Therefore, we are using an accumulator - specifically [UTreeXO](https://dci.mit.edu/research/2019/6/6/utreexo-a-dynamic-hash-based-accumulator-optimized-for-the-bitcoin-utxo-set), a form of Merkle mountain range that can swap tree nodes and, by doing so, reduces the root recalculations after removing a leave from the UTXO set - to handle succinct state in- and output for every validation run. The state then only includes a list of UTreeXO root hashes that represent the whole UTXO set. In case a transaction in the currently validated block uses a specific UTXO it can be fed to the program via Cairo's hints (which are **not** part of the public input) together with a membership proof. ### Proof Scheme We want to start by creating an own proof for every block so we have to find a way to eventually compress them as we did with the batches of the light version of ZeroSync. For now, this will be done in the most reduced and straightforward way: Every proof will be verified by the next one - essentially a tree with width one - and we will refer to this as incrementally verifiable computation (IVC). ![ZeroSync IVC](https://i.imgur.com/qxc1DkM.png) <p style="text-align: center;"><i> Incrementally verifiable computation:</i> There is a recursive verifier attached to the block validation program that verifies the previous chain proof. Every proof includes the validation of the current block and the verification of all previous blocks. </p><br> Note that this can be improved to be more dynamic and to allow the generation of proofs for subsequent blocks in parallel. We could replace each IVC step (so block validation) with a recursive proof tree over multiple block validation proofs and then only call the recursive verification part of the IVC step after the tree has compressed, e.g., 10 blocks into a single proof. These 10 blocks could have been generated in parallel, by simulating the block validation program written in Cairo by a different program that is not running in the Cairo virtual machine - so there is no proof of execution, but we can get the resulting output state. This state can be fed into the next block's validation while the current validation may still be running. Of course, the recursive verification in the tree would have to check that eventually all input states match the previous output state. ## Conclusion We introduce ZeroSync a work-in-progress tool to generate STARK proofs of the Bitcoin blockchain with the first milestone to create a single proof for the entire chain. This proof in combination with the corresponding UTXO set can be used to instantly sync a bitcoin full node. At the current state the Bitcoin logic is implemented up to the point of an assume-valid node, so no transaction script validation yet, and we are working towards the recursive verification. The first benchmarks look promising and we are able to validate a block with 108 transactions in around 5 million of Cairo's steps. ZeroSync is an open-source effort so do not hesitate to check out and contribute to [the repository](https://github.com/ZeroSync/ZeroSync) and [work in progress website](https://zerosync.org/) yourself. For further questions or remarks get in touch with [me](https://twitter.com/lucidLuckylee/) or [ZeroSync](https://twitter.com/ZeroSync_) via Twitter. We would love to hear from you!

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully