Emiel de Smidt
    • 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
    # Distributed democracy This document contains information on how to use the `Voting` module in the `Kotlin-IPv8` application as created by the Delft Blockchain Lab. Furthermore, design choices that have been made will be elaborated upon, as well as the current drawbacks in terms of security that should be accounted for when using the Voting application. ###### tags: `DAO` `Voting` `Distributed Democracy` `TrustChain` ## Functionality and API ### Propose vote When a vote is started a single central proposer broadcasts a voting block to all members of the community. This broadcast is put into operation by calling the propose_vote(subject) function. This function takes a vote subject as argument and sends a half block to all peers in the community. The call ends with a self-signed block that represent the end of the vote. ``` fun startVote(voteSubject: String) { val peers = getVotingCommunity().getPeers() val voteList = JSONArray(peers.map { it.publicKey.toString() }) // Create a JSON object containing the vote subject val voteJSON = JSONObject() .put("VOTE_SUBJECT", voteSubject) .put("VOTE_LIST", voteList) // Put the JSON string in the transaction's 'message' field. val transaction = mapOf("message" to voteJSON.toString()) // Loop through all peers in the voting community and send a proposal. for (peer in peers) { trustchain.createVoteProposalBlock( peer.publicKey.keyToBin(), transaction, "voting_block" ) } // Update the JSON to include a VOTE_END message. voteJSON.put("VOTE_END", "True") val endTransaction = mapOf("message" to voteJSON.toString()) // Add the VOTE_END transaction to the proposer's chain and self-sign it. trustchain.createVoteProposalBlock( myPeer.publicKey.keyToBin(), endTransaction, "voting_block" ) } ``` ### Vote After a voting block has been received by the participant, it should be possible to cast a vote. As for now, the only options are `YES` and `NO`. Naturally, this implies that the participant either agrees or disagrees with the vote subject. A vote can be casted upon receival of a proposal. A prompt will be displayed, where the user can select either yes or no, or simply refrain by exiting the prompt. Under the hood, the following function is called: ``` fun respondToVote(voteName: String, vote: Boolean, proposalBlock: TrustChainBlock) { // Reply to the vote with YES or NO. val voteReply = if (vote) "YES" else "NO" // Create a JSON object containing the vote subject and the reply. val voteJSON = JSONObject() .put("VOTE_SUBJECT", voteName) .put("VOTE_REPLY", voteReply) // Put the JSON string in the transaction's 'message' field. val transaction = mapOf("message" to voteJSON.toString()) trustchain.createAgreementBlock(proposalBlock, transaction) } ``` ### Count votes Counting votes is done as follows: The proposer's chain is traversed and for each block that concerns the current vote, it's transaction is checked for adhering to the correct formatting and if so, the vote reply is extracted and tallied. A Pair of (#yesVotes, #noVotes) is retured as a result. ``` fun countVotes(voteName: String, proposerKey: ByteArray): Pair<Int, Int> { var yesCount = 0 var noCount = 0 // Crawl the chain of the proposer. for (it in trustchain.getChainByUser(proposerKey)) { // Skip all blocks which are not voting blocks // and don't have a 'message' field in their transaction. if (it.type != "voting_block" || !it.transaction.containsKey("message")) { continue } // Parse the 'message' field as JSON. val voteJSON = try { JSONObject(it.transaction["message"].toString()) } catch (e: JSONException) { // Assume a malicious vote if it claims to be a vote but does not contain // proper JSON. handleInvalidVote("Block was a voting block but did not contain " + "proper JSON in its message field: ${it.transaction["message"].toString()}." ) continue } // Assume a malicious vote if it does not have a VOTE_SUBJECT. if (!voteJSON.has("VOTE_SUBJECT")) { handleInvalidVote("Block type was a voting block but did not have a VOTE_SUBJECT.") continue } // A block with another VOTE_SUBJECT belongs to another vote. if (voteJSON.get("VOTE_SUBJECT") != voteName) { // Block belongs to another vote. continue } // A block with the same subject but no reply is the original vote proposal. if (!voteJSON.has("VOTE_REPLY")) { // Block is the initial vote proposal because it does not have a VOTE_REPLY field. continue } // Add the votes, or assume a malicious vote if it is not YES or NO. when (voteJSON.get("VOTE_REPLY")) { "YES" -> yesCount++ "NO" -> noCount++ else -> handleInvalidVote("Vote was not 'YES' or 'NO' but: '${voteJSON.get("VOTE_REPLY")}'.") } } return Pair(yesCount, noCount) } ``` ### Potential solution: quorum An interesting alternative solution is the use of a quorum. A quorum functions as a subset of al the eligible voter set, which is allowed to make decisions on behalf of the entire group. More intuitively, once a predefined amount of eligible voters agree on a vote (i.e. a threshold of voters has been achieved), the vote subject can be considered to be accepted by the community. When using a quorum, the is no such thing as a `NO` vote. It is either agreeing with the proposal, or refraining from agreeing. Perhaps the biggest benefit of doing so is that it eliminates the question of when the election can be concluded. The only requirement for a proposal vote to be accepted is the amount of people agreeing with it exceeds the threshold. Furthermore, a vote proposal can not be initiated or cut off at moments that suit the proposer best (e.g. when there are still uncast votes, but the current majority agrees with the proposer) This threshold (or minimal quorum size) should be set by the founder of the community, and those who like to join the community do so knowing that this value is set. Under no circumstances should this value be changed. ## Open questions and future work At the time of writing, the following questions should be further investigated to improve the security of the voting implementation. ### When to end an election? `YES/NO` A major issue is the open question of ### Whom to include in an election? ### Veto powers ### Becoming aware of vote after being offline Currently, a participant that is offline does not receive a vote proposition (as he is not an active peer at the moment). Unfortunately, when the participant does come online there is no resync performed. This is something that we hope to implement in the coming sprints. `EDIT 24-03-2020`: This issue is out of the scope of the project. ## Security flaws In this section we will give an explanation of current security threats that we are aware of, and the risk that said threats pose. ### Double voting attack When receiving a voting block, a participant of the vote is able to respond with multiple aggreement blocks which are then counted as seperate votes. This means that everybody (including the proposer himself) could corrupt the vote. `EDIT 24-03-2020 13:30`: This issue has been resolved in the back-end. The front end allows for multiple votes from a single participant, however while crawling the chain, only the last vote of a participant will be counted. ### Block hiding attack When a participant hides his agreement block, his vote becomes invisible. This way a participant could change the outcome of the vote when he learns about the current state. For the same reason could a proposer hide all the voting blocks on its chain if the outcome were to be out of its favour. Block hiding attacks can however always be detected when crawling a chain. ### Stalling attack If the voting process would end only after everybody has cast their vote, a participant could decide to stall the vote by not voting, if the results are going in the wrong direction from the perspective of this participant. Through the use of a quorum and cut-off date, which is set by the DAO, the voting process can not be stalled. ## Literature ### Design of Distributed Voting Systems [[link]](https://arxiv.org/pdf/1702.02566.pdf) This paper lists constraints that are discussed in most literature concerning distributed voting namely, authentication, verification and fairness. The blockchain approach is mostly about problems within consensus protocols, which don't exist in TrustChain. ### Blockchain-based E-Voting System [[link]](https://ieeexplore.ieee.org/abstract/document/8457919) This paper presents a list of design considerations, we have added our thoughts about them below each consideration: * (i) An election system should not enable coerced voting. * Out of scope * (ii) An election system should allow a method of secure authentication via an identity verification service. * Done via Trustchain * (iii) An election system should not allow traceability from votes to respective voters. * This is unavoidable because traceability is necessary for verification of the voting outcome. * (iv) An election system should provide transparency, in the form of a verifyable assurance to each voter that their vote was counted, correctly, and without risking the voter’s privacy. * Everyone is able to count the votes that have been cast * (v) An election system should prevent any third party from tampering with any vote. * Tampering is detectable by Trustchain principles * (vi) An election system should not afford any single entity control over tallying votes and determining the result of an election. * Single central proposer is used, in accordance with current project goals (see [GitHub ticket](https://github.com/Tribler/tribler/issues/5145#issuecomment-597561146)) * (vii) An election system should only allow eligible individuals to vote in an election * Only members of the DAO can cast their vote.

    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