@@ -28,7 +28,7 @@ contract Chirotonia {
2828 uint256 [] votanti;
2929 mapping (uint256 => bool ) votanteAccreditato;
3030 StatoVotazione stato;
31- uint256 [] voti;
31+ string [] voti;
3232 mapping (uint256 => bool ) votiAccettati;
3333 }
3434
@@ -39,6 +39,8 @@ contract Chirotonia {
3939 address public identityManager;
4040
4141 address public privacyManager;
42+
43+ string encryptionKey;
4244
4345 modifier onlyManager {
4446 require (msg .sender == manager);
@@ -50,6 +52,11 @@ contract Chirotonia {
5052 _;
5153 }
5254
55+ modifier onlyPrivacyManager {
56+ require (msg .sender == privacyManager);
57+ _;
58+ }
59+
5360 constructor (address _identityManager ) public {
5461 manager = msg .sender ;
5562 identityManager = _identityManager;
@@ -145,7 +152,8 @@ contract Chirotonia {
145152 uint256 [2 ] calldata tag ,
146153 uint256 [] calldata tees ,
147154 uint256 seed ,
148- uint256 voto ,
155+ uint256 voteHash ,
156+ string calldata voto ,
149157 string calldata _identificativoVotazione
150158 ) external {
151159 Votazione storage votazione = votazioni[_identificativoVotazione];
@@ -156,12 +164,19 @@ contract Chirotonia {
156164 // Verifica che il voto non sia stato già espresso
157165 require (! votazione.votiAccettati[tag[0 ]], "Voto già espresso " );
158166 // Verifica la correttezza della firma ad anello
159- require (verifyRingSignature (voto , tag, tees, seed, _identificativoVotazione), "Firma non valida " );
167+ require (verifyRingSignature (voteHash , tag, tees, seed, _identificativoVotazione), "Firma non valida " );
160168 // Aggiunge il voto a quelli accettati
161169 votazione.voti.push (voto);
162170 // Segna il votante come già votato
163171 votazione.votiAccettati[tag[0 ]] = true ;
164172 }
173+
174+ function verificaTag (
175+ string calldata _identificativoVotazione ,
176+ uint256 _xTag
177+ ) external view returns (bool ) {
178+ return votazioni[_identificativoVotazione].votiAccettati[_xTag];
179+ }
165180
166181 /**
167182 Chiude la votazione ponendo lo stato in Scrutinio
@@ -173,10 +188,17 @@ contract Chirotonia {
173188 }
174189
175190 /**
176- Recupera l'insieme di voti per una data votazione
191+ Recupera l'i-esimo voto per una data votazione
192+ */
193+ function getVoto (string calldata _identificativoVotazione , uint256 index ) external view returns (string memory ) {
194+ return votazioni[_identificativoVotazione].voti[index];
195+ }
196+
197+ /**
198+ Mostra il numero di voti salvati per una data votazione
177199 */
178- function getVoti (string calldata _identificativoVotazione ) external view returns (uint256 [] memory ) {
179- return votazioni[_identificativoVotazione].voti;
200+ function getNumeroVotiAcquisiti (string calldata _identificativoVotazione ) external view returns (uint256 ) {
201+ return votazioni[_identificativoVotazione].voti. length ;
180202 }
181203
182204 /**
@@ -185,6 +207,13 @@ contract Chirotonia {
185207 function setPrivacyManager (address _privacyManager ) external onlyManager {
186208 privacyManager = _privacyManager;
187209 }
210+
211+ /**
212+ Imposta l'indirizzo del Privacy Manager per la crittazione dei voti
213+ */
214+ function setEncryptionKey (string calldata _encryptionKey ) external onlyPrivacyManager {
215+ encryptionKey = _encryptionKey;
216+ }
188217
189218 /**
190219 Funzione di verifica della firma ad anello collegabile
0 commit comments