URL to the Assembly Voting backend server, specific for election.
Initializes the client with an election config. If no config is provided, it fetches one from the backend.
Allows injection of an election configuration for testing purposes
Allows injection of a keypair to support automatic testing
Returns undefined if succeeded or throws an error
Should be called when a voter chooses digital vote submission (instead of mail-in).
Will attempt to get backend services to send an access code (one time password, OTP) to voter's email address.
Should be followed by validateAccessCode to submit access code for validation.
Voter ID that preserves voter anonymity.
where the voter expects to receive otp code.
Returns undefined or throws an error.
Should be called after requestAccessCode.
Takes an access code (OTP) that voter received, uses it to authorize to submit votes.
Internally, generates a private/public key pair, then attempts to authorize the public key with each OTP provider.
Should be followed by {@link AVClient.constructBallotCryptograms | constructBallotCryptograms}.
An access code string.
Returns undefined if authorization succeeded or throws an error
Compatible with new DBB structure (WIP)
Registers a voter
undefined or throws an error
Should be called after validateAccessCode.
Encrypts a ballot-selection (CVR) and generates vote cryptograms.
Example:
const client = new AVClient(url);
const cvr = { '1': 'option1', '2': 'optiona' };
const trackingCode = await client.constructBallotCryptograms(cvr);
Example of handling errors:
try {
await client.constructBallotCryptograms({});
} catch(error) {
if(error instanceof AvClientError) {
switch(error.name) {
case 'InvalidStateError':
console.log("State is not valid for this call");
break;
case 'NetworkError':
console.log("It's a network error");
break;
default:
console.log('Something else was wrong');
}
}
}
Where '1'
and '2'
are contest ids, and 'option1'
and 'optiona'
are
values internal to the AV election config.
Should be followed by either spoilBallot or castBallot.
Returns the ballot tracking code. Example:
'5e4d8fe41fa3819cc064e2ace0eda8a847fe322594a6fd5a9a51c699e63804b7'
Should be the last call in the entire voting process.
Requests that the previously constructed ballot is cast.
Returns the vote receipt. Example of a receipt:
{
previousBoardHash: 'd8d9742271592d1b212bbd4cbvobbe357aef8e00cdbdf312df95e9cf9a1a921465',
boardHash: '5a9175c2b3617298d78be7d0244a68f34bc8b2a37061bb4d3fdf97edc1424098',
registeredAt: '2020-03-01T10:00:00.000+01:00',
serverSignature: 'dbcce518142b8740a5c911f727f3c02829211a8ddfccabeb89297877e4198bc1,46826ddfccaac9ca105e39c8a2d015098479624c411b4783ca1a3600daf4e8fa',
voteSubmissionId: 6
}
Should be called when voter chooses to test the encryption of their ballot. Gets commitment opening of the digital ballot box and validates it.
Returns undefined if the validation succeeds or throws an error
Should be called when the voter has 'paired' the verifier and the voting app. Computes and encrypts the clientEncryptionCommitment and posts it to the DBB
Returns void if the computation was succesful
Purges internal data.
Should be called after spoilBallot. Gets the verifier public key from the DBB
Returns the pairing code based on the address of the verifier item in the DBB
Finds the ballot status corresponding to the given trackingcode. Also returns the activities associated with the ballot
base58-encoded trackingcode
Assembly Voting Client API
The API is responsible for handling all the cryptographic operations and all network communication with:
Expected sequence of methods being executed
Example walkthrough test