HackMD
    • 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
    special thanks to YOUR NAME HERE for WHAT YOU DID HERE :D # SNasma ## Abstract We define a SNARK implementation of Plasma where different users can select the security of their accounts. It is possible for a user to ensure that no one will ever be able to withdraw their leaf unless they allow it. ## Introduction: Plasma currently works by allowing a centralized operator to create state transitions. If they create an invalid state transition anyone can challenge them and revert it. However, if the operator refuses to publish information about the new state, users are unable to know if the state transition was valid or not. This is solved by requiring that all users exit their funds once data unavailability is detected (also known as "mass exits"). This results in timeouts for deposits and withdrawals and limits the number of unspent outputs that can safely exist inside the system. SNARKs can be used to disallow invalid state transitions. In this document we describe one such system called SNasma. ## State transitions: We start with a UTXO model. Each output is hashed with the owner's public key and that is a leaf in the Merkle tree. ``` LEAF +----------------^----------------+ LHS Unspent Output +----------------+ Public_key_x Public_key_y ``` Each leaf is stored in the same Merkle tree: ``` Merkle Root +----------------^----------------+ Node1 Node2 +----------------+ +----------------+ Leaf1 Leaf2 Leaf1 Leaf2 ``` If a user wants to transfer ownership of a UTXO they provide a signature to the operator. We define Snark 1 `batch_transfer` which aggregates signatures and updates the merkle root accordingly. The EVM then verifies the SNARK and updates the merkle root if that SNARK constitutes a valid state transition. The operator handles state transitions by batching together multiple transactions into a chain ``` State1 -> State2 -> State3 -> State4 -> State5 -> State6 -> State7 -> State8 -> State8 ``` Where each state transition has multiple transactions which updates multiple leaves. The above construction prevents invalid state transitions. This significantly lowers the attacks the operator can make since they are now unable to steal funds from the users of the SNasma chain. They can however make data unavailable and deprive users of their funds permanently. ## Data availability guarantees To over come this we tried a bunch of EVM based data availability guarantees which ultimately limited our scaling ability with costs of ~5000 gas per transaction (not including SNARK verification). That is better than current in EVM batched transactions but we want to do better. Plasma does not provide any data availability guarantees, however it introduces an exit game which allows users to exit from the latest known valid state. In order to prevent invalid exit requests, there is a dispute period during which other users can challenge invalid exit requests. If there is data availability, users should still be able to exit. Due to the usage of the above SNARKs, there is no way to have an invalid state transition, which gives us the following advantages over plasma: 1. Only the people who used to own your leaf can try withdraw it. A malicious operator cannot try to exit your leaf unless she already owned it. And even then you can stop her by proving that you own it now. In order to improve these guarantees we define `SNARK_prevent_withdraws_before_block` that disallows withdrawal of leaves before state `X`. We have a SNARK to validates multiple signatures and confirms they owned the leaf at the state they selected. Then we create an EVM mapping between the leaves and the `min_withdraw_block` of the leaf defined by the aggregate signature. We have to save this in the EVM which is kind of expensive but we need to be able to check this at withdraw time. ### Note: We can probably do better than just locking the tx on the "unavailable chain" I think we can actually do an exit to another provider from a point when data is still available. I will add more on this tomororw. ## EVM withdraw 1. User requests withdraw from old state Y. They prove that they own a given leaf and try to exit with it. 2. Check that the `min_withdraw_block` for that leaf is less than Y. 3. They wait a timeout period X which others can use to contest it. 4. During the timeout anyone can come forward with a newer state than Y where the leaf is different and prevent the withdrawal. 5. After the timeout has elapsed a user can withdraw their leaf but the EVM notes its address in the tree and prevents any other withdrawals. This way a user can disallow withdraws of their leaf before they received it. Taking complete ownership of it. This way there is no way anyone can take this output unless the user allows them to. At this stage the users funds are not at risk and we can wait for the opportune moment to exit. ## Transactions in SNARK after withdraw After withdrawing via the EVM method the leaf is still a valid in the SNARK's leaf. However no one should be able to withdraw from it as the EVM knows that that leaf has already been withdrawn. It's important users do not accept payment from leaves that have been withdrawn. In the future it may be required to pour transactions to change the number of inputs and outputs. This is probably possible using this method but you need to update the ownership of multiple leaves.

    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