def getPublicKey(ballot): # Get the public key 'n' publicKeyResponse = geth.callFunction(ballot.address, 'getPublicKeyN')['result'] publicKeyN = geth.responseToPublicKey(publicKeyResponse) # Get the public key 'g' publicKeyResponse = geth.callFunction(ballot.address, 'getPublicKeyG')['result'] publicKeyG = geth.responseToPublicKey(publicKeyResponse) # Return a public key object return crypto.PublicKey(publicKeyN, publicKeyG)
def getVotes(ballot): # Get the vote values for the selected ballot votesResponse = geth.callFunction(ballot.address, 'getVotes')['result'] voteValues = geth.responseToVoteValues(votesResponse) # Get the candidate count candidateCount = getCandidateCount(ballot) # Initalise the votes array votes = [] # Loop through each set of votes for index in xrange((len(voteValues) / 8) / candidateCount): # Add a row for this set of votes votes.append([]) # Loop through each candidate for candidateIndex in xrange(candidateCount): # Initalise this vote value voteValue = '' # Loop through each value for this candidate for valueIndex in xrange(8): # Compile this vote voteValue += str(voteValues[((index * (candidateCount * 8)) + (candidateIndex) * 8) + valueIndex]) # Add the vote value to the vote array votes[index].append(geth.hexToNumber(voteValue)) # Return the votes array return votes
def getVoters(ballot): votersResponse = geth.callFunction(ballot.address, 'getVoters')['result'] return geth.responseToVoters(votersResponse)
def getCandidateCount(ballot): candidateCountResponse = geth.callFunction(ballot.address, 'getCandidateCount')['result'] return geth.responseToInteger(candidateCountResponse)
def getCandidates(ballot): candidatesResponse = geth.callFunction(ballot.address, 'getCandidates')['result'] return geth.responseToCandidates(candidatesResponse)
def getDescription(ballot): descriptionResponse = geth.callFunction(ballot.address, 'getDescription')['result'] return geth.responseToString(descriptionResponse)
def getTitle(ballot): titleResponse = geth.callFunction(ballot.address, 'getTitle')['result'] return geth.responseToString(titleResponse)