Paul Peregud
    • 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Proof of staking circuit design ## Goals Being able to do privacy-preserving claims about my own staking history that can be automatically checked. ### Why existing solutions don't allow you to do that? The most basic way of proving to someone some fact about your history of staking is to show them Ethereum blockchain, point out deposit and withdrawal TXes, and prove that you own the account that made those transactions. Problem with this approach - it is not privacy preserving (you reveal everything about your Ethereum usage) and it is not tunable (you don't decide how much verifier will learn). ## Transcript problem Ethereum does not enable easy creation of zksnark proofs about it's contents. One can attempt to prove a state of particular cell (32 bytes) of Ethereum state. Creating a merkle proof against hash of the state at particular block height is easy. Dealing with Solidity contract variable layout is also realistic. The real problem with such proof - you can't make it privacy preserving. One can create a circuit that will allow you to make claims, but unfortunately this circuit will be huge. Which means long proving times and big RAM requirements. There is also a problem of data representation in Ethereum blockchain. To prove that funds hasn't moved between block n and n+k one would need to construct a proof for exact amount of funds for each of the blocks in that range - k+1 proves. While it is possible without blowing up circuit size even more (with help of recursive snarks), amount of computation needed is rediculous. Which means that to make this problem tracktable we need to write our own transcript and make claims against it. ## Protocol custody problem ### Approaches that do not work * stake attributed to the owner. In such case owner can deposit through protocol, withdraw outside of protocol, deposit through protocol again. This fakes wei\*block score and destroys transcript usefulness for ALL PARTICIPANTS, not just cheater. * stake of all of owners is attributed to the protocol contract. This breaks more interesting staking protocols (all with non-linear rewards, all where stake is connected with some obligations and possible penalties - such as Ethereum PoS). Solution: **create a vault contract per owner**, let vault stake on behalf of the owner. ## Design Protocol participants opt-in before making stakes. Their deposits and withdrawals are marked in the transcript. Transcript is constracted in provably correct way (guaranteed by both Ethereum and zksnarks). Next participants can create zksnark proofs for claims such as: * I've been staking not less that 100 ETH during March of 2023 * During 2023 my staking score was between 1200 and 2400 ETH*months ### Limitations Negative claims (*I wasn't staking during march 2023* or *I was staking less than X during march 2023*) are not supported - one can always dodge the protocol by staking directly. ## Transcript Transcript is organized as a binary merkle tree of fixed depth with leaves representing staking and unstaking events. Each leaf contains: * address of the token * address of the staker * nonce * current staked amount * current score (unit: wei\*block) * event block-height Leafs are hashed using zksnark-friendly hash. Merkle tree nodes are hashed with the same hash. Transcript is not stored on-chain. Only its current root. Apart from transcript, contract stores {token, staker, nonce} triplets. Update with nonce n is organized in similar manner to Tornado Cash updates. **Update circuit** takes merkle proofs of leafs {token, staker, n-1, ..}, {token, staker, n, ..}, checks correctness of computation of current staked amount, current score etc. Public inputs are: token, staker, n, delta of staked funds, event block height. ## Proofs Proofs are circuits that make claims against some of the values of transcript root hash. Such circuits can be provided by the validator. To check proof validity, validator will need to check correctness of its public inputs, such as transcript tree hash, dates, amounts (and possibly challenge string). ### Designated verifier Proof can be bound to a particular verifier. This is done by making designing a circuit to proof one of two thing: `claim is correct` OR `prover has private key of the verifier`. This way we can prevent proof reuse outside of context intended by the prover. ### Nullifiers If client protocol uses PRODUCT as a way to obtain sybil resistance, nullifier can be used to prevent prover from making multiple claims. Nullifier can be a function of prover's private key. TODO: consider using new type of nullifiers (demoed at Bogota) to achieve that. ### Domain separation Nullifiers can be bound to particular domain/protocol. This way staker can create two identities in different contexts without linking them together. This problem arises mostly in context of nullifiers. Domain binding is done by making nullifier a function of private key and domain string.

    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