# MEGA-EPIC: Elections
###### tags: `evoting`
:::info
**TODO: Revisar referencias. Hasta que no cerremos todas las historias igual no publicar esta parte que habría que repasarlo bien**
For the steps of the Election we follow the ones in [ElectionGuard documentation](https://microsoft.github.io/electionguard-python/):
1. Configure Election
2. Key Ceremony
3. Encrypt Ballots
4. Cast and Spoil
5. Decrypt Tally
6. Publish and Verify
### 1. Configure Election
- [ ] As a Decidim implementer, I want to configure Decidim with the Bulletin Board (S-PGME.XX)
- [ ] As a Bulletin Board implementer, I want to configure the Bulletin Board with Decidim (S-PGME.XX)
TODO: configure election in Decidim
- [ ] As the Participatory Space Administrator, I want to set up a new Election on the Bulletin Board (S-PGME.XX)
- [ ] As the Participatory Space Administrator, I want that the Election be blocked when synced with the Bulletin Board (S-PGME.XX)
- [ ] As a visitor, I want to have access to the Election Log (S-PGME.XX)
- [ ] As a participatory space administrator, I want to have an Election Admin Status Dashboard (S-PGME.XX)
### 2. Key Ceremony
- [ ] As the Bulletin Board, I want to open (activate) an election (S-PGME.02)
- [ ] As a Trustee, I want to be able to create Elections keys for an Election (S-PGME.XX) #6363
### 3. Encrypt Ballots
- [ ] As a participant, I want to be able to emit the encrypted vote in Decidim (S-PGME.XX)
- [ ] As the Bulletin Board, I want to be able to receive the encrypted vote (S-PGME.XX)
- [ ] As the Bulletin Board, I want to close (deactivate) an election (S-PGME.04)
### 4. Cast and Spoil
- [ ] As a participant, I want to be able to Audit my unsent ballot (S-US.13)
### 5. Decrypt Tally
- [ ] As the Trustee, I want to participate in the tally process (S-T.02)
- [ ] As the Bulletin Board, I want to start the tally process (S-BB.06)
### 6. Publish and Verify
- [ ] As the Bulletin Board, I want to sent the tally results to Decidim (S-BB.07)
- [ ] As the Space Administrator, I want to publish the results (S-PGME.06)
- [ ] As a visitor, I want to verify the election (ref: S-US.XX) #6521
---
:::
---
# EPIC: Elections [Administrator]
https://github.com/decidim/decidim/issues/5958
---
## Configure Decidim with the Bulletin Board
ref: S-PGME.XX
https://github.com/decidim/decidim/issues/6286
---
## Set up a new election
Ref: S-AP.02
https://github.com/decidim/decidim/issues/5959
---
## Create new questions and answers for an election
Ref: S-AP.01
https://github.com/decidim/decidim/issues/5960
---
## Import from proposals to answers on a election
Ref: S-AP.01
https://github.com/decidim/decidim/issues/5961
---
## Define which authorization strategy to use in a Question
ref: S-AP.03
https://github.com/decidim/decidim/issues/5963
---
## Publish and unpublish an election
ref: S-AP.02
https://github.com/decidim/decidim/issues/6075
---
## Define Trustees for all the Election components in the participatory space
https://github.com/decidim/decidim/issues/6359
---
## Create election on the Bulletin Board
https://github.com/decidim/decidim/issues/6361
---
## Block the Election configuration after sending it to Bulletin Board
ref: S-AP.07
https://github.com/decidim/decidim/issues/6621
---
## View statistics of an election on admin panel
https://github.com/decidim/decidim/issues/6014
ref: S-AP.06
---
## Tally the elections votes
ref: S-AP.08
https://github.com/decidim/decidim/issues/6622
---
## Publish the election results
ref: S-AP.09
https://github.com/decidim/decidim/issues/6623
---
## Admin Election Status Dashboard
ref: S-AP.10
https://github.com/decidim/decidim/issues/6624
---
## Selected answers on elections
ref: S-AP.11
https://github.com/decidim/decidim/issues/7408
---
# EPIC: Elections [Participant]
https://github.com/decidim/decidim/issues/5971
---
## Identify and verify myself
ref: S-US.01
https://github.com/decidim/decidim/issues/5972
---
## Submit a vote
ref: S-US.02
https://github.com/decidim/decidim/issues/5973
---
## Modify my vote
ref: S-US.03
https://github.com/decidim/decidim/issues/5974
---
## Verify my vote
ref: S-US.04
https://github.com/decidim/decidim/issues/5975
---
## Receive my Tracking ID by email
ref: S-US.05
https://github.com/decidim/decidim/issues/5976
---
## Send an opinion of the process
ref: S-US.07
https://github.com/decidim/decidim/issues/5978
---
## See all the elections
ref: S-US.08 (NEW)
https://github.com/decidim/decidim/issues/6266
----
## Exit message on quiting the Election voting process
ref: S-US.09
https://github.com/decidim/decidim/issues/6347
---
## "None of the above" option on Election voting process
ref: S-US.10 (NEW)
https://github.com/decidim/decidim/issues/6348
---
## Refine metadata from Elections
ref: S-US.11 (NEW)
https://github.com/decidim/decidim/issues/6349
---
## Emit the encrypted vote in Decidim
ref: S-US.12
https://github.com/decidim/decidim/issues/6625
----
## Audit my unsent ballot
ref: S-US.13
https://github.com/decidim/decidim/issues/6626
----
# EPIC: Elections [Visitor]
https://github.com/decidim/decidim/issues/5966
---
## View results of an election
ref: S-V.01
https://github.com/decidim/decidim/issues/5967
---
## Download elections results on an open format
ref: S-V.02
https://github.com/decidim/decidim/issues/5968
---
## View the election information
ref: S-V.05
https://github.com/decidim/decidim/issues/6531
---
## Verify the election
ref: S-V.06
https://github.com/decidim/decidim/issues/6521
----
## Access to the Election Log
ref: S-V.07
https://github.com/decidim/decidim/issues/6627
---
# EPIC: Elections [Trustee]
---
## Manage identification keys as Trustee
ref: S-T.01
https://github.com/decidim/decidim/issues/6360
---
## Participate in the Key Ceremony as Trustee
ref: S-T.02
https://github.com/decidim/decidim/issues/6628
---
## Participate in the Tally process as Trustee
ref: S-T.03
https://github.com/decidim/decidim/issues/6630
---
# EPIC: Elections [Bulletin Board]
https://github.com/decidim/decidim/issues/5979
---
## Configure the Bulletin Board with Decidim
~~ref: S-PGME.XX~~
ref: S-BB.01
https://github.com/decidim/decidim/issues/6288
---
## Set up a new Election on the Bulletin Board
~~ref: S-PGME.XX~~
ref: S-BB.02
https://github.com/decidim/decidim/issues/6362
----
## Activate the vote reception in Bulletin Board
ref: S-BB.03
https://github.com/decidim/decidim/issues/6632
----
## Receive the encrypted vote in the Bulletin Board
ref: S-BB.04
https://github.com/decidim/decidim/issues/6633
---
## Close the Bulletin Board
ref: S-BB.05
https://github.com/decidim/decidim/issues/6634
---
## Start the tally process
ref: S-BB.06
https://github.com/decidim/decidim/issues/6635
---
## Send the tally results
ref: S-BB.07
https://github.com/decidim/decidim/issues/6636
---
# Descartados / duplicados / depreciado
:::spoiler
### Manage permissions of Election Officials
ref: S-AP.05
As an administrator I want to give permissions to the Election Officials ~~and to the administrators of the participation space~~ so they can manage their encription keys.
>>> No entiendo por qué mencionamos el rol del admin de un espacio, si ya existe, y si además no va a tener acceso al cifrado de las llaves. Creo que en este issue deberíamos definir aspectos como el que hemos comentado hoy, que los election officials solo tienen acceso al componente de votación, no?
>> estoy de acuerdo, es liarla, lo quitamos, ok?
> una cosa es la gestion de estos permisos (que deberian estar) - pero no en esta fase del desarrollo sino la siguiente. he modificado las historias del final para reflajr esto. con esto ultimo ya podriamos quitar esta completamente (no aporta nada)

#### Acceptance criteria
- [ ] As an administrator I can manage the new role: "Election Official"
- [ ] As a participation space administrator I can manage the new role "Election Official"
Related with V-AP.07 and V-AP.08
---
### View the candidates and number of votes each one has
ref: S-V.04
As a visitor I want to view the candidates and the number of votes that each one of them has received.
#### Acceptance criteria
- [ ] As a visitor I can view the candidates and the number of votes that each one has when the election has finished
> Duplicada de la S-V.01
----
### Assign users to Trustee role
ref: S-PGME.XX
---
### Manage keys as Trustee
ref: S-PGME.XX
---
### Set-up Election on Decidim
ref: S-PGME.XX
---
### Set-up an Election on the Bulletin Board
ref: S-PGME.XX
----
### Create Elections keys for an Election
ref: S-PGME.XX
### Roles
The actors defined for a secure election are:
| Name | Description |
| -------- | -------- |
| [Administrator](#EPIC-Elections-Administrator) | The person that has to manage the platform, not from a technical point of view (sysadmin, programmer) but at the configuration of the platform |
| [Participant](#EPIC-Elections-Participant) | Registered user that has been given the right to participate on the process.|
| [Visitor](#EPIC-Elections-Visitor) | Any person that enters the platform. She'll be able to visualise published contents, but can not emit any support or opinion. |
> :information_source: **Information** -
> Notifications are missing in general. We should think about which ones are needed and when.
> :information_source: **Information** -
> For configuring this and as a building block for other developments on this contract we're going to need at least two new modules:
> * decidim-elections: the component for configuring these kind of elections.
> * decidim-bulletin_board: the module and the "glue" with external APIs to save the votes itselves.
> 📋 [Arquitectura Vot electrònic per a Decidim Barcelona](https://docs.google.com/document/d/1LwWmZeSqPvNmsJYhzV7tUADPs3hV11zRrNcgiosxUaI/edit#heading=h.s2ijlysm026x)
### Generate the keys in the browser
ref: S-PGME.01
As a Trustee I want to have the option for generating the keys. I'll have a private key that lives only on the browser, and as such is really important that I have also an option for Download the keys (for making a backup; what happens if my browser or my computer gets broken?); I'll also have the option for Uploading the keys (for restoring the backup).
As we're working only on the Election module, for the moment we will not have multi keys, only a single key.
These keys are going to be used for encripting the votes and working with the criptography of the bulletin board.

> las keys de un mismo Trustee serian las mismas para todas las elecciones?
haria falta uqe las acciones de download/upload generasen output en el log?
hace falta pensar las implicaciones de la revocación de las llaves
hace falta mockups de los distintos momentos? es decir:
1) generate keys + elections
2) download keys + upload keys + revoke keys
#### Acceptance criteria
- [ ] As a trustee I can generate the keys in the browser
- [ ] As a visitor I can see the output for this task on the Election Log
- [ ] As a trustee I can download my keys
- [ ] As a trustee I can upload my keys
- [ ] As a trustee after I have generated the keys I can not generate a new ones until I revoke my old ones
- [ ] As a trustee I can revoke my keys, but I get multiple alerts and if there's a current election with my keys I can't
---
--
### Check my token at a bulletin board
ref: S-US.06
As a participant I can check my token at a bulletin board.
The bulletin board should be updated with sorted public tokens on a batch (like every 15 minutes or every 100 votes) to disallow order or timing kind attacks.
#### Acceptance criteria
- [ ] As a participant I can check my token in a bulletin board, published and updated every certain period of time
---
### View a friendly version of the ballot tracking code
ref: S-US.05
As a participant I want to be able to get a ballot of my vote. As this is a really long hash, it'd be nice to have it on other formats. This is like a short URL but for ballot.
* Short version: an abbreviated way to having for instance the first 10 characters of this string (for instance, the diference between `git rev-parse HEAD` and `git rev-parse --short HEAD `). If there's a short version, then we could also do:
* SMS: the participant can add their mobile phone number and she'll receive an SMS message. It'd be nice to also have an URL with the full process explanation but that'd probably be larger that SMS text limits (at most 160 characters). Also this need to be implemented through the SMS provider that the Decidim installation already has, if there's any. If there isn't a provider configured then it shouldn't be an option. Finally we should also throttle this as this could potentially be abused with economic costs.
* QR code: a barcode with the URL and the Short version for checking this token (see "Check my token at a bulletin board"). This should be a short URL for making it easy to check (as if the QR code has too many characters then it'd be too difficult to scan). See [Wikipedia article for QR code](https://en.wikipedia.org/wiki/QR_code).
* Send to email button: have a receipt of my vote on email with the instructions on how to check it.
#### Notes
* Short version would depend on the criptographic system that we finally use, so it'd be necessary to first know it better. It could also be a security issue.
* QR it's a pain at the UX level
As an example, this is how AgoraVoting shows their token:

#### Acceptance criteria
- [ ] As a participant I can obtain a token on long version format
- [ ] As a participant I can obtain a token on short version format
- [ ] As a participant I can put my mobile phone number to receive an SMS message with the token. The message is something like "The token to verify your voting on [Decidim Barcelona] for the election XXXX is 0123456789."
- [ ] As a participatory space administrator I can see a warning on admin if the SMS message is too large (at most 160 characters)
- [ ] As a participant I can't see the option for the SMS message if there isn't any provider configured.
- [ ] As a participant I can obtain a token on QR format. The URL that's scanned is not too large (at most 150 characters).
---
### See the elections on the Bulletin Board
ref: S-PGME.08
As a Trustee on the Bulletin Board I need a way for seeing all the Elections I've been asigned on, with also the election status, like if it's created but without votes, receiving votes, tallying or finished with published results.

> el set up de las elections se haria manual o automaticamente? (por la API de decidim?)
#### Acceptance criteria
- [ ] As a Trustee I can see if