Bruno Lulinski
    • 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 No publishing access yet

      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.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    Technical Description === [TOC] # Census & Census Proofs The **census** is the set of NFT holders, as defined by the EVM Merkle Patricia Trie. The census is obtained directly from the Ethereum blockchain (using Etherum storage proofs) and does not need to be separately buit. This is arguably the most groundbreaking feature of our scheme. The **census proof** will combine a ZKP of [ECDSA verification](https://github.com/noir-lang/noir/blob/master/noir_stdlib/src/ecdsa_secp256k1.nr) and an [Ethereum storage proof](https://aztecnetwork.notion.site/Storage-Proof-Ethereum-16bf3cc90612467ca1ca4638f3b7d5cd), which together proves token ownerships and delegations of voters without revealing the identites of voters. The voter identity remains private as the proof proves that the voter knows a $privateKey$ for which its address holds a certain token for the given $root$ (i.e. at a particular block), without revealing the voter address nor keys. A typical voting action starts with voters [retrieving Merkle proofs](https://eips.ethereum.org/EIPS/eip-1186) of their NFT ownership / delegation record from an Ethereum node / gateway, generating signatures with their Ethereum key, and feeding them as inputs of a Noir census proof. :::info **Contents of a Vote Package** A vote package is the data sent to the contract to cast a vote. It is used to verify voting eligibility and store the vote in the contract. It contains the following elements: - A merged ZKP consists of: - $zkOwnershipProof$ that proves the NFT is either owned by or delegated to the signer for a specified `EthPatriciaTrie_Root` corresponding to a given block number - $correctVoteValueProof$ that proves: - If vote is encrypted: `encrypted(vote_value)` has been correctly computed for the given `encryption_public_key` - If vote is unencrypted: `vote_value` contains a valid value ($v_i \in \{0,1, 2\}$, {abstain, yes, no}) - $correctNullifierProof$ that prevents double-voting by proving the `nullifier` is: - Well computed from the `voter_address_privateKey` - Well computed from the NFT public data - `nullifier`: linked to the NFT - `vote_value`: the value of the vote, either encrypted or not (configurable) ::: # Vote verification and tallying using a Hash-chain of encrypted_votes A Hash-chain is used to guarantee that the voting smart contract knows the current state of the election and can check if the results of the election and the proof it recieves do indeed match the state of the election. It does not require homomorphic encryption. The - Voter sends their encrypted_vote value to the SmartContract - SC computes the `Hash(encrypted_vote)` - SC stores `curr_hash = Hash(Hash(encrypted_vote), curr_hash`) - the SC mantains `curr_hash` and stores `encrypted_vote` as events - the `encrypted_vote` values are accessible through emit-events At the end of the voting period, anybody (with a suitably powerful machine) can compute the tally: - get all the `encrypted_votes` from the emit-events - compute the hash-chain until the last `curr_hash` - generate a results-proof which proves: - correct decryption of all `encrypted_votes` - all the `decrypted_votes` added give certain `result` - the chain-hash for the given `encrypted_votes` corresponds to the onchain-living `curr_hash` - the `proof` is sent onchain together with the `result` - verification of proof: - public-inputs: `curr_hash, result` For the hash, we will use keccak256, as it is cheaper (in terms of gas costs) to compute in the contract. The result+proof will be a bit costly to generate, but this is not a problem as this needs to be done only once at the end of the voting process, and can be done on a 'powerful server'. # Achieving Tally Fairness using a Public Time-lapse Cryptographic Service To achieve tally fairness, i.e. to make it impossible to tally a proposal’s votes before the voting period ends, there are two main options: * a commit/reveal process, which completely avoids off-chain dependency; * encrypted ballots, with a mechanism for uncovering the secret encryption key after the voting period ends. The first option is considered impractical because it requires two SC interactions for every voter. The second option is also less than ideal, as it usually requires a distributed key generation ceremony before the vote, and a secret key uncovering ceremony afterwards. To eliminate this problem, we propose to create a **public time-lapse cryptography service** for a range of public key cryptographic schemes. The idea is the following: For a chosen scheme supported by the system and a future date (up to for example 1 year in the future), the system will already have published a specific public key whose corresponding private key is scheduled to be published on the desired future date. At any moment, there will therefore be many publicly available keys, with new public keys published and new private keys uncovered daily. In terms of trust assumptions: * for some schemes, will need to trust the parties participating in the system to not collude and uncover the secret keys early. * for other schemes, we will be able rely on existing external services (cf tlock which relies on an external randomness beacon) which will give us much higher trust guarantees. One of our research tasks will be to determine which schemes can be secured by external data or schemes, such as randomness beacons or data from major blockchains. # Private Gas Payment & Vote Power Obfuscation ## Prepaid voting with delay-relayer We now describe an approach allowing a DAO to pay for the votes of its members. For a given election, funds are deposited into the voting contract and earmarked for that election. When a valid vote is submitted for that election, the corresponding gas costs as well as a small premium are returned to the submitter, for as long as funds are available. If any funds are left after the election, they can be reclaimed. This way, NFT holders can submit votes to a relayer without needing to deal with gas costs. ## Voting power obfuscation To prevent identification of voters by their voting power, there will be a unique vote per NFT. Users will still have to make sure these votes are submitted from another Etherum address, with the submissions spaced out over time. This can be done by the delay-relayers. For accounts with multiple tokens, we will look into producing proofs for fixed amounts of tokens (e.g. 2, 5, 10 tokens). However, this feature is out of the scope of the current proposal (see [Further work](https://hackmd.io/L6oniVQNRh2eT2nLjOfKLA)). # ZK Proving Analysis This proposal targets at constructing ZK proofs in-browser via Noir’s multi-threaded WASM prover. This section analyses the feasibility of achieving so. ## Constraint Count We estimate that the constraint count of this proposal's Noir circuit should not exceed ~600,000 constraints, and should be easily provable in a web browser. The majority of the constraint cost will come from Ethereum storage proofs due to the heavy use of the Keccak algorithm. The cost of a Keccak hash in Noir is ~18,000 constraints. The majority of smart contracts do not have deep storage trees (for an NFT contract the tree depth is likely close to $log_2(\text{total number of NFTs})$). For an NFT contract with $2^{14}$ (i.e. >16,000) NFTs, we estimate that a storage proof of such an NFT balance should require ~8-14 Keccak hashes (i.e. ~140,000-250,000 constraints). Another often-notable constraint cost comes from the act of validating an Ethereum signature within a Noir circuit. Noir supports an optimised ECDSA signature verification gadget that can validate a signature in ~36,000 constraints. Each voting action requires 1 ECDSA signature verification to be proved. Considering the constraint count limit to prove Noir circuits in browser is ~$2^{20}$ (i.e. ~1,000,000) constraints, the resulting circuit of this proposal should be easily provable in a web browser, even if multiple storage proofs are required. ## Proving Time We estimate that the proving time of this proposal's Noir circuit should not exceend 1-2 minutes. With respect to proving times, the proving backend this project is expected to utilise with Noir is identical to what the current Aztec Connect circuits running in production are based on. Using that as a frame of reference, it typically requires 5 seconds on a modern device to compute a proof of a circuit of size $2^{16}$ (i.e. ~65,000) constraints. Prover times are broadly linear in circuit size, meaning that proofs of this project should, in the worst case, take 1-2 minutes to compute. # Gas Costs Analysis The expected gas costs are as follows: | Action | Gas estimation | Who pays | | -------- | -------- | -------- | | Voting process setup | 100-300k | Organiser | | Cast a vote | 400-500k | Voter (or a [third party](https://hackmd.io/1MqXYKcrRRSnB7pvnY8jYA#Private-gas-payment-and-vote-origin-obfuscation)) | | Submit the result of a voting process and its proof | 400-500k | Submitter (anyone) |

    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
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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