Example #1
0
def gen_vote(election, i, ed25519_node_keys):
    (input_i, votes_i, key_i) = to_inputs(election, i, ed25519_node_keys)
    election_pub_key = Election.to_public_key(election.id)
    return Vote.generate([input_i],
                         [([election_pub_key], votes_i)],
                         election_id=election.id)\
        .sign([key_i.private_key])
Example #2
0
def generate_election(b, cls, public_key, private_key, asset_data):
    voters = cls.recipients(b)
    election = cls.generate([public_key], voters, asset_data,
                            None).sign([private_key])

    votes = [
        Vote.generate([election.to_inputs()[i]],
                      [([Election.to_public_key(election.id)], power)],
                      election.id) for i, (_, power) in enumerate(voters)
    ]

    return election, votes