[Noisebridge-discuss] 2014 BoD Electctions + Crypto (Help Needed)

bfb at riseup.net bfb at riseup.net
Wed Jan 29 10:14:02 UTC 2014


Hi y'all

Noisebridge Board of Directors elections happen soon. Ballots will be
froze and cut at the next Tuesday meeting (Feb 4, 2014). Throw your hat in
the ring, nominate a friend, or see who nominated you at
<https://noisebridge.net/wiki/Board/2014_Nominations>.

As regards the election protocol. I prefer to use a Prêt à Voter scheme
[1]. I need your help. If you're thinking of a sweet piece of image
recognition open source software, then write it down in a response to this
message.

The software should be able to read and respond to the following
information on a ballot; plain-text code and checked/unchecked boxes.

Sample ballot:

[X]
[X]
[X]
[X]
[X]
hiNbk84zarcIGPV1Hlzo6yapByRgyj7A4fFxruK0M6JxuLDsy5NuLjfLPlAlGhuJr/jE3nXdVkrtvyzt/xCQJQ==

I have a basic implementation of Prêt à Voter that takes a candidate list,
creates an exhaustive list of possible orderings, and encrypts the order
using AES. The plain-text code on the ballot is the cipher text of the
order. The image recognition software should be able to decode, assign
candidates to boxes, and make a final tally. Voilà.

The code is bellow. I'm a beginner taking a Coursera Crypto course, please
help me to fix all that is wrong, broken and insecure in what follows...

#!/usr/bin/env python

from Crypto.Cipher import AES
from Crypto.Util import Counter
from itertools import permutations
import base64
import os

#Ballot Stuff

candidate_a = "alan touring"
candidate_b = "alanzo church"
candidate_c = "grace hopper"
candidate_d = "charles babbage"
candidate_e = "ada lovelace"

ballot = [candidate_a, candidate_b, candidate_c,
          candidate_d, candidate_e]
ballots = permutations(ballot)

#Crypto Stuff

key = os.urandom(32) #For safe keeping
ctr = Counter.new(128, initial_value=0)
ctr_decrypt = Counter.new(128, initial_value=0)
aes = AES.new(key, AES.MODE_CTR, counter=ctr)
aes_decrypt = AES.new(key, AES.MODE_CTR, counter=ctr_decrypt)

#Ballot Code Generation

for b in ballots:
    order = ''.join(b)
    cipher_text = aes.encrypt(order)
    ballot_code = base64.b64encode(cipher_text)
    image_regcognition_decryption = base64.b64decode(ballot_code) #A machine
    print ballot_code, aes_decrypt.decrypt(image_recognition_decryption)



[1] Read all about it at <https://en.wikipedia.org/wiki/Pret_a_Voter>




More information about the Noisebridge-discuss mailing list