# Re: Trying to avoid digging through the archives

From: Alan Dechert <alan_at_openvotingconsortium_dot_org>
Date: Sun Nov 30 2003 - 12:18:46 CST

Karl (digging through archives).

I recognize this is becoming an increasing problem. I hope we can get an
FAQ together fairly soon and get the architecture document update too.

>
> Can anyone point me to the description of how the choices are encoded into
> "the big number" (36 digits?) that is made visible via the bar-code?
>
have a look at the ballot mockup here:

Each button represents a digit in a 116-digit string of 0s and 1s, "0" for
not selected an "1" for selected. The first digit in this string is the
first choice in the first contest (Geo Wash for Pres). After you go down
the first column, the next digit represents the first choice in the second
column (Willard for US Senate) and so on. The county commissioner contest
takes up the last 64 positions in the 116 digit string. The 8 positions for
each candidate represent choices for rank (first - eighth, left-right).

After all selections are made, you wind up with a this 116 digit binary
number. That gets changed to decimal (35 digits but you need a leading zero
because Charcter set C for the Code 128 barcode scheme needs digitis in
pairs).

def todecimal(bin):
dec = 0
pow = 1
for i in bin:
dec += i*pow
pow *= 2
return dec

def tobinary(dec):
bin = []
while dec > 0:
bit = int(dec % 2)
bin.append(bit)
dec = (dec - bit)/2
return bin

Then the 36 digit decimal number (really 35 with leading zero). Then we use
the ballot number (4 digits) as a key to obscure the number (and resultant
barcode):

Here's the Python code for the obscure routine

def obscure(key, num):
keydigits = list(key)
numdigits = list(num)
for i in range(len(numdigits)):
numdigits[i] = str((int(numdigits[i]) + int(keydigits[i % 4])) % 10)
return string.join(numdigits, "")

Revert is like so:

def revert(key, num):
keydigits = list(key)
numdigits = list(num)
for i in range(len(numdigits)):
numdigits[i] = str((int(numdigits[i]) - int(keydigits[i % 4])) % 10)
return string.join(numdigits, "")

The BVA app you looked at has a dBASE translation of the revert function.

For more details, see these posts from Jan:

And, of course, these is much discussion leading up to this.

Alan D.
==================================================================
= The content of this message, with the exception of any external
= quotations under fair use, are released to the Public Domain
==================================================================
Received on Sun Nov 30 23:17:12 2003

This archive was generated by hypermail 2.1.8 : Sun Nov 30 2003 - 23:17:13 CST