Status of the document: work in progress
Cryptography and distributed p2p systems have given rise to a new, revolutionary digital technology which might change the way society organizes: blockchain. Among many other applications, it can allow for secure, transparent, distributed and resilient decision making.
In this document, we propose the system architecture of a decentralized anonymous voting platform.
We want to bring decentralized voting to mass adoption. This requires a solution that has a user experience at least on par with current, centralized solutions.
We achieve this by externalizing the heavy lifting to a relay
network - thereby allowing for lightweight end-user clients. This fundamental architectural choice has the following implications:
- Minimizes transactions to the blockchain. Can potentially be used in the Ethereum Mainnet
Voter
does not write, only reads from the blockchainVoter
can participate with an light-client (static web/app)- Secure vote anonymization using zk-SNARK
- Data availability via distributed filesystems (IPFS)
- Economically incentivized,
relay
network performs actions not possible by light-clients - The whole
process
is verifiable by any external observer
The system is agnostic to the identity scheme used.
We are developing our implementation using Iden3, which promises an ideal balance of decentralization and scalability.
Other identity schemes could eventually be integrated.
The following concepts are referenced extensively throughout the document
Voter
- A
voter
is the end user that will vote - Its digital representation is called an
identity
- Inside the voting
process
, andidentity
is specified by apublic key
- Can manage all interactions through a
light-client
(web/app)
Organizer
- The entity that creates and manages a specific voting
process
- Needs to interact with the blockchain
- Needs to add and retrieve data to IPFS
- Pays for the costs of a
process
- Has the highest interest for the
process
to succeed - Knows the census beforehand (list of
voters
that are authorized to participate in a specificprocess
)
Relay
- Is used as a proxy between the
voter
and the blockchain - Is a selfish actor. Good behaviour is ensured through economic incentives
- It may have to be split into several
relay
types - Performs functions that would not be possible on a
light-client
- Relays
vote packages
to otherrelays
- Aggregates
vote packages
and adds them into the blockchain - Validates
franchise proofs
- Validates anti-spam proof-of-work nonce
- Ensures data availability on IPFS
- Is responsible for the data availability of the
vote packages
it has added (will lose stake if those are not available) - Exposes an IPFS proxy for the
light-clients
- Provides
census
Merkle-proofs tovoter
- Exposes an RPC end-point to the blockchain for the
light-client
- It should run a full Ethereum node
- Relays
Process
- Represents an individual decision-making contest
- Each process is identified by a
ProcessId
ProcessId
- A unique identifier for each process
- Generated by the
Voting smart-contract
when a new process is created
Light-client
- The client which
voters
will use to vote - Could be an app or static website running on a smart-phone
- Provides UI for easy interaction
- Runs some moderate computational loads, such as the
franchise proof
and the relay anti-spam proof-of-work
Census
- A Merkle-tree made of the
public keys
of all thevoters
- The Merkle-root is hosted in the blockchain as a proof of the census
- The tree needs to be publicly available (IPFS, DAT) for everyone to verify it.
- The
zk-SNARK circuit
will use its Merkle-root to validate if avoter
public key
is part of it
Franchise proof
- Leverages zk-SNARK technology
- Used to prove two things without revealing critical data
Voter
is the owner of theprivate key
corresponding to thepublic key
Voter
'spublic key
is included in thecensus
- Generated in the
user
light-client - Is a CPU and memory intensive process
- Is validated by the
relays
before adding thevoting package
in the blockchain - It is validated by the
organizer
once theprocess
ends
zk-SNARK circuit
- Used by the
voter
to generate thefranchise proof
- Used by the
relay
andorganizer
to validate thefranchise proof
- The same circuit can be use for any
process
- It requires a trusted setup to be generated
Voting smart-contract
- The
process metadata
required by aprocess
is published here when a newprocess
is created - The
voter
light client retrieves theprocess metadata
from here - Aggregated
vote package
hashes are added here - It holds the funds used to pay the
relays
- It holds the funds that the
relays
need to stake to ensure their good behaviour - When a
process
is successfully finished it transfers the funds to therelays
Process metadata
- Is the metadata that needs to be public before a
process
starts- Merkle Root of the
census
Merkle tree Vote encryption key
- Available
voting options
Process
start time (block number)Process
end time (block number)
- Merkle Root of the
Vote package
- Is the set of data sent by the
Voter
to therelay
in order to vote- Franchise proof
- Encrypted vote: encrypt(selected
vote options
+ random nonce) Nullifier
: hash(ProcessId
+Voter
private key
)ProcessId
- Anti spam proof of work
Vote encryption key
- Provided by
organizer
- The public key used by the
Voters
to encrypt their vote - Its private key needs to be made public at the end of the process, for everyone to decrypt the votes
- Multiple
vote encryption keys
can be used to ensure that no one has access to the results before theprocess
is finished - Entities providing the
vote encryption key
could be required to put some stake to ensure key publishing
Voting options
- A potential option for the user to choose when they vote
- They are published when a
process
is created - They could be exclusive or not
- Before the process in itself starts
voters
must have their digitalidentity
already created. - The unique requirement for those
identities
is that they need to be represented by apublic key
. - The system is agnostic to the identity system used, but further systems may require additional work to fully integrate.
- Presently assumes that the
organizer
has a list of all thevoters
that can participate - It aggregates all the
public keys
of thevoters
and generates thecensus
Merkle tree from them.
- Via a user interface, it provides the required
process metadata
regarding a voting process. - Sends a transaction to the
voting smart-contract
- It includes the
process metadata
, so is public for the other players - The funds sent in the transaction will be used to pay the
relays
- The amount sent is proportional to the needs of the
process
(number of participants, relay redundancy...)
- It includes the
- In parallel it also publishes the
census
to IPFS, to make it available to everyone else.
- Gets the
process metadata
from thevoting smart-contract
- Gets the
census
Merkle-proof from arelay
- Verifies her
public key
is in the publishedcensus
Merkle tree - Selects the desired
voting options
from theprocess metadata
- Encrypts the selected
voting options
and a random nonce with thevote encryption keys
encrypted_vote = encrypt( selected_voting_options + random_nonce )
- Generates the nullifier
nullifier = hash( process_id + user_private_key )
The franchise proof
is generated by running the zk-SNARK voting cicuit
with several inputs.
- private input: Private Key, census Merkle-proof
- public input: census Merkle-root, Nullifier, ProcessId, Hash(encrypted vote)
- output: Franchise proof
Vote package
is created by aggregating
- Franchise proof
- Encrypted vote
- Nullifier
- ProcessID
Potentially the vote package
can be encrypted with one or more relay
public keys
in order to choose the relay chain and minimize IP mapping
A proof-of-Work nonce (to avoid relay node spamming) must be attached to the packet. If the PoW is not correct, the relay pool will discard the packet.
The vote package
and the nonce are sent to the relay
pool
- The
relay
pool receives thevote package
from theuser
- A
relay
verifies the proof-of-work and thefranchise proof
. If either is invalid, thevote package
is discarded. - Chooses a set of pending
vote packages
and aggregates them into a single bundle of data. - Adds the aggregated data bundle to IPFS
- Uploads the IPFS hash of the bundle to the blockchain
- The owners of the
vote encryption keys
publish the correspondingprivate keys
, so the votes and proofs can be decrypted - The
organizer
gets the hashes of aggregatedvote package
bundles from the blockchain - The
organizer
downloads the aggregatedvote package
bundles from IPFS - The
organizer
iterates over all thevote packages
- It decrypts it with the published private key of the
voting encryption key
- It runs the
franchise proof
through thezk-SNARK circuit
and discards invalid proofs - It discards
vote-packages
with repeatednullifier
(double votes)
- It decrypts it with the published private key of the
- It computes the final results
- The
organizer
signals badrelays
- The
organizer
makes theprocess
closing transaction, uploading the results Relays
are rewarded according to their contribution
- zk-SNARK trusted setup
- IP/vote mapping
- Most of the unresolved details are around creating a fully decentralized relay network. Multiple alternatives exist.
- A centralized trusted
relay
is a very valid option in a certain context