Igor Gulamov
    • 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
    # Plasma Cashflow data model ### Merkle trees and proofs ### General data types We use this types as strucures or RLP structures and compute hash of them as is (without merkelization or something like this). #### TXInput Here is input to a transaction. You may consider it as pointer to any output in the blockchain. Note: amount may be lesser than the output. It is valid, if one output has many inputs with different parts of the segment. ```solidity struct TXInput { bool isNull, uint256 owner, uint64 blockIndex, uint32 txIndex, uint256 txContentHash, uint8 outputIndex, Segment amount } ``` #### TXOutput You may consider it as owned segment. ```solidity struct TXOutput { bool IsNull, uint256 owner, Segment amount } ``` #### Segment Segment with begin and end. ```solidity struct Segment { uint128 begin, uint128 end } ``` #### Signature ```solidity struct Signature { bool isNull, uint8 v, uint256 r, uint256 s } ``` ### Complex data types #### Transaction Transaction may be passed into functions as following object: ``` solidity struct Transaction { Input[2] inputs, Output[2] outputs, uint64 maxBlockIndex, Signature[2] signatures } ``` Some of inputs, outputs or signatures may be NULL. ##### Transaction hash computation Arguments are limited by 2736030358979909402780800718157159386076813972158567259200215660948447373041 (it is about 250 bits). This is dot order for baby jubjub curve. We linearize TransactionContent and compute the hash. It is enough to store only TransactionContentHashes at leaves of SumMerkleTree, because signatures are cryptographically bounded to inputs of the transactions. If the operator do not provide signatures, blocks are considered to be withheld. ### Plasma state #### Plasma chain ```solidity hashmap(uint64 => uint256) sumMerkleRoot; ``` All blocks are transactional. For deposits and withdrawals we are going to use `txFix` data s #### Exit state ```solidity hashmap(uint256 => bool) exitStateHashmap; ``` The list of unchallanged and not finalized exits #### Deposit state ```solidity OrderedLinkedList deposit; ``` Here is list of deposited segments. ### General methods ```solidity function deposit(OrderedLinkedListItem depositSlot) external payable returns(bool); ``` Transaction may be banned and transaction may be increased priority for txContentHash ### Priority increasing game #### PriorityState ``` Solidity struct PriorityState { TransactionContent txContent, //unsigned transaction uint256 txContentHash, Signature s, // at least one signature uint256 timestamp } //storage mapping (uint256 => bool) priorityChallenges // mapping keccak256(priorityState) => bool of all active priority challenges mapping (uint256 => uint64) txFix // priority fix for transacion. 2^64-1 for banned transactions, zero is default value ``` ```Solidity function priorityBegin( TransactionContent txContent, uint256txContentHash, Signature s ) struct priorityChallengeHash( PriorityState state, Groth16Proof snarkProof // proof that hash is invalid ) // spend of one input of state.txContent // txContentHash, txBlockIndex is information abot spending tx struct priorityChallengeSpend( PriorityState state, uint256[3] txContentHash, //ContentHash of 2 inputs and spending tx uint64[3] txBlockIndex, // BlockIndex of 2 inputs and spending tx Groth16Proof snarkProof // proof of inclusion tx into , spending part of state.point ) external returns (bool); // accept signature differs from state.s function prioritySignatureCollect( PriorityState state, Signature s ) ``` ### Exit game #### ExitState Here is exit state. `TXInput` is not an input of any included transaction. You may consider it as pointer to any output or input of withdrawal transaction. Hashing algorithm is standard (keccak256 of blob). It is enough ``` struct ExitState { TXInput point, uint256 timestamp } ``` ```Solidity function withdrawalBegin( Input point ) external payable returns (bool); function withdrawalChallangeSpend( ExitState state, uint256[3] txContentHash, uint64[3] txBlockIndex, Groth16Proof snarkProof // proof of inclusion tx into , spending part of state.point ) external returns (bool); function withdrawalChallangeExistance( ExitState state, Groth16Proof snarkProof // proof of exclusion state.point from state.point.blockIndex ) external returns (bool); function withdrawalChallangeHash( ExitState state, Groth16Proof snarkProof // proof that txContextHash is wrong ) external returns (bool); function withdrawalChallangeConcurrent( ) returns (bool); // finalize. If transaction is banned by txContentHash, reject exit procedure function withdrawalEnd(ExitState state) ``` ## SNARKs ### zkSNARK proof ```solidity struct Groth16Proof { uint256 A; uint256[2] B; uint256 C; } ``` We can pack G1 point into one uint256 to make the commitment shorter. We do not need to calculate the snarks immidiately, we can use something like truebit instead.

    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