yisun
    • 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
    • Engagement control
    • 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 Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control 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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # zkAttestor: Trustless on-chain Ethereum indexing Although Ethereum has a large set of on-chain data, only the small portion of current **state** data is available for use in smart contracts. This means on-chain data like historical state, **transactions** and **receipts** are not available for use in dapps. With this enhanced set of on-chain data, dapps could deliver richer experiences: * A mining DAO could trustlessly slash miners for mining a sandwich attack. * A new lending protocol could offer better terms to past Aave or Compound users. * A defi protocol could update its risk parameters based on the worst loan-to-value achieved over the past week. **zkAttestor** solves this problem with the magic of zkSNARK proofs. It produces zkSNARK-based attestations to data from any Ethereum state or block, trustlessly verified on-chain. By using zkAttestor, downstream applications can access historical block or state information for use cases like on-chain reputation, programmable identity, and defi primitives involving history. ## What is zkAttestor? zkAttestor consists of two components: * The `ZKAttestor` smart contract on Ethereum which validates claims about historical states, transactions, or receipts on Ethereum and stores them on-chain. * A permissionless off-chain proving service which generates zkSNARK proofs of such claims and allows users to put them on-chain. ![](https://hackmd.io/_uploads/SyQqwXwaq.jpg) To use zkAttestor to prove a claim about historical state (e.g. "I owned CryptoPunk #1 at block 14194126."), a user can: * Query an archive node to get an **Ethereum light client proof** of the claim. * Use the zkAttestor ZK circuits to produce a **zkSNARK proof** that the light client proof is valid. * Submit the zkSNARK proof to the `ZKAttestor` smart contract, where it will be verified on-chain and checked against a trustlessly cached set of Ethereum block headers. Initially, we will operate an off-chain proving service to automate this process for users, but the entire process is **permissionless** and **trustless**. Users are always able to generate their own proofs and they do not need to trust any aspect of our proving server -- the resulting zkSNARK proofs will be verified on-chain. Our live demo at [zkattestor.xyz](https://www.zkattestor.xyz) illustrates this process with live contracts deployed on the Goerli testnet. ## What can I use it for? zkAttestor can be useful for any protocol or dapp where historical on-chain data is important. A few of the initial applications we envision include the following. ### On-chain reputation By enabling access to the past transaction history of Ethereum accounts, zkAttestor enables dapps to construct reputations for them based on their past on-chain activity. For example, zkAttestor could prove the claim "Address ABC has repaid a loan of at least 1 ETH on Aave", which may make the owner of ABC a good candidate for a referral bonus for a competing lending protocol. Unlike existing approaches to reputation, this reputation can be computed and verified independently of any trusted third party. ### Programmable identity Experiments such as [Cabal](https://www.cabal.xyz/), [heyanon](https://www.heyanon.xyz/), and [Sismo](https://www.sismo.io/) allow users to show they are members of a certain on-chain group (e.g. CryptoPunk owners) but use zero-knowledge to avoid revealing other facts about their identity. Because they do not have access to the on-chain Ethereum state within a SNARK, these applications rely on a trusted third party to create groups. zkAttestor removes this trust assumption and enables applications to use arbitrary on-chain criteria for group membership. ### Application primitives involving history Applications use two approaches today to work around limits on state access to deliver richer functionality. One approach involves caching historical information using expensive checkpointing, like for [Uniswap's TWAP computation](https://docs.uniswap.org/protocol/concepts/V3-overview/oracle) or ERC-20 tokens using [Compound governance](https://github.com/compound-finance/compound-protocol/blob/a3214f67b73310d547e00fc578e8355911c9d376/contracts/Governance/Comp.sol#L233), where extra gas is used on *every token transfer* to cache governance weights. Another approach is to use trusted off-chain governance or oracles, like [Gauntlet's parameter updates for Aave](https://app.aave.com/governance/proposal/70/) or [Chainlink oracles](https://data.chain.link/). zkAttestor provides a more efficient and trustless approach. By giving smart contracts historical state information, it removes the need for checkpointing. For example, zkAttestor enables developers to compute Uniswap v2 TWAP over any time interval without any prior checkpointing. Furthermore, zkAttestor can completely remove the use of trusted third party for access to on-chain data, resulting in fewer necessary trust assumptions for users. ## How do I integrate with zkAttestor? Developers can integrate with zkAttestor in two ways. The simplest method, live on testnet today, is to call into the `ZKAttestor` smart contract to verify historical state. We provide an `attestSlot` function which accepts a claim of the form "the value at `slot` for `address` at `block` was `value`", verifies it in a zkSNARK proof, and stores the outcome on-chain. Users of your application can call this either synchronously or asynchronously and then use the verified historical state in your application. In the near future, we are developing a method for smart contracts to use zkAttestor via a trustless off-chain callback system inspired by the [EIP-677 standard](https://github.com/ethereum/EIPs/issues/677). In this system, developers can: 1. Post a request for a zkSNARK proof of a claim by emitting a `ZKAttestorRequest` event. 2. Rely on a permissionless network of provers to generate a zkSNARK proof of the claim. 3. Have an arbitrary callback triggered on-chain by any prover after the zkSNARK is trustlessly verified in the `ZKAttestor` smart contract. This system will be similar to the way existing smart contracts integrate with oracles like Chainlink, but will be completely permissionless and trustless. Because zkSNARKs can be verified on-chain, we can allow anyone in the world to submit a SNARK and trigger the callback. This means developers do not need to trust the liveness of any permissioned entity for execution of their smart contract code. Of course, in the initial deployment phase, we will run a proving server to ensure execution -- but you don't have to trust us! ## How does it work? Each Ethereum block header contains commitments to the full Ethereum state as well as transactions and receipts in that block. Using these commitments, Ethereum **light client proofs** enable a recipient to trustlessly validate any information about an Ethereum state or transaction against the block hash. These consist of proofs of Merkle-Patricia trie inclusion, which can be large and costly to post directly on-chain. Furthermore, the EVM only provides access to the 256 most recent block hashes, meaning older block hashes must be cached to allow for trustless verification. ![](https://hackmd.io/_uploads/rySPNmDpq.jpg) zkAttestor solves these issues by operating a smart contract which periodically caches trustlessly verified block hashes from the EVM on-chain. We then generate zkSNARKs to trustlessly prove light client proofs for on-chain data are correct. zkAttestor then verifies these zkSNARK proofs on-chain and checks that they are consistent with the cached set of block hashes. If these checks pass, the resulting claims about Ethereum history are valid. ## What's next? As we move towards productionizing the current testnet version of zkAttestor, we are looking for early integration partners to use zkAttestor. We are actively iterating on the smart contract interface and the sophistication of statements we can prove, and would like your feedback on what can make zkAttestor most useful for your application. If you would like to learn more: * Try our live demo of zkAttestor on Goerli testnet at [zkattestor.xyz](zkattestor.xyz). * You can check out our open-source circuit code at https://github.com/yi-sun/zk-attestor. * Watch our talk at DevConnect 2022 at https://www.youtube.com/watch?v=2-yYtEJdrFY. * Follow us on [Twitter](https://twitter.com/zkattestor) and join our [Telegram](https://t.me/zkattestor). To discuss possible applications, or if your project would like to be an early integration partner, reach out on Twitter at [@zkattestor](https://twitter.com/zkattestor)!

    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