Skip to content

Commit

Permalink
Develop (#40)
Browse files Browse the repository at this point in the history
* Ag 17 commitlint fix (#1)

* fix(@script): AG-17 changed script logic

changed script login the commit script

* fix(@script): AG-17 changed script

modified some logic in the script folder

* docs(@agora): modified readme

modified readme

* feat(@agora): AG-35 basic workflow (#3)

* feat(@agora): AG-35 basic workflow

basic GitHub Actions workflow implementation

* feat(@agora): AG-35 duplicated code

inserted duplicated code check in ci-cd

* docs(@agora): AG-35 updloaded image (#5)

uploaded image for functional analysis

* Ag 18 eoa implementation (#7)

* feat(@script): AG-18 EOA script implementation

implemented script in order to generate an EOA over different ethereum networks configured

* test(@script): AG-18 unit test configuration

unit test configuration for scripts using jest

* test(@agora): AG-18 configured test step in workflow

configured workflow to run script unit test

* test(@script): AG-18 configured commit script

configured pre-commit hook script to run unit test

* test(@script): AG-18 unit test implementation

implemented unit test for eoa script

* test(@script): AG-18 code coverage

unit test code coverage report implementation

* refactor(@script): AG-18 precommit hook

added check in pre-commit hook

* fix(@script): AG-18 fixed unit test threshold

fixed unit test code coverage threshold

* fix(@agora): AG-18 fixed package.json

fixed package json property not used

* fix(@agora): AG-18 fixed unit test

n

* fix(@agora): AG-18 fixed workflow

fixed workflow

* refactor(@script): AG-18 test code coverage threshold

test code coverage threshold

* docs(@agora): AG-18 updated readme

updated readme file

* Ag 19 DECsRegistry smart contract (#8)

* fix(@script): AG-19 removed comments

removed code comments

* docs(@docs): AG-19 updated sequence diagrams

updated the sequence diagrams images for the functional analysis

* docs(@docs): AG-19 updated smart contract classes

updated docs about the smart contracts classes

* feat(@contracts): AG-19 DEC contract implementation

implemented a first version of the DEC contract

* feat(@contracts): AG-19 added events to DEC sc

emitted event in the DEC smart contract implementation

* feat(@contracts): AG-19 implemented DEC contract

implemented DEC contract and related unit tests

* fix(@contracts): AG-19 removed event

removed event not used in DEC contract

* feat(@contracts): AG-19 DECs registry implementation

implemented the register of the DECs with the required methods

* test(@contracts): AG-19 defined test for DECsRegistry contract

defined test structure for the DECsRegistry smart contract

* test(@contracts): AG-19 implemented unit test

implemented unit tests for DECsRegistry smart contract

* feat(@contracts): AG-19 added events to smart contract

added events to the DECsRegistry smart contract

* Ag 20 election smart contract (#9)

* refactor(@agora): AG-20 switched test network

switched from legacy goerli test network to sepolia

* docs(@docs): AG-20 updated analysis diagrams

updated diagrams in the functional analysis

* feat(@contracts): AG-20 Election smart contract

implemented Election smart contract with unit tests

* feat(@contracts): AG-20 Elections smart contracts

implemeneted different smart contracts for different kind of elections

* docs(@docs): AG-20 addded diagrams files to docs

added diagrams file to the docs folder

* docs(@docs): AG-20 updated class diagrams

updated the smart contracts class diagrams

* Ag 20 election smart contract (#10)

* refactor(@agora): AG-20 switched test network

switched from legacy goerli test network to sepolia

* docs(@docs): AG-20 updated analysis diagrams

updated diagrams in the functional analysis

* feat(@contracts): AG-20 Election smart contract

implemented Election smart contract with unit tests

* feat(@contracts): AG-20 Elections smart contracts

implemeneted different smart contracts for different kind of elections

* docs(@docs): AG-20 addded diagrams files to docs

added diagrams file to the docs folder

* docs(@docs): AG-20 updated class diagrams

updated the smart contracts class diagrams

* fix(@agora): AG-20 updated version number

updated version number in package json

* Ag 25 deploy contracts (#13)

* feat(@agora): AG-25 configured evm compiler

configured the evm compiler in the hardhat configuration file

* refactor(@contracts): AG-25 refactored DECs Registry contract

refactored DECs registry contract

* refactor(@contracts): AG-25 refactored DEC contract

refactored DEC smart contract

* feat(@contracts): AG-25 added name property to DECs Registry

added name property to DECs Registry smart contract

* feat(@contracts): ignition modules implementation

implemented the ignition modules for contracts deploy

* fix(@contracts): AG-25 added folder to gitignore

added foldet to gitignore

* fix(@contracts): AG-25 ignored files

added files to gitignore

* Ag 26 register election script (#14)

* docs(@docs): modified main flow diagram

modified the representation of the entire process in the functional analysis

* docs(@docs): AG-26 typo fix

typo fix in the README file

* feat(@scripts): AG-26 implemented the deploy for the Election smart contract

implemented the ignition module for the deploy of the Election smart contract

* feat(@script): AG-26 municipality election deploy

created the ignition module for the deploy of a municipality election

* feat(@contracts): AG-26 defined methods for municipality election contract

defined properties and methods for the municipality election smart contract

* feat(@contracts): AG-26 election contract modifier implementation

implemented a modifier in the municipality election smart contract

* feat(@contracts): AG-26 municipality election method implementation

implemented the registerParty method in the municipality election smart contract

* refactor(@contracts): AG_26 modified contracts methods

modified the sign of the methods of all the smart contracts

* feat(@contracts): AG-26 municipality election smart contract

implemented the municipality election smart contract

* refactor(@contracts): AG-26 refactored municipality election contract

refactored municipality election smart contract to make it more gas efficient

* feat(@contracts): AG-26 added getter to municipality election contract

added a getter function to the municipality election getter contract

* refactor(@contracts): AG-26 formatted smart contract

formatted smart contract file

* feat(@contracts): AG-26 get coalition in municipality election

implemented a get coalition in the municipality election contract

* refactor(@contracts): AG-26 refactored municipality election contract

refactored municipality election contract

* refactor(@contracts): AG-26 Municipality contract unit test

unit tests implementation for municipality election smart contract

* feat(contracts): AG-26 refactored Municipality Election

modified Municipality Election smart contract deploy

* feat(@contracts): AG-26 Ignition module implementation

ignition module implementation

* style(@contracts): AG-26 contract refactor

refactored formatting of a smart contract

* feat(@contracts): AG-26 MunicipalityElection smart contract deploy script

implementation of the ignition module for the deploy of the MunicipalityElection smart dd contract

* feat(@contracts): AG-26 Create election script definition

defined create-election script that register the data into a given election contract

* feat(@scripts): AG-26 create election script partial implementation

partially implemented the script for the MunicipalityElection smart contract

* feat(@scripts): AG-26 Implemented the create-election script

implemented the create election script

* feat(@script): AG-26 unit test implementation

implemented unit test for create election script

* refactor(@script): improved script

improved script

* Ag 37 actions api layer (#16)

* feat(@ci): AG-37 defined ci module

defined a ci module for the workflows api layer

* feat(@ci): AG-37 ci api integration

integrated ci apis into github actions workflow

* fix(@ci): AG-37 fixed command path

fixed ci command path

* fix(ci): AG-37 fixed ci module logic

fixed ci module logic

* docs(@docs): updated README

updated README

* fix(@ci): AG-36 fixed github username (#19)

fixed git user in workflow

* Ag 39 encrypt dec data (#21)

* docs(@docs): AG-39 updated architectural diagram

updated architectural diagram

* feat(@lib): AG-39 cryptoUtils lib implementation

implemented library that ecrypt and decrypt strings

* feat(@script): AG-39 deploy encrypted DEC implementation

implemented the encryption of DEC data and deploy of smart contract instance

* feat(@script): AG-39 script test

implemented unit test for election scripts

* Ag 40 dec registration (#22)

* feat(@scripts): AG-40 decs registry deploy script

defined the script for the deploy of the DECs Registry

* feat(scripts): AG-40 decs registry deploy script

implemented the script for the deploy of the DECs Registry

* test(scripts): unit test implementation

implemented unit test for the DECsRegistry deploy script

* feat(scripts): AG-40 DEC registration

defined the script for the registration of a DEC into the Registry

* feat(scripts): AG-40 register dec script

implemented register dec script

* feat(@script): AG-40 register dec

refactored the register dec script implementation

* feat(@script): AG-40 process review

review and fixes of the entire process with scripts

* docs(@docs ): AG-40 updated readme

updated readme

* refactor(@docs): AG-40 updated app version

updated version

* fix(@cicd): AG-42 fix github actions (#24)

fixed tag creation in workflow

* fix(CICD): AG-42 workflow fixes (#26)

workflow fixes

* Ag 42 fixes 2 (#28)

* Develop (#27)

* Ag 17 commitlint fix (#1)

* fix(@script): AG-17 changed script logic

changed script login the commit script

* fix(@script): AG-17 changed script

modified some logic in the script folder

* docs(@agora): modified readme

modified readme

* feat(@agora): AG-35 basic workflow (#3)

* feat(@agora): AG-35 basic workflow

basic GitHub Actions workflow implementation

* feat(@agora): AG-35 duplicated code

inserted duplicated code check in ci-cd

* docs(@agora): AG-35 updloaded image (#5)

uploaded image for functional analysis

* Ag 18 eoa implementation (#7)

* feat(@script): AG-18 EOA script implementation

implemented script in order to generate an EOA over different ethereum networks configured

* test(@script): AG-18 unit test configuration

unit test configuration for scripts using jest

* test(@agora): AG-18 configured test step in workflow

configured workflow to run script unit test

* test(@script): AG-18 configured commit script

configured pre-commit hook script to run unit test

* test(@script): AG-18 unit test implementation

implemented unit test for eoa script

* test(@script): AG-18 code coverage

unit test code coverage report implementation

* refactor(@script): AG-18 precommit hook

added check in pre-commit hook

* fix(@script): AG-18 fixed unit test threshold

fixed unit test code coverage threshold

* fix(@agora): AG-18 fixed package.json

fixed package json property not used

* fix(@agora): AG-18 fixed unit test

n

* fix(@agora): AG-18 fixed workflow

fixed workflow

* refactor(@script): AG-18 test code coverage threshold

test code coverage threshold

* docs(@agora): AG-18 updated readme

updated readme file

* Ag 19 DECsRegistry smart contract (#8)

* fix(@script): AG-19 removed comments

removed code comments

* docs(@docs): AG-19 updated sequence diagrams

updated the sequence diagrams images for the functional analysis

* docs(@docs): AG-19 updated smart contract classes

updated docs about the smart contracts classes

* feat(@contracts): AG-19 DEC contract implementation

implemented a first version of the DEC contract

* feat(@contracts): AG-19 added events to DEC sc

emitted event in the DEC smart contract implementation

* feat(@contracts): AG-19 implemented DEC contract

implemented DEC contract and related unit tests

* fix(@contracts): AG-19 removed event

removed event not used in DEC contract

* feat(@contracts): AG-19 DECs registry implementation

implemented the register of the DECs with the required methods

* test(@contracts): AG-19 defined test for DECsRegistry contract

defined test structure for the DECsRegistry smart contract

* test(@contracts): AG-19 implemented unit test

implemented unit tests for DECsRegistry smart contract

* feat(@contracts): AG-19 added events to smart contract

added events to the DECsRegistry smart contract

* Ag 20 election smart contract (#9)

* refactor(@agora): AG-20 switched test network

switched from legacy goerli test network to sepolia

* docs(@docs): AG-20 updated analysis diagrams

updated diagrams in the functional analysis

* feat(@contracts): AG-20 Election smart contract

implemented Election smart contract with unit tests

* feat(@contracts): AG-20 Elections smart contracts

implemeneted different smart contracts for different kind of elections

* docs(@docs): AG-20 addded diagrams files to docs

added diagrams file to the docs folder

* docs(@docs): AG-20 updated class diagrams

updated the smart contracts class diagrams

* Ag 20 election smart contract (#10)

* refactor(@agora): AG-20 switched test network

switched from legacy goerli test network to sepolia

* docs(@docs): AG-20 updated analysis diagrams

updated diagrams in the functional analysis

* feat(@contracts): AG-20 Election smart contract

implemented Election smart contract with unit tests

* feat(@contracts): AG-20 Elections smart contracts

implemeneted different smart contracts for different kind of elections

* docs(@docs): AG-20 addded diagrams files to docs

added diagrams file to the docs folder

* docs(@docs): AG-20 updated class diagrams

updated the smart contracts class diagrams

* fix(@agora): AG-20 updated version number

updated version number in package json

* Ag 25 deploy contracts (#13)

* feat(@agora): AG-25 configured evm compiler

configured the evm compiler in the hardhat configuration file

* refactor(@contracts): AG-25 refactored DECs Registry contract

refactored DECs registry contract

* refactor(@contracts): AG-25 refactored DEC contract

refactored DEC smart contract

* feat(@contracts): AG-25 added name property to DECs Registry

added name property to DECs Registry smart contract

* feat(@contracts): ignition modules implementation

implemented the ignition modules for contracts deploy

* fix(@contracts): AG-25 added folder to gitignore

added foldet to gitignore

* fix(@contracts): AG-25 ignored files

added files to gitignore

* Ag 26 register election script (#14)

* docs(@docs): modified main flow diagram

modified the representation of the entire process in the functional analysis

* docs(@docs): AG-26 typo fix

typo fix in the README file

* feat(@scripts): AG-26 implemented the deploy for the Election smart contract

implemented the ignition module for the deploy of the Election smart contract

* feat(@script): AG-26 municipality election deploy

created the ignition module for the deploy of a municipality election

* feat(@contracts): AG-26 defined methods for municipality election contract

defined properties and methods for the municipality election smart contract

* feat(@contracts): AG-26 election contract modifier implementation

implemented a modifier in the municipality election smart contract

* feat(@contracts): AG-26 municipality election method implementation

implemented the registerParty method in the municipality election smart contract

* refactor(@contracts): AG_26 modified contracts methods

modified the sign of the methods of all the smart contracts

* feat(@contracts): AG-26 municipality election smart contract

implemented the municipality election smart contract

* refactor(@contracts): AG-26 refactored municipality election contract

refactored municipality election smart contract to make it more gas efficient

* feat(@contracts): AG-26 added getter to municipality election contract

added a getter function to the municipality election getter contract

* refactor(@contracts): AG-26 formatted smart contract

formatted smart contract file

* feat(@contracts): AG-26 get coalition in municipality election

implemented a get coalition in the municipality election contract

* refactor(@contracts): AG-26 refactored municipality election contract

refactored municipality election contract

* refactor(@contracts): AG-26 Municipality contract unit test

unit tests implementation for municipality election smart contract

* feat(contracts): AG-26 refactored Municipality Election

modified Municipality Election smart contract deploy

* feat(@contracts): AG-26 Ignition module implementation

ignition module implementation

* style(@contracts): AG-26 contract refactor

refactored formatting of a smart contract

* feat(@contracts): AG-26 MunicipalityElection smart contract deploy script

implementation of the ignition module for the deploy of the MunicipalityElection smart dd contract

* feat(@contracts): AG-26 Create election script definition

defined create-election script that register the data into a given election contract

* feat(@scripts): AG-26 create election script partial implementation

partially implemented the script for the MunicipalityElection smart contract

* feat(@scripts): AG-26 Implemented the create-election script

implemented the create election script

* feat(@script): AG-26 unit test implementation

implemented unit test for create election script

* refactor(@script): improved script

improved script

* Ag 37 actions api layer (#16)

* feat(@ci): AG-37 defined ci module

defined a ci module for the workflows api layer

* feat(@ci): AG-37 ci api integration

integrated ci apis into github actions workflow

* fix(@ci): AG-37 fixed command path

fixed ci command path

* fix(ci): AG-37 fixed ci module logic

fixed ci module logic

* docs(@docs): updated README

updated README

* fix(@ci): AG-36 fixed github username (#19)

fixed git user in workflow

* Ag 39 encrypt dec data (#21)

* docs(@docs): AG-39 updated architectural diagram

updated architectural diagram

* feat(@lib): AG-39 cryptoUtils lib implementation

implemented library that ecrypt and decrypt strings

* feat(@script): AG-39 deploy encrypted DEC implementation

implemented the encryption of DEC data and deploy of smart contract instance

* feat(@script): AG-39 script test

implemented unit test for election scripts

* Ag 40 dec registration (#22)

* feat(@scripts): AG-40 decs registry deploy script

defined the script for the deploy of the DECs Registry

* feat(scripts): AG-40 decs registry deploy script

implemented the script for the deploy of the DECs Registry

* test(scripts): unit test implementation

implemented unit test for the DECsRegistry deploy script

* feat(scripts): AG-40 DEC registration

defined the script for the registration of a DEC into the Registry

* feat(scripts): AG-40 register dec script

implemented register dec script

* feat(@script): AG-40 register dec

refactored the register dec script implementation

* feat(@script): AG-40 process review

review and fixes of the entire process with scripts

* docs(@docs ): AG-40 updated readme

updated readme

* refactor(@docs): AG-40 updated app version

updated version

* fix(@cicd): AG-42 fix github actions (#24)

fixed tag creation in workflow

* fix(CICD): AG-42 workflow fixes (#26)

workflow fixes

* fix(CICD): AG-42 fixes

fixes

* AG-42 fixes (#30)

* fixes (#32)

* Ag 32 zokrates init (#36)

* feat(@zkp): AG-32 zokrates init

init a zokrates proof as example

* docs(docs): AG-32 updated docs

updated documentation

* fix(CI/CD): AG-45 added set -e parameter to workflow (#38)

* fix(CI/CD): AG-45 added set -e parameter to workflow

added the set -e parameter to workflow steps

* test pipeline

* test pipeline

* test pipeline

* test pipeline

* fix(CI/CD): AG-45 fixed ci module

fixed error handling in CI module functions

* docs(docs): AG-45 updated readme

updated readme

* feat(zk-snarks): AG-32 defined voting program (#39)

defined municipality election voting zk-snarks protocol

* updated version
  • Loading branch information
g3k0 authored Apr 18, 2024
1 parent 772b22c commit 9feb3ae
Show file tree
Hide file tree
Showing 22 changed files with 151 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .jscpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"reporters": ["console"],
"languages": ["javascript", "typescript"],
"gitignore": true,
"failOnDuplication": false
"failOnDuplication": true
}

9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ Remember to follow this convention for commit messages: `AG-<jira id> <descripti

Smart contracts code coverage documentation [here](https://www.npmjs.com/package/solidity-coverage).

CI/CD workflow fails if the unit test code coverage threshold (**80% of lines of code**) for scripts is not met.
### Quality gates

| step | library used | theshold | is error blocking |
|------|--------------|----------|-------------------|
| Code Linting | [eslint](https://www.npmjs.com/package/eslint) | No thesholds | yes |
| Code duplication | [jscpd](https://www.npmjs.com/package/jscpd) | 10% | yes |
| Smart contracts unit tests | [jest](https://www.npmjs.com/package/jest) | all tests must pass | yes |
| TypeScript files unit tests | [jest](https://www.npmjs.com/package/jest) | all tests must pass; 80% code coverage | yes |

## Run the localhost development network

Expand Down
38 changes: 32 additions & 6 deletions ci/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,44 @@ const execSyncOptions = { stdio: "inherit" };

const functions = {
installDeps: function () {
return execSync("npm install", execSyncOptions);
try {
execSync("npm install", execSyncOptions);
} catch (e) {
console.log(e);
process.exit(1);
}
},
lint: function () {
return execSync("npm run lint", execSyncOptions);
try {
execSync("npm run lint", execSyncOptions);
} catch (e) {
console.log(e);
process.exit(1);
}
},
checksDuplications: function () {
return execSync("npm run duplicated", execSyncOptions);
try {
execSync("npm run duplicated", execSyncOptions);
} catch (e) {
console.log(e);
process.exit(1);
}
},
smartContractsUnitTest: function () {
return execSync("npm run test-contracts", execSyncOptions);
try {
execSync("npm run test-contracts", execSyncOptions);
} catch (e) {
console.log(e);
process.exit(1);
}
},
scriptsUnitTest: function () {
return execSync("npm run test-scripts", execSyncOptions);
try {
execSync("npm run test-scripts", execSyncOptions);
} catch (e) {
console.log(e);
process.exit(1);
}
},
tagRelease: function () {
try {
Expand All @@ -39,7 +64,8 @@ const functions = {
);
execSync("git push origin --tags", execSyncOptions);
} catch (e) {
throw new Error(e);
console.log(e);
process.exit(1);
}
},
};
Expand Down
7 changes: 2 additions & 5 deletions contracts/MunicipalityElection.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ contract MunicipalityElection is Election {
struct Candidate {
string name;
string candidatesFor; // major or councilor
uint256 points;
}

/// @dev the string key of the map correspond tho the party name registered in the parties mapping
Expand Down Expand Up @@ -112,8 +111,7 @@ contract MunicipalityElection is Election {

Candidate memory c = Candidate({
name: councilorCandidates[i],
candidatesFor: "councilor",
points: 0
candidatesFor: "councilor"
});

candidatesList.push(c);
Expand Down Expand Up @@ -143,8 +141,7 @@ contract MunicipalityElection is Election {

Candidate memory mcandidate = Candidate({
name: majorCandidate,
candidatesFor: "major",
points: 0
candidatesFor: "major"
});

Coalition memory newCoalition;
Expand Down
4 changes: 4 additions & 0 deletions election-scripts/__mocks__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const MAJOR_CANDIDATE_2 = "Ugo Silenti";
export const PARTIES: Party[] = [
{
name: PARTY_NAME_A,
points: 0,
councilorCandidates: [
"Luigi Rossi",
"Maria Verdi",
Expand All @@ -50,6 +51,7 @@ export const PARTIES: Party[] = [
},
{
name: PARTY_NAME_B,
points: 0,
councilorCandidates: [
"Francesca Riti",
"Vanessa Reti",
Expand All @@ -60,6 +62,7 @@ export const PARTIES: Party[] = [
},
{
name: PARTY_NAME_C,
points: 0,
councilorCandidates: [
"Giuseppe Toni",
"Nicolò Movizzo",
Expand All @@ -70,6 +73,7 @@ export const PARTIES: Party[] = [
},
{
name: PARTY_NAME_D,
points: 0,
councilorCandidates: [
"Patrizio Pini",
"Mariagrazia Crudi",
Expand Down
3 changes: 0 additions & 3 deletions election-scripts/create-election.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ describe("Create Election Script", () => {
expect(coalitionFromContract[0][1]).to.equal(
coalition.majorCandidate.candidatesFor,
);
expect(coalitionFromContract[0][2]).to.equal(
coalition.majorCandidate.points,
);
expect(coalitionFromContract[1]).to.deep.equal(
coalition.parties.map((p) => p.name),
);
Expand Down
6 changes: 4 additions & 2 deletions election-scripts/create-election.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,15 @@ export async function main(
majorCandidate: {
name: coalition1Raw[0][0],
candidatesFor: coalition1Raw[0][1] as Candidature,
points: Number(coalition1Raw[0][2]),
points: 0,
},
parties: [],
};

for (const p of parties) {
for (const k of coalition1Raw[1]) {
if (k === p.name) {
p.points = 0;
coalition1.parties.push(p);
}
}
Expand All @@ -120,14 +121,15 @@ export async function main(
majorCandidate: {
name: coalition2Raw[0][0],
candidatesFor: coalition2Raw[0][1] as Candidature,
points: Number(coalition2Raw[0][2]),
points: 0,
},
parties: [],
};

for (const p of parties) {
for (const k of coalition2Raw[1]) {
if (k === p.name) {
p.points = 0;
coalition2.parties.push(p);
}
}
Expand Down
1 change: 1 addition & 0 deletions election-scripts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type Candidate = {

export type Party = {
name: string;
points: number;
councilorCandidates: string[];
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agora",
"version": "0.7.0",
"version": "0.8.0",
"description": "A confidentiality-first electronic voting system",
"author": {
"name": "nova collective",
Expand Down
1 change: 0 additions & 1 deletion test/MunicipalityElection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ describe("MunicipalityElection Contract", function () {

expect(coalition[0][0]).to.be.equal(majorCandidate);
expect(coalition[0][1]).to.be.equal("major");
expect(coalition[0][2]).to.be.equal(0);
expect(coalition[1][0]).to.be.equal(partyName);
expect(coalition[1][1]).to.be.equal(partyNameB);
});
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
98 changes: 98 additions & 0 deletions zkProtocols/voting/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Municipality Election zk-SNARKS Voting proof

## About

This program implements a π-vote proof based on a municipality election smart contract deployed using the election-scripts.

The TypeScript script deploy the MunicipalityElection smart contract and registers parties and candidates using mock data.This must be done
before to generate the proof program.

In a real use case of this program, the circuit for the π-vote proof must be generated after the election
registration phase has closed, so that you know the ballot paper used by the Voter to vote.

Following the ballot paper for the municipalityElection generated by the ts script:

```json
{
"contractAddress":"0xa82fF9aFd8f496c3d6ac40E2a0F282E47488CFc9",
"coalitions":[
{
"majorCandidate":{
"name":"Pino Pini",
"candidatesFor":"major",
"points":0
},
"parties":[
{
"name":"Partito Democratico",
"councilorCandidates":[
"Luigi Rossi",
"Maria Verdi",
"Renato Bianchi",
"Francesco Guidi",
"Paolo Franchi"
],
"points":0
},
{
"name":"Forza Italia",
"councilorCandidates":[
"Francesca Riti",
"Vanessa Reti",
"Mario Checchi",
"Carlo Proni",
"Pierpaolo Pingitore"
],
"points":0
}
]
},
{
"majorCandidate":{
"name":"Ugo Silenti",
"candidatesFor":"major",
"points":0
},
"parties":[
{
"name":"Cinque Stelle",
"councilorCandidates":[
"Giuseppe Toni",
"Nicolò Movizzo",
"Alessandra Tonali",
"Antonella Chierici",
"Antonio Basso"
],
"points":0
},
{
"name":"Lega",
"councilorCandidates":[
"Patrizio Pini",
"Mariagrazia Crudi",
"Sabrina Giacigli",
"Marco Lioni",
"Pio Pedri"
],
"points":0
}
]
}
]
}
```

## Voting mechanism

The election is created assigning 20 voting points (see the `election-scripts/create-election.ts`).

Therefore, each voter can assign point to the major candidates and/or the parties
up to a maximum of 20 points totally.

It is possible to assign points to more that one major candidate at the same time and also to parties in different coalitions.

## What this program proofs

1. The sum of the points assigned to the candidates and the parties does not exceed 20;
2. Since a voter can assign negative points in that way that the sum is 20, the second proof verifies that the points assigned are positive integers;
3. The third proof consist to demonstrate that the voter knows for whom he/she is voting;
Empty file added zkProtocols/voting/root.zk
Empty file.

0 comments on commit 9feb3ae

Please sign in to comment.