Skip to content
This repository has been archived by the owner on Jul 8, 2021. It is now read-only.
/ elekton-contracts Public archive

Solidity smart contracts to vote anonymously on a free-gas network (Besu) using zk-SNARK.

License

Notifications You must be signed in to change notification settings

cedoor/elekton-contracts

Repository files navigation

elekton-contracts | elekton.js | elekton-dapp

Elekton contracts

Solidity smart contracts to vote anonymously on a free-gas network (Besu) using zk-SNARK.

Linter eslint Code style prettier Repository top language

Elekton is a set of modules useful to create a simple e-voting system that uses non-interactive zero-knowledge proofs and blockchain technologies to allow users to vote anonymously in a verifiable and transparent way. In addition to this repository there is a JavaScript library (elekton.js) with the functions to interact with the Elekton contract and a simple DApp, which in turn uses elekton.js and allows you to create users, ballots and to vote anonymously.


Table of Contents

Technologies

Technology Description
Hyperledger Besu Ethereum client with additional PoA consensus mechanisms, private transactions, permissioning and other features.
zk-SNARK Zero-knowledge technology used to prove possession of certain information without revealing that information and without any interaction between the prover and verifier.
Iden3 A set of useful tools that make it easier to use zk-SNARK on Ethereum blockchains (Circom, SnarkJS, Circomlib).
Merkle trees Data structure used to create the proof-of-membership to allow users to vote on a ballot.
EdDSA Digital signature scheme used to sign data and to create the voter's asymmetric keys.
Poseidon ZK-friendly hash function used in the previous algorithms.

In order to create anonymous transactions it is necessary to use an universal shared Ethereum account to sign them, and in order to have more scalability it is necessary to use a PoA consensus mechanism. For this reason the best solution is to use a permissioned blockchain with a free-gas network. Elekton uses Besu, an Ethereum client written in Java that implements Proof of Work (Ethash) and Proof of Authority (IBFT 2.0 and Clique) consensus mechanisms.

The goal of zero-knowledge proofs is for a verifier to be able to convince herself that a prover possesses knowledge of a secret parameter. In the Elekton system the verifier is a Solidity smart contract, whereas the prover is the voter, who must create a valid off-chain proof in order to send a transaction and vote on an on-chain ballot anonymously. In recent years zk-SNARK has aroused a lot of interest. ZCash uses it to provide a privacy-focused cryptocurrency with a strong mechanism for creating anonymous transactions and many development tools make it easy to use for the integration with other types of blockchains as well. Iden3 provides several tools to use zk-SNARK with Ethereum, and they are just used in the Elekton system. Circom is used to create the voting circuit, whereas SnarkJS is used to generate the proofs and export the verifier as a Solidity smart contract. The circuit requires the use of some ZK-friendly algorithms: Merkle trees, EdDSA and Poseidon. Circom actually requires a special kind of Merkle tree, the sparse Merkle tree (SMT), which can be used to create not only membership proofs, but also non-membership proofs. Elekton uses the SMT TypeScript implementation and the Circomlib JavaScript library, which provides several zk-friendly algorithm implementations.

Features

Feature Status Description
User registration ✔️ Anyone can register himself in the contract as Elekton user.
Ballot creation ✔️ All users can create ballots.
Anonymous vote ✔️ The authorized users can vote on ballots anonymously.

Install

Clone this repository and install the dependencies:

git clone https://github.com/cedoor/elekton-contracts.git
cd elekton-contracts
yarn # or `npm i`

Install the binary distribution of Besu, used to start a development zero-gas network. The besu command line must be executable from the terminal.

Usage

Create the snark artifacts (it takes a few minutes) and start the Besu development network:

yarn snark
yarn start

Test the contract functions and deploy a contract instance:

yarn test
yarn deploy

Now you can interact with the contract using Remix or Web3.js on http://localhost:8545 or ws://localhost:8546.

Contacts

Developers