GithubHelp home page GithubHelp logo

shixiangbupt / decentralized-blockchain-voting Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fernandolobato/decentralized-blockchain-voting

0.0 1.0 0.0 1.02 MB

An implementation of a decentralized voting scheme on top of the Ethereum blockchain using linkable ring signatures and threshold keys.

Python 3.86% JavaScript 37.62% CSS 45.62% HTML 12.89%

decentralized-blockchain-voting's Introduction

Decentralized Voting on the Ethereum Blockchain

This repo contains an implementation of a decentralized voting scheme on top of Ethereum in the form of a smart contract. The scheme uses linkable ring signatures and threshold cryptography to ensure voter privacy. For more information on the scheme works please reference the paper available here.

How does it work

The voting scheme is divided into the following phases after being deployed on the blockchain.

  1. SETUP

    Election authority uploads all information about the election. Length of voting and registration periods, threshold key for voters to encypt their votes and the voting options.

  2. REGISTRATION

    At this phase any voter can go with the election authority and request his public key be included into the set of public keys elegible to vote.

  3. VOTING

    At this phase any previously registered voter and submit an encypted vote with the threshold key published in the contract with a ring signature of all the public keys registered in the sub ring.

  4. FINISHED

    Once the voting phase is over all the third parties olding secrets can submit them to the blockchain. When all the secrets are in the contract, anybody can download and reconstruct the private key.

  5. READY TO TALLY

    Anybody can tally the result of the ellection.

This repo contains:

  • Solidity contracts to represent election.
  • Python scripts to compile and deploy.
  • Javascript files for testing.
  • A small web application to run the election scheme.
  • Python program for working with linkable ring signatures.
  • Python program for working with threshold encryption.

How do I run this?

It is important to have geth installed and the solc compiler if you wish to make changes to the contract.

You can run this on the a private network or use testrpc for quick deployment.

It's a lot easier using the testrpc but running your own private networm might give you more insight into Ethereum.

To create your own private network you just need to define a genesis.json file in the directory where you want to run your private blockchain and run:

$ geth --datadir /PATH/TO/FOLDER/ init /PATH/TO/FOLDER/genesis.json

This is an example of a genesis.json file: The account 0x33bfbdc0048f477810434707de9c13031abd47ca will be allocated sum funds.

{
  "config": {
        "chainId": 10,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "alloc"      : {
    "0x33bfbdc0048f477810434707de9c13031abd47ca": {
        "balance": "200000000000000000000"
    }
  },
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x20000",
  "extraData"  : "",
  "gasLimit"   : "0x8000000",
  "nonce"      : "0x0000000000000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}
$ geth --datadir /PATH/TO/FOLDER/ init /PATH/TO/FOLDER/genesis.json

Now you are ready to run your private ethereum network:

$ geth --datadir /PATH/TO/FOLDER/ --nodiscover --rpc --rpcapi="db,eth,net,web3,personal,miner,admin" --rpcport "8545" --rpcaddr "0.0.0.0" --rpccorsdomain "*" --nat "any"

This will set up an ethereum client that takes rpc api connection on port 8545 and can be accessed by other computers on your network.

To access the geth console and begin to play with you blockchain you just need to run:

$ geth attach http://YOUR.IP.ADDRESS.PLEASE:8545

If you wish to compile the contracts just run:

$ ./compile.py

It is a python script that uses solc to compile the contracts and places them in the bin folder.

This repo already contains a lot of scripts to deploy this project easily. Inside the deploy folder there is a deploy.js file, that file has a hardcoded string of where the project resides, change that, add that variable to the geth console and you can include that file into the console for easy deployment.

decentralized-blockchain-voting's People

Contributors

fernandolobato avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.