Skip to content

Ballot Encryption

An ElectionGuard ballot is comprised entirely of encryptions of one (indicating selection made) and zero (indicating selection not made). To enable homomorphic addition (for tallying), these values are exponentiated during encryption. Specifically, to encrypt a ballot entry (V), a random value R is selected such that 0R<q, and the following computation is performed.

  • Zero (not selected) is encrypted as (gRmodp,KRmodp).

  • One (selected) is encrypted as (gRmodp,gKRmodp).

Note that if multiple encrypted votes (gRimodp,gViKRimodp) are formed, their component-wise product (giRimodp,giViKiRimodp) serves as an encryption of iVi which is the tally of those votes.1

A contest in an election consists of a set of options together with a selection limit that indicates the number of selections that are allowed to be made in that contest. In most elections, most contests have a selection limit of one. However, a larger selection limit (e.g., select up to three) is not uncommon in some elections. Approval voting can be achieved by setting the selection limit to the total number of options in a contest. Ranked choice voting is not supported in this version of ElectionGuard, but it may be enabled in a future version.2 Also, write-ins are assumed to be explicitly registered or allowed to be lumped into a single “write-ins” category for the purpose of verifiable tallying. Verifiable tallying of free-form write-ins may be best done with a MixNet3 design.

A legitimate vote in a contest consists of a set of selections with cardinality not exceeding the selection limit of that contest. To accommodate legitimate undervotes, the internal representation of a contest is augmented with “placeholder” options equal in number to the selection limit. Placeholder options are selected as necessary to force the total number of selections made in a contest to be equal to the selection limit. When the selection limit is one, for example, the single placeholder option can be thought of as a “none of the above” option.

With larger selection limits, the number of placeholder options selected corresponds to the number of additional options that a voter could have selected in a contest.

Note

For efficiency, the placeholder options could be eliminated in an approval vote. However, to simplify the construction of election verifiers, we presume that placeholder options are always present – even for approval votes.

Two things must now be proven about the encryption of each vote to ensure the integrity of a ballot.

  1. The encryption associated with each option is either an encryption of zero or an encryption of one.

  2. The sum of all encrypted values in each contest is equal to the selection limit for that contest (usually one).

The use of ElGamal encryption enables efficient zero-knowledge proofs of these requirements, and the Fiat-Shamir heuristic can be used to make these proofs non-interactive. ChaumPedersen proofs are used to demonstrate that an encryption is that of a specified value, and these are combined with the Cramer-Damgård-Schoenmakers technique to show that an encryption is that of one of a specified set of values – particularly that a value is an encryption of either zero or one. The encryptions of selections in a contest are homomorphically combined, and the result is shown to be an encryption of that contest’s selection limit – again using a Chaum-Pedersen proof.

Note

Note that the decryption of the selection limit could be more efficiently demonstrated by just releasing the sum of the nonces used for each of the individual encryptions. But, again to simplify the construction of election verifiers, a Chaum-Pedersen proof is used here as well.

The “random” nonces used for the ElGamal encryption of the ballot nonces are derived from a single 256-bit master nonce RB for each ballot. For each contest listed in the ballot coding file, a contest nonce RC is derived from the master nonce (RB) and the contest label (LC) as RC=H(LC,RB) using the hash function SHA-256. For each option listed in the ballot coding file, the nonce used to encrypt that option is derived from the contest nonce (RC) and the selection label for that option (LS) as R=H(LS,RC).

A user of ElectionGuard may optionally provide an additional public key. If such a key is provided, ElectionGuard uses that key to encrypt each ballot’s master nonce RB and return this encryption together with the encrypted ballot.

Ballot nonces may be independent across different ballots, and only the nonces used to encrypt ballot selections need to be derived from the master nonce. The use of a single master nonce for each ballot allows the entire ballot encryption to be re-derived from the contents of a ballot and the master nonce. It also allows the encrypted ballot to be fully decrypted with the single master nonce.

Outline for proofs of ballot correctness

To prove that an ElGamal encryption pair (α,β) is an encryption of zero, the Chaum-Pedersen protocol proceeds as follows.

NIZK Proof that (α,β) is an encryption of zero (given knowledge of encryption nonce R)

The prover selects a random value u in q and commits to the pair (a,b)=(gumodp,Kumodp). A hash computation is then performed (using the Fiat-Shamir heuristic) to create a pseudo-random challenge value c=H(Q¯,(α,β),(a,b)), and the prover responds with v=(u+cR)modq. A verifier can now confirm the claim by checking that both gvmodp=aαcmodp and Kvmodp=bβcmodp are true.

NIZK Proof that (α,β) is an encryption of one (given knowledge of encryption nonce R)

To prove that (α,β) is an encryption of one, βgmodp is substituted for β in the above. The verifier can be relieved of the need to perform a modular division by computing βg¯modp rather than βgmodp. As an alternative, the verifier can confirm that gcKvmodp=bβcmodp instead of Kvmodp=b(βg)cmodp.

As with many zero-knowledge protocols, if the prover knows a challenge value prior to making its commitment, it can create a false proof. For example, if a challenge c is known to be forthcoming, a prover can generate a random v in q and commit to (a,b)=(gvαcmodp,Kvβcmodp)=(gvαqcmodp,Kvβqcmodp). This selection will satisfy the required checks for (α,β) to appear as an encryption of zero regardless of the values of (α,β). Similarly, setting (a,b)=(gvαcmodp,Kvgcβcmodp)=(gvαqcmodp,Kvgcβqcmodp) will satisfy the required checks for (α,β) to appear as an encryption of one regardless of the values of (α,β). This quirk is what enables the Cramer-Damgård-Schoenmakers technique to prove a disjunction of two predicates.

Sketch of NIZK Proof that (α,β) is an encryption of zero or one

After the prover makes commitments (a0,b0) and (a1,b1) to the respective assertions that (α,β) is an encryption of zero and (α,β) is an encryption of one, a single challenge value c is selected by hashing all commitments and baseline parameters. The prover must then provide challenge values c0 and c1 such that c=c0+c1modq. Since the prover has complete freedom to choose one of c0 and c1, the prover can fix one value in advance – either c0 if (α,β) is actually an encryption of one or c1 if (α,β) is actually an encryption of zero. In response to the resulting challenge c, the prover uses this freedom to answer its faux claim with its chosen challenge value and then uses the remaining challenge value (as forced by the constraint that c=(c0+c1)modq) to demonstrate the truth of the other claim. An observer can see that one of the two claims must be true but cannot tell which.

Details for proofs of ballot correctness

The full protocol proceeds as follows – fully divided into the two cases.

To encrypt an “unselected” option on a ballot, a random nonce R is selected uniformly q and an encryption of zero is formed as (α,β)=(gRmodp,KRmodp).

NIZK Proof that (α,β) is an encryption of zero or one (given knowledge of encryption nonce R for which (α,β) is an encryption of zero)

To create the proof that (α,β) is an encryption of a zero or a one, randomly select c1, v1, and u0 from q and form the commitments

(a0,b0)=(gu0modp,Ku0modp)

and

(a1,b1)=(gv1αc1modp,Kv1gc1βc1modp)=(gv1αqc1modp,Kv1gc1βqc1modp).

A challenge value c is formed by hashing the extended base hash Q¯ together with (α,β), (a0,b0), and (a1,b1) to form a challenge value c=H(Q,(α,β),(a0,b0),(a1,b1)). The proof is completed by forming c0=(cc1)modq and v0=(u0+c0R)modq and answering the challenge by returning c0, c1, v0, and v1.

To encrypt a “selected” option on a ballot, a random nonce R is selected uniformly from q and an encryption of one is formed as (α,β)=(grmodp,gKrmodp).

NIZK Proof that (α,β) is an encryption of zero or one (given knowledge of encryption nonce R for which (α,β) is an encryption of one)

To create the proof that (α,β) is an encryption of a zero or a one, randomly select c0, v0, and u1 from q and form the commitments

(a0,b0)=(gv0αc0modp,Kv0βc0modp)=(gv0αqc0modp,Kv0βqc0modp)

and

(a1,b1)=(gu1modp,Ku1modp)

A challenge value c is formed by hashing the extended base hash Q¯ together with (α,β), (a0,b0), and (a1,b1) to form a challenge value c=H(Q¯,(α,β),(a0,b0),(a1,b1)). The proof is completed by forming c1=(cc0)modq and v1=(u1+c1R)modq and answering the challenge by returning c0, c1, v0, and v1.

In either of the two above cases, what is published in the election record is the encryption (α,β) together with the commitments (a0,b0) and (a1,b1) which are all hashed together with the election’s extended base hash to form the challenge value c which is published together with values c0, c1, v0, and v1.

Important

An election verifier must confirm the following for each possible selection on a ballot:

(A) The given values α, β, a0, b0, a1, and b1 are all in the set pr. (A value x is in pr if and only if x is an integer such that 0 ≤ x < p and xqmodp=1 is satisfied.)

(B) The challenge c is correctly computed as c=H(Q¯,(α,β),(a0,b0),(a1,b1)).

(C) The given values c0, c1, v0, and v1 are each in the set q. (A value x is in q if and only if x is an integer such that 0x<q.)

(D) The equation c=(c0+c1)modq is satisfied.

(E) The equation gv0modp=a0αc0modp is satisfied.

(F) The equation gv1modp=a1αc1modp is satisfied.

(G) The equation Kv0modp=b0βc0modp is satisfied.

(H) The equation gc1Kv1modp=b1βc1modp is satisfied.

Proof of satisfying the selection limit

The final step in proving that a ballot is well-formed is demonstrating that the selection limits for each contest have not been exceeded. This is accomplished by homomorphically combining all of the (αi,βi) values for a contest by forming the aggregate contest encryption (α,β)=(Πiαimodp,Πiβimodp) and proving that (α,β) is an encryption of the total number of votes allowed for that contest (usually one). The simplest way to complete this proof is to combine all of the random nonces Ri that were used to form each (αi,βi)=(gRimodp,KRimodp) or (αi,βi)=(gRimodp,gKRimodp) – depending on whether the value encrypted is zero or one. The aggregate nonce R=iRimodq matches the aggregate contest encryption as (α,β)=(Πiαimodp,Πiβimodp)=(gRmodp,gLKRmodp) - where L is the selection limit for the contest. (Recall that L extra “placeholder” positions will be added to each contest and set to one as necessary to ensure that exactly L selections are made for the contest.)

NIZK Proof that (α,β) is an encryption of L (given knowledge of aggregate encryption nonce R)

An additional Chaum-Pedersen proof of (α,β) being an encryption of L is performed by selecting a random U in q, publishing (a,b)=(gUmodp,KUmodp), hashing these values together with election’s extended base hash Q¯ to form a pseudo-random challenge C=H(Q¯,(α,β),(a,b)), and responding by publishing V=(U+CR)modq.4

Note that all of the above proofs can be performed directly by the entity performing the public key encryption of a ballot without access to the decryption key(s). All that is required is the nonces Ri used for the individual selection encryptions.

Important

An election verifier must confirm the following for each contest on the ballot:

(A) The number of placeholder positions matches the contest’s selection limit L.

(B) The contest total (A,B) satisfies A=Πiαimodp and B=Πiβimodp where the (αi,βi) represent all possible selections (including placeholder selections) for the contest.

(C) The given value V is in q.

(D) The given values a and b are each in qr.

(E) The challenge value C is correctly computed as C=H(Q¯,(A,B),(a,b)).

(F) The equation gVmodp=(aAC)modp is satisfied.

(G) The equation (gLCKV)modp=(bBC)modp is satisfied.

Tracking codes

Upon completion of the encryption of each ballot, a tracking code is prepared for each voter. The code is a running hash that begins with the extended base hash code Q¯ and includes an identifier for the voting device, the location of the voting device, the date and time that the ballot was encrypted, and, of course, the encryption of the ballot itself. The hash (H) used for this purpose is SHA-256. The tracking code is formed as follows. H0=H(Q¯) where Q¯ is the extended base hash code of the election. For ballot with index i>0,Hi=H(Hi1,D,T,Bi) where D consists of the voting device information described above, T is the date and time of ballot encryption, and Bi is an ordered list of the individual encryptions on the ballot – with the ordering as specified by the ballot coding file. At the conclusion of a voting period (this may be the end of a day in a multi-day election), the hash chain is closed by computing H¯=H(H,"CLOSE"), where H is the final tracking code produced by that device during that voting period. The close of the hash chain can be computed either by the voting device or subsequently by election administrators, and it is published as part of the election record.

Important

An election verifier must confirm that each of the values in the running hash is correctly computed. Specifically, an election verifier must confirm each of the following.

(A) The equation H0=H(Q¯) is satisfied.

(B) For each ballot Bi,Hi=H(Hi1,D,T,Bi) is satisfied.

(C) The closing hash H¯=H(H,"CLOSE") is correctly computed from the final tracking code H.

Once in possession of a tracking code (and never before), a voter is afforded an option to either cast the associated ballot or spoil it and restart the ballot preparation process. The precise mechanism for voters to make these selections may vary depending upon the instantiation, but this choice would ordinarily be made immediately after a voter is presented with the tracking code, and the status of the ballot would be undetermined until the decision is made. It is possible, for instance, for a voter to make the decision directly on the voting device, or a voter may instead be afforded an option to deposit the ballot in a receptacle or to take it to a poll worker to be spoiled. For vote-by-mail scenarios, a voter can be sent (hashes of) two complete sets of encryptions for each selectable option and can effect a ballot challenge implicitly by choosing which encryptions to return.


  1. The initial decryption actually forms the value giVimodp. However, since iVi is a relatively small value, it can be effectively computed from giVimodp by means of an exhaustive search or similar methods. 

  2. Benaloh J., Moran. T, Naish L., Ramchen K., and Teague V. Shuffle-Sum: Coercion-Resistant Verifiable Tallying for STV Voting (2009) in Transactions of Information Forensics and Security. 

  3. Chaum D. Untraceable Electronic Mail, Return Addresses, and Digital Pseudonyms (1981) Communications of the ACM. 

  4. One could simply release the aggregate nonce R=iRimodq to complete this proof. However, since Chaum-Pedersen proofs are being performed elsewhere, it is simpler for a verifier to just repeat the same steps.