Skip to content

Commit 24b2b58

Browse files
committed
Adds architecture and steps documentation
1 parent 373b08b commit 24b2b58

9 files changed

+183
-33
lines changed

README.md

+183-33
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262

6363
**D-Voting** is an e-voting platform based on the
6464
[Dela](https://github.com/dedis/dela) blockchain. It uses state-of-the-art
65-
protocols that guarantee a fully decentralized process. This project was born in
66-
early 2021 and has been iteratively implemented by EPFL student under the
67-
supervision of DEDIS members.
65+
protocols that guarantee privacy of votes and a fully decentralized process.
66+
This project was born in early 2021 and has been iteratively implemented by EPFL
67+
students under the supervision of DEDIS members.
6868

6969
⚠️ This project is still under developpment and should not be used for real
7070
elections.
@@ -77,11 +77,11 @@ Main properties of the system are the following:
7777
</div>
7878

7979
**No single point of failure** The system is supported by a decentralized
80-
network of blockchain nodes, making no single party able to take over the
81-
network without compromising a Byzantine threshold of nodes. Additionally,
80+
network of blockchain nodes, making no single party able to break the system
81+
without compromising a Byzantine threshold of nodes. Additionally,
8282
side-protocols always distribute trust among nodes: The distributed key
8383
generation protocol (DKG) ensures that a threshold of honest node is needed to
84-
decrypt a vote, and the shuffling protocol needs at least one honest node to
84+
decrypt ballots, and the shuffling protocol needs at least one honest node to
8585
ensure privacy of voters. Only the identification and authorization mechanism
8686
make use of a central authority, but can accommodate to other solutions.
8787

@@ -92,9 +92,9 @@ make use of a central authority, but can accommodate to other solutions.
9292

9393
**Privacy** Ballots are cast on the client side using a safely-held distributed
9494
key-pair. The private key cannot not be revealed without coercing a threshold of
95-
nodes, and the public key can be retrieved on any node the voter trusts. Ballots
96-
are decrypted only once a cryptographic process ensured that cast ballots cannot
97-
be linked to the original voter.
95+
nodes, and voters can retrieve the public key on any node. Ballots are decrypted
96+
only once a cryptographic process ensured that cast ballots cannot be linked to
97+
the original voter.
9898

9999
<div align="center">
100100
<img height="50px" src="docs/assets/audit-black.png#gh-light-mode-only">
@@ -109,40 +109,190 @@ and auditors can witness the election process.
109109

110110
## 🧩 Global architecture
111111

112-
Find more about the architecture on the [documentation
113-
website](https://dedis.github.io/d-voting/#/).
112+
The project has 4 main high-level components:
113+
114+
**Blockchain node** A blockchain node is the wide definition of the program that
115+
runs on a host and participate in the election logic. The blockchain node is
116+
built on top of Dela with an additional d-voting smart contract, proxy, and two
117+
services: DKG and verifiable Shuffling. The blockchain node is more accurately a
118+
subsystem, as it wraps many other components. Blockchain nodes communicate
119+
through gRPC with the [minogrpc][minogrpc] network overlay. We sometimes refer
120+
to the blockchain node simply as a "node".
121+
122+
**Proxy** A proxy enables external interactions on a blockchain node. It is a
123+
component of the blockchain node that exposes HTTP endpoints for external
124+
entities to send commands to the node. The proxy is notably used by the web
125+
clients to use the election system.
126+
127+
**Web frontend** The web frontend is a web app built with React. It offers a
128+
view for end-users to use the D-Voting system. The app is meant to be used by
129+
voters and admins. Admins can perform administrative tasks such as creating an
130+
election, closing it, or revealing the results. Depending on the task, the web
131+
frontend will directly send HTTP requests to the proxy of a blockchain node, or
132+
to the web-backend.
133+
134+
**Web backend** The web backend handles authentication and authorization. Some
135+
requests that need specific authorization are relayed from the web-frontend to
136+
the web-backend. The web backend checks the requests and signs messages before
137+
relaying them to the blockchain node, which trusts the web-backend. The
138+
web-backend has a local database to store configuration data such as
139+
authorizations. Admins use the web-frontend to perform update.
140+
141+
The following component diagrams summarizes the interaction between those
142+
high-level components.
143+
144+
[minogrpc]: https://github.com/dedis/dela/tree/master/mino/minogrpc
114145

115146
![Global component diagram](http://www.plantuml.com/plantuml/proxy?src=https://raw.githubusercontent.com/dedis/d-voting/main/docs/assets/component-global.puml)
116147

148+
You can find more information about the architecture on the [documentation
149+
website](https://dedis.github.io/d-voting/#/).
150+
151+
## Workflow
152+
153+
An election follows a specific workflow to ensure privacy of votes. You can
154+
find more about it in the
155+
[documentation](https://dedis.github.io/d-voting/#/api?id=signed-requests), but
156+
here is a high-level recap.
157+
158+
Once an election is created and open, there are 4 main steps from the cast of a
159+
ballot to getting the result of the election:
160+
161+
<div align="center">
162+
<img height="55px" src="docs/assets/encrypt-black.png#gh-light-mode-only">
163+
<img height="55px" src="docs/assets/encrypt-white.png#gh-dark-mode-only">
164+
</div>
165+
166+
**1) Create ballot** The voter get the shared public key and encrypts locally
167+
its ballot. The shared public key can be retrieved on any node and is associated
168+
to a private key that is distributed among the nodes. This process is done on
169+
the client's browser using the web-frontend.
170+
171+
<div align="center">
172+
<img height="80px" src="docs/assets/cast-black.png#gh-light-mode-only">
173+
<img height="80px" src="docs/assets/cast-white.png#gh-dark-mode-only">
174+
</div>
175+
176+
**2) Cast ballot** The voter submits its encrypted ballot as a transaction to one
177+
of the blockchain node. This operation is relayed by the web-backend which
178+
verifies that the voters has the right to vote. If successful, the encrypted
179+
ballot is stored on the blockchain. At this stage each encrypted ballot is
180+
recorded with its user on the blockchain.
181+
182+
<div align="center">
183+
<img height="70px" src="docs/assets/shuffle-black.png#gh-light-mode-only">
184+
<img height="70px" src="docs/assets/shuffle-white.png#gh-dark-mode-only">
185+
</div>
186+
187+
**3) Shuffle ballots** Once the election is closed by an admin, ballots are
188+
shuffled to ensure privacy of voters. This operation is done by a threshold of
189+
node that each perform their own shuffling. Each shuffling guaranty the
190+
integrity of votes while re-encrypting and changing the order of votes. At this
191+
stage encrypted ballots cannot ne linked back to their voters.
192+
193+
<div align="center">
194+
<img height="90px" src="docs/assets/reveal-black.png#gh-light-mode-only">
195+
<img height="90px" src="docs/assets/reveal-white.png#gh-dark-mode-only">
196+
</div>
197+
198+
**4) Reveal ballots** Once ballots have been shuffled, they are decrypted and
199+
revealed. This operation is done only if the previous step is correctly
200+
executed. The decryption is done by a threshold of nodes that must each provide
201+
a contribution to achieve the decryption. Once done, the result of the election
202+
is stored on the blockchain.
203+
204+
## Smart contract
205+
206+
A smart contract is a piece of code that runs on a blockchain. It defines a set
207+
of operations that act on a global state (think of it as database) and can be
208+
triggered with transactions. What makes a smart contract special is that its
209+
executions depends on a consensus among blockchain nodes and operations are
210+
successful only if a consensus is reached. Additionally, transactions and their
211+
results are permanently recorded and signed on an append-only ledger, making any
212+
operations on the blockchain transparent and permanent.
213+
214+
In the D-Voting system a single D-Voting smart contract handles the elections.
215+
The smart contract ensures that elections follow a correct workflow to
216+
guarantees its desirable properties such as privacy. For example, the smart
217+
contract won't allow ballots to be decrypted if they haven't been shuffled by a
218+
threshold of nodes before.
219+
220+
## Services
221+
222+
Apart from executing smart contracts, blockchain nodes need additional side
223+
services to support an election. Side services can read from the global state
224+
and send transactions. They are used to perform specific protocol executions not
225+
directly related to blockchain protocols such as the distributed key generation
226+
(DKG) and verifiable shuffling protocols.
227+
228+
### DKG
229+
230+
DKG stands for Distributed Key Generation. This service allows the creation of a
231+
key-pair that is distributed among multiple participants. Data encrypted with
232+
the key-pair can only be decrypted with the contribution of a threshold of
233+
participants. This makes it convenient to distribute trust on encrypted data.
234+
In the D-Voting project we use the Pedersen [[1]] version of DKG.
235+
236+
The DKG service needs to be setup at the beginning of each new election - we
237+
want each election to have its own key-pair. Doing the setup requires two steps:
238+
1\) Initialization and 2\) Setup. The initialization creates a new RPC for nodes
239+
to communicate and must be done on each node. The second step, setup, must be
240+
executed on one of the node. The setup step starts the DKG protocol and
241+
generates the key-pair. Once done, the D-Voting smart contract can be called to
242+
open the election, which will retrieve the DKG public key and save it on the
243+
smart contract.
244+
245+
[1]: https://dl.acm.org/doi/10.5555/1754868.1754929
246+
247+
### Verifiable shuffling
248+
249+
The shuffling service ensures that encrypted votes can not be linked to their
250+
voters. Once the service is setup, each node can perform what we call a
251+
"shuffling step". A shuffling step re-orders an array of elements such that
252+
integrity of the elements is guarantee (i.e no elements have been modified,
253+
added, or removed), but one can't trace how elements have been re-ordered.
254+
255+
In D-Voting we use the Neff [[2]] implementation of verifiable shuffling. Once
256+
an election is closed, an admin can trigger the shuffling steps from the nodes.
257+
During this phase, every node perform a shuffling on the current list of
258+
encrypted ballots and try to submit it to the D-Voting smart contract. The smart
259+
contract will accept only one shuffling step per block, and nodes repeat their
260+
shuffling step with the latest shuffled list until their shuffling step has not
261+
been accepted and a threshold of nodes has not been reached.
262+
263+
[2]: https://dl.acm.org/doi/10.1145/501983.502000
264+
117265
## 📁 Folders structure
118266

119-
```
267+
<pre>
268+
<code>
120269
.
121270
├── cli
122-
│ ├── cosipbftcontroller
123-
│ ├── dvoting
124-
── memcoin
125-
│ └── postinstall
126-
── contracts
127-
│ └── evoting
128-
├── deb-package
129-
├── docs
130-
├── integration
131-
├── internal
271+
│ ├── cosipbftcontroller Custom initialization of the blockchain node
272+
│ ├── <b>memcoin</b> Build the node CLI
273+
── postinstall Custom node CLI setup
274+
├── <b>contracts</b>
275+
│ └── <b>evoting</b> D-Voting smart contract
276+
└── controller CLI commands for the smart contract
277+
├── deb-package Debian package for deployment
278+
├── docs Documentation
279+
├── integration Integration tests
280+
├── internal Internal packages: testing, tooling, tracing
132281
├── metrics
133-
│ └── controller
134-
├── proxy
135-
├── services
282+
│ └── controller CLI commands for Prometheus
283+
├── proxy Defines and implements HTTP handlers for the REST API
284+
├── <b>services</b>
136285
│ ├── dkg
137-
│ │ └── pedersen
286+
│ │ └── <b>pedersen</b> Implementation of the DKG service
138287
│ └── shuffle
139-
│ └── neff
140-
└── web
141-
├── backend
142-
│ └── src
143-
└── frontend
144-
└── src
145-
```
288+
│ └── <b>neff</b> Implementation of the shuffle service
289+
└── <b>web</b>
290+
├── <b>backend</b>
291+
│ └── src Source of the web backend
292+
└── <b>frontend</b>
293+
└── src Sources of the web frontend
294+
</pre>
295+
</code>
146296

147297
## 👩‍💻👨‍💻 Contributors
148298

docs/assets/cast-black.png

4.1 KB
Loading

docs/assets/cast-white.png

4.33 KB
Loading

docs/assets/encrypt-black.png

3.84 KB
Loading

docs/assets/encrypt-white.png

4.14 KB
Loading

docs/assets/reveal-black.png

4.83 KB
Loading

docs/assets/reveal-white.png

5.17 KB
Loading

docs/assets/shuffle-black.png

4.71 KB
Loading

docs/assets/shuffle-white.png

5.17 KB
Loading

0 commit comments

Comments
 (0)