me.edwards.des.block
Class Ballot

java.lang.Object
  extended by me.edwards.des.block.Ballot

public class Ballot
extends java.lang.Object

Data structure to store and maintain a single cast Ballot for a single entity (user). Ballots are created in an Election Application when a user votes.

The Ballot contains the Votes chosen by the user in addition to the user's unique UUID (created by the Election Authority). To prevent changes from being made to the Ballot, its hash is signed using the ECDSA private key generated by the Election Application. After the Ballot is signed, the private key is destroyed and the public key is sent to the Election Authority, marking the Ballot as cast. When the Node receives a Ballot, the signature is authenticated with the Ballot's hash to ensure that the Ballot was not changed en-route to the Node.

Created on: Nov 1, 2015 at 11:30:16 PM

Author:
Matthew Edwards

Field Summary
private  byte[] bytes
           
private  java.lang.String id
           
private  java.lang.String root
           
private  java.lang.String signature
           
private  java.lang.String signatureRoot
           
private  byte version
           
static byte VERSION
          This class' Ballot version
private  byte[] votes
           
 
Constructor Summary
Ballot(byte[] binary)
          Initializes Ballot from binary data as a byte array.
Ballot(java.lang.String id, java.lang.String signature, java.util.ArrayList<Vote> votes)
          Creates new Ballot from a UUID, Signatures, and list of votes.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 byte[] getBytes()
          Returns the Ballot in binary format as a byte array.
 java.lang.String getID()
          Returns this Ballot's (user) UUID
 java.lang.String getRoot()
          Returns the root hash of this ballot.
 java.lang.String getSignature()
          Returns this Ballot's signature.
 java.lang.String getSignatureRoot()
          Returns the signature root hash of this ballot.
 java.util.ArrayList<Vote> getVotes()
          Returns the Votes contained in this Ballot as an ArrayList.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION

public static final byte VERSION
This class' Ballot version

See Also:
Constant Field Values

version

private byte version

id

private java.lang.String id

votes

private byte[] votes

signature

private java.lang.String signature

signatureRoot

private java.lang.String signatureRoot

root

private java.lang.String root

bytes

private byte[] bytes
Constructor Detail

Ballot

public Ballot(java.lang.String id,
              java.lang.String signature,
              java.util.ArrayList<Vote> votes)
Creates new Ballot from a UUID, Signatures, and list of votes. This constructor is mainly used for demonstration or testing purposes because Election Applications create new Ballots. Nodes and Blocks only create Ballots from binary data.

Parameters:
id - UUID of Ballot signer (User who cast this Ballot)
signature - Signature on this ballot generated using user's private ECDSA key
votes - List of Votes on this Ballot

Ballot

public Ballot(byte[] binary)
Initializes Ballot from binary data as a byte array. This constructor is used by Nodes and Blocks to load Ballots.

Parameters:
binary - Byte array representing this Ballot
Method Detail

getID

public java.lang.String getID()
Returns this Ballot's (user) UUID

Returns:
UUID as a 16-digit hexadecimal String

getSignature

public java.lang.String getSignature()
Returns this Ballot's signature. Used for Ballot authentication by the Node.

Returns:
Signature as a 72-digit hexadecimal ECDSA signature

getSignatureRoot

public java.lang.String getSignatureRoot()
Returns the signature root hash of this ballot. Used for Ballot authentication by the Node.

Returns:
Signature root as a 32-digit hexadecimal hash digest

getRoot

public java.lang.String getRoot()
Returns the root hash of this ballot. Used to identify this Ballot in Inventory requests and in the Node's memory.

Returns:
Ballot root hash (32-digit hexadecimal)

getBytes

public byte[] getBytes()
Returns the Ballot in binary format as a byte array.

Returns:
Byte array representing this Ballot

getVotes

public java.util.ArrayList<Vote> getVotes()
Returns the Votes contained in this Ballot as an ArrayList.

Returns:
ArrayList containing votes

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object