|
36 | 36 | },
|
37 | 37 | {
|
38 | 38 | "cell_type": "code",
|
39 |
| - "execution_count": null, |
| 39 | + "execution_count": 1, |
40 | 40 | "metadata": {},
|
41 | 41 | "outputs": [],
|
42 | 42 | "source": [
|
|
57 | 57 | },
|
58 | 58 | {
|
59 | 59 | "cell_type": "code",
|
60 |
| - "execution_count": null, |
| 60 | + "execution_count": 2, |
61 | 61 | "metadata": {},
|
62 | 62 | "outputs": [],
|
63 | 63 | "source": [
|
|
82 | 82 | },
|
83 | 83 | {
|
84 | 84 | "cell_type": "code",
|
85 |
| - "execution_count": null, |
| 85 | + "execution_count": 3, |
86 | 86 | "metadata": {},
|
87 | 87 | "outputs": [],
|
88 | 88 | "source": [
|
|
109 | 109 | },
|
110 | 110 | {
|
111 | 111 | "cell_type": "code",
|
112 |
| - "execution_count": null, |
| 112 | + "execution_count": 4, |
113 | 113 | "metadata": {},
|
114 | 114 | "outputs": [],
|
115 | 115 | "source": [
|
|
124 | 124 | " vote_class = pricon_vote.get_vote_class(vote_value)\n",
|
125 | 125 | "\n",
|
126 | 126 | " onehot_votes = [0] * len(pricon_vote)\n",
|
127 |
| - " onehot_votes[vote_class] = 1\n", |
| 127 | + " onehot_votes[vote_class] = 1 # [1, 0, 0]\n", |
128 | 128 | " \n",
|
129 | 129 | " vote_shares = [self._encrypt_vote(binary_vote) for binary_vote in onehot_votes]\n",
|
130 | 130 | "\n",
|
|
134 | 134 | " self._vote_shares = None\n",
|
135 | 135 | "\n",
|
136 | 136 | " def _encrypt_vote(self, vote: int):\n",
|
137 |
| - " share_a = random.randint(-Q,Q)\n", |
138 |
| - " share_b = random.randint(-Q,Q)\n", |
139 |
| - " share_c = (vote - share_a - share_b) % Q\n", |
| 137 | + " share_a = random.randint(-self._Q,self._Q)\n", |
| 138 | + " share_b = random.randint(-self._Q,self._Q)\n", |
| 139 | + " share_c = (vote - share_a - share_b) % self._Q\n", |
140 | 140 | " return (share_a, share_b, share_c)\n",
|
141 | 141 | "\n",
|
142 | 142 | " def send_vote(self, parties) -> None:\n",
|
|
152 | 152 | },
|
153 | 153 | {
|
154 | 154 | "cell_type": "code",
|
155 |
| - "execution_count": null, |
| 155 | + "execution_count": 5, |
156 | 156 | "metadata": {},
|
157 | 157 | "outputs": [],
|
158 | 158 | "source": [
|
|
183 | 183 | },
|
184 | 184 | {
|
185 | 185 | "cell_type": "code",
|
186 |
| - "execution_count": null, |
| 186 | + "execution_count": 6, |
187 | 187 | "metadata": {},
|
188 | 188 | "outputs": [],
|
189 | 189 | "source": [
|
|
201 | 201 | },
|
202 | 202 | {
|
203 | 203 | "cell_type": "code",
|
204 |
| - "execution_count": null, |
| 204 | + "execution_count": 7, |
205 | 205 | "metadata": {},
|
206 | 206 | "outputs": [],
|
207 | 207 | "source": [
|
|
212 | 212 | },
|
213 | 213 | {
|
214 | 214 | "cell_type": "code",
|
215 |
| - "execution_count": null, |
| 215 | + "execution_count": 8, |
216 | 216 | "metadata": {},
|
217 | 217 | "outputs": [],
|
218 | 218 | "source": [
|
|
244 | 244 | },
|
245 | 245 | {
|
246 | 246 | "cell_type": "code",
|
247 |
| - "execution_count": null, |
| 247 | + "execution_count": 9, |
248 | 248 | "metadata": {},
|
249 | 249 | "outputs": [],
|
250 | 250 | "source": [
|
|
259 | 259 | },
|
260 | 260 | {
|
261 | 261 | "cell_type": "code",
|
262 |
| - "execution_count": null, |
| 262 | + "execution_count": 10, |
263 | 263 | "metadata": {},
|
264 |
| - "outputs": [], |
| 264 | + "outputs": [ |
| 265 | + { |
| 266 | + "name": "stdout", |
| 267 | + "output_type": "stream", |
| 268 | + "text": [ |
| 269 | + "red: Adding vote for 3a29334a-cff6-4a73-b681-29aa0bd3be41\n", |
| 270 | + "blue: Adding vote for 3a29334a-cff6-4a73-b681-29aa0bd3be41\n", |
| 271 | + "yellow: Adding vote for 3a29334a-cff6-4a73-b681-29aa0bd3be41\n", |
| 272 | + "red: Adding vote for c33db94b-8e5b-488f-ac39-91c74491f123\n", |
| 273 | + "blue: Adding vote for c33db94b-8e5b-488f-ac39-91c74491f123\n", |
| 274 | + "yellow: Adding vote for c33db94b-8e5b-488f-ac39-91c74491f123\n", |
| 275 | + "red: Adding vote for 0347145d-dd85-4ef8-930f-12dcff90190e\n", |
| 276 | + "blue: Adding vote for 0347145d-dd85-4ef8-930f-12dcff90190e\n", |
| 277 | + "yellow: Adding vote for 0347145d-dd85-4ef8-930f-12dcff90190e\n", |
| 278 | + "red: Adding vote for 5d88aa47-a73a-4e04-9111-fa0f0fef189d\n", |
| 279 | + "blue: Adding vote for 5d88aa47-a73a-4e04-9111-fa0f0fef189d\n", |
| 280 | + "yellow: Adding vote for 5d88aa47-a73a-4e04-9111-fa0f0fef189d\n", |
| 281 | + "red: Adding vote for 7e41730d-4270-490f-b227-a3ee719373eb\n", |
| 282 | + "blue: Adding vote for 7e41730d-4270-490f-b227-a3ee719373eb\n", |
| 283 | + "yellow: Adding vote for 7e41730d-4270-490f-b227-a3ee719373eb\n", |
| 284 | + "red: Adding vote for eb09cd17-166f-4fa4-8a89-ac7a199119e3\n", |
| 285 | + "blue: Adding vote for eb09cd17-166f-4fa4-8a89-ac7a199119e3\n", |
| 286 | + "yellow: Adding vote for eb09cd17-166f-4fa4-8a89-ac7a199119e3\n", |
| 287 | + "red: Adding vote for fd992cfa-bb52-4fdd-b42f-90c2b1107ac4\n", |
| 288 | + "blue: Adding vote for fd992cfa-bb52-4fdd-b42f-90c2b1107ac4\n", |
| 289 | + "yellow: Adding vote for fd992cfa-bb52-4fdd-b42f-90c2b1107ac4\n" |
| 290 | + ] |
| 291 | + } |
| 292 | + ], |
265 | 293 | "source": [
|
266 | 294 | "for voter in [alice, bob, charlie, dan, eve, fran, greg]:\n",
|
267 | 295 | " voter.send_vote([red, blue, yellow])"
|
|
276 | 304 | },
|
277 | 305 | {
|
278 | 306 | "cell_type": "code",
|
279 |
| - "execution_count": null, |
| 307 | + "execution_count": 11, |
280 | 308 | "metadata": {},
|
281 |
| - "outputs": [], |
| 309 | + "outputs": [ |
| 310 | + { |
| 311 | + "data": { |
| 312 | + "text/plain": [ |
| 313 | + "[-1689120296584, -1384865635954, -859978157999]" |
| 314 | + ] |
| 315 | + }, |
| 316 | + "execution_count": 11, |
| 317 | + "metadata": {}, |
| 318 | + "output_type": "execute_result" |
| 319 | + } |
| 320 | + ], |
282 | 321 | "source": [
|
283 | 322 | "red._vote_sum"
|
284 | 323 | ]
|
|
303 | 342 | },
|
304 | 343 | {
|
305 | 344 | "cell_type": "code",
|
306 |
| - "execution_count": null, |
| 345 | + "execution_count": 12, |
307 | 346 | "metadata": {},
|
308 |
| - "outputs": [], |
| 347 | + "outputs": [ |
| 348 | + { |
| 349 | + "name": "stdout", |
| 350 | + "output_type": "stream", |
| 351 | + "text": [ |
| 352 | + "Vote counts are [3, 2, 2]\n", |
| 353 | + "PryVote is the winner!\n" |
| 354 | + ] |
| 355 | + } |
| 356 | + ], |
309 | 357 | "source": [
|
310 | 358 | "total_sums = []\n",
|
311 | 359 | "\n",
|
|
360 | 408 | "This could be solved by policy,\n",
|
361 | 409 | "such as frequent, independent auditing of a running vote aggregation during the lifetime of a vote session."
|
362 | 410 | ]
|
| 411 | + }, |
| 412 | + { |
| 413 | + "cell_type": "code", |
| 414 | + "execution_count": null, |
| 415 | + "metadata": {}, |
| 416 | + "outputs": [], |
| 417 | + "source": [] |
| 418 | + }, |
| 419 | + { |
| 420 | + "cell_type": "code", |
| 421 | + "execution_count": null, |
| 422 | + "metadata": {}, |
| 423 | + "outputs": [], |
| 424 | + "source": [] |
| 425 | + }, |
| 426 | + { |
| 427 | + "cell_type": "code", |
| 428 | + "execution_count": null, |
| 429 | + "metadata": {}, |
| 430 | + "outputs": [], |
| 431 | + "source": [] |
363 | 432 | }
|
364 | 433 | ],
|
365 | 434 | "metadata": {
|
|
378 | 447 | "name": "python",
|
379 | 448 | "nbconvert_exporter": "python",
|
380 | 449 | "pygments_lexer": "ipython3",
|
381 |
| - "version": "3.8.5" |
| 450 | + "version": "3.7.9" |
382 | 451 | }
|
383 | 452 | },
|
384 | 453 | "nbformat": 4,
|
|
0 commit comments