Skip to main content

Command Reference

This page lists how to run the audit image and all options of the seven commands of the audit: first audit-tally, then the commands that it runs. It also gives the format of the two files that you can write: scope.json and connections.json.

Common rules​

  • All options are long options: --option value. The commands have no short options.
  • --help shows the options of a command. --version is not available.
  • An option with the suffix -sha512 is a pin: the SHA-512 digest of a file, in 128 lowercase hexadecimal characters. Get the pin from the audit notes, not from the file.
  • An --output directory must not exist. The command makes it with access for your account only, and it does not overwrite a file.
  • All ballot audit commands use the exit statuses 0 to 4. See Read the Results.

In the tables, Required shows if you must give the option. Default in the description is the value that the command uses when you do not give the option.

The audit image​

The audit image restores the backups into copies inside the container, runs audit-tally on them and stops. See Run the Audit.

docker run --rm --network none -v <backups>:/backups:ro -v <output>:/output <image> \
--tally-session-id <ID> --public-key-sha512 <digest> \
--electoral-log-system-public-key <key> [-- <audit-tally option> ...]
Part of the commandDescription
--rmRemoves the container, with the copies, when it stops.
--network noneThe container has no network. The copies and the tools connect only on 127.0.0.1.
-v <backups>:/backups:roThe backups directory, read only. It holds hasura.dump, keycloak.dump, b3.dump, immudb.tar.gz, backup-digests.txt and, if the board stores messages in files, b3-blobs.tar.gz.
-v <output>:/outputAn empty directory for the results.
--tally-session-id <ID>The tally ID, from the election authority.
--public-key-sha512 <digest>The public key hash, from the election authority.
--electoral-log-system-public-key <key>The electoral log system public key, from the election authority.
-- <option> ...More options of audit-tally, for example --statement-timeout-seconds 600.

backup-digests.txt has one line for each backup: its SHA-512 digest, two spaces and its file name, as shasum -a 512 writes it. The ImmuDB archive holds the data directory, or one directory that holds it.

The command gives audit-tally the options --connections, --immudb-server-url, --immudb-username, --b3-server-url, --output and, if there is a blob archive, --b3-blob-root. It returns the exit status of audit-tally, and shows it in its last line, for example ballot-audit: exit status 0 (all steps passed).

Do not repeat the image-controlled options after --. At the reviewed revision, --electoral-log-export conflicts with the image's fixed ImmuDB option. These conflicts cause a usage error after restoration. Use the image's shell form to run a command separately when you need those options.

Two other forms:

CommandDescription
docker run --rm -it --network none -v <backups>:/backups:ro -v <output>:/output <image> shellRestores the copies and opens a shell in /output, to run one command at a time. The copies stop when you leave the shell.
docker run --rm <image> helpShows how to run the audit.

In the container, the copies use these addresses:

CopyAddress
Hasura, Keycloak, B3127.0.0.1:5432, databases hasura_copy, keycloak_copy and b3_copy
ImmuDBhttp://127.0.0.1:3322
B3 serverhttp://127.0.0.1:50051

audit-tally​

Audits all areas and contests of one tally. It reads the tally from the Hasura copy, makes one scope for each area and contest, and runs the other six commands. See Run the Audit.

OptionRequiredDescription
--connections <file>YesThe connections file. See connections.json.
--tally-session-id <ID>YesThe tally ID, from the election authority. Use lowercase.
--public-key-sha512 <digest>YesThe public key hash, from the election authority.
--electoral-log-system-public-key <key>YesThe electoral log system public key, from the election authority.
--immudb-server-url <url>Yes, if you do not give --electoral-log-exportThe loopback address of the restored ImmuDB, for example http://127.0.0.1:43322. Give it with --immudb-username.
--immudb-username <user>With --immudb-server-urlThe read-only ImmuDB user.
--immudb-password-env <variable>NoThe name of the environment variable that holds the ImmuDB password. Default: BALLOT_AUDIT_IMMUDB_PASSWORD.
--electoral-log-export <directory>Yes, if you do not give --immudb-server-urlAn existing directory from export-electoral-log of the full election event. The command uses it and does not read ImmuDB.
--b3-server-url <url>NoThe address of the B3 server on the B3 copy, for example http://127.0.0.1:50051. Without it, the Braid verifier does not run and the audit is incomplete.
--braid-verify <file>NoThe Braid verifier. Default: verify in the directory of audit-tally.
--b3-blob-root <directory>NoThe restored B3 blob directory. Give it when the bulletin board stores messages in files.
--statement-timeout-seconds <n>NoThe time limit of each database query, in seconds. The minimum is 1. Default: 120.
--output <directory>YesThe new directory for all files of the audit.

The command runs export-electoral-log, export-ballot-audit, prepare-ballot-audit, ballot-audit and audit-cast-history from its own directory. It gives each command the pins of the files that the earlier steps wrote. It gives prepare-ballot-audit the cast-vote history and the saved mapping, and ballot-audit the selection file. It runs export-electoral-log without --election-id.

It runs the Braid verifier once for the board, with --batches set to all batches of the tally and all batches with Ballots statements on the board. The verifier runs in the directory braid.

Output files: tally-plan.json, audit-record.json, public-summary.json and one directory for each scope, for the histories and for the Braid verifier. See File Reference.

export-ballot-audit​

Reads the restored Hasura, Keycloak and B3 copies in read-only transactions and writes the evidence of the scope. It checks the scope against the saved tally. See Export the Evidence.

OptionRequiredDescription
--scope <file>YesThe scope file. See scope.json.
--scope-sha512 <digest>YesThe pin of the scope file.
--connections <file>YesThe connections file. See connections.json. Only your account can have access to it.
--b3-blob-root <directory>NoThe restored B3 blob directory. Give it when the bulletin board stores messages in files.
--statement-timeout-seconds <n>NoThe time limit of each database query, in seconds. The minimum is 1. Default: 120.
--output <directory>YesThe new directory for the evidence.

Output files: scope.json, cast-votes.json, eligible-voters.json, board-messages.json, cast-vote-history.json, saved-mapping.json, keycloak-source.json, eligibility-reasons.json, board-source.json and acquisition.json.

export-electoral-log​

Reads the signed cast-vote records of an election event from the restored ImmuDB copy in a read-only transaction. See Export the Evidence.

OptionRequiredDescription
--server-url <url>YesThe loopback address of the restored ImmuDB, for example http://127.0.0.1:43322.
--database <name>YesThe electoral log database. Its name is the board name of the scope.
--username <user>YesThe read-only ImmuDB user.
--password-env <variable>NoThe name of the environment variable that holds the password. Do not give the password itself. Default: BALLOT_AUDIT_IMMUDB_PASSWORD.
--election-event-id <ID>YesThe election event of the records.
--election-id <ID>NoExports the records of one election only. Do not use it when you check the cast-vote history.
--output <directory>YesThe new directory for the electoral log.

Output files: electoral-log.json and electoral-log-provenance.json.

prepare-ballot-audit​

Selects the ballots that the tally must count and writes the audit bundle. It reads only files. See Prepare the Audit Bundle.

OptionRequiredDescription
--scope <file>YesThe scope file from the export: postgres-export/scope.json.
--scope-sha512 <digest>YesThe pin of the scope file.
--cast-votes <file>Yescast-votes.json from the export.
--cast-votes-sha512 <digest>YesThe pin of cast-votes.json.
--eligible-voters <file>Yeseligible-voters.json from the export.
--eligible-voters-sha512 <digest>YesThe pin of eligible-voters.json.
--board-messages <file>Yesboard-messages.json from the export.
--board-messages-sha512 <digest>YesThe pin of board-messages.json.
--electoral-log <file>Yeselectoral-log.json from the electoral log export.
--electoral-log-sha512 <digest>YesThe pin of electoral-log.json.
--cast-vote-history <file>Yes, if you do not give --without-cast-vote-historycast-vote-history.json from the export. Give it with its pin.
--cast-vote-history-sha512 <digest>With --cast-vote-historyThe pin of cast-vote-history.json.
--without-cast-vote-historyNoSkips the history checks. You cannot use it with --cast-vote-history. Do not use it in an audit. Default: Off.
--saved-mapping <file>Nosaved-mapping.json from the export. Give it with its pin. The command then compares the selection with the counts of the saved tally.
--saved-mapping-sha512 <digest>With --saved-mappingThe pin of saved-mapping.json.
--output <directory>YesThe new directory for the audit bundle.

Output files: manifest.json, configuration.borsh, cast-votes.json, messages.json, electoral-log.json, anchors.json, provenance.json and selection.json.

CAUTION

Do not use --without-cast-vote-history in an audit. Without the history, the command cannot detect a removed revote or a changed vote order.

ballot-audit​

Checks the audit bundle a second time, independently of the preparation, and looks up a receipt. It writes the report to the standard output. See Audit the Bundle.

OptionRequiredDescription
--manifest <file>Yesmanifest.json from the bundle.
--manifest-sha512 <digest>YesThe pin of the manifest, from the audit notes.
--cast-votes <file>Yescast-votes.json from the bundle.
--configuration <file>Yesconfiguration.borsh from the bundle.
--configuration-sha512 <digest>YesThe pin of the configuration, from the audit notes.
--messages <file>Yesmessages.json from the bundle.
--electoral-log <file>Yeselectoral-log.json from the bundle.
--ballot-id <receipt>NoLooks up one receipt. The command still checks all ballots.
--selection <file>Noselection.json from the bundle. With it, the lookup reports stored reason labels for receipts absent from the selected inputs.

audit-cast-history​

Compares all stored ballots of the election with the signed records of the electoral log. It writes the report to the standard output. See Check the Cast-Vote History.

OptionRequiredDescription
--scope <file>YesThe scope file. The command uses only the tenant, the election event, the election and the system public key.
--scope-sha512 <digest>YesThe pin of the scope file.
--cast-vote-history <file>Yescast-vote-history.json from the export.
--cast-vote-history-sha512 <digest>YesThe pin of cast-vote-history.json.
--electoral-log <file>Yeselectoral-log.json of the full election event.
--electoral-log-sha512 <digest>YesThe pin of electoral-log.json.
--ballot-id <receipt>NoShows only the groups of this receipt in the report. The command still checks the full history.

verify (Braid)​

Checks signatures, configuration, public keys, mix evidence and references in published plaintext records. Its decryption routine checks proofs and recomputes plaintexts when it runs. See Versions for the decryption completion requirement. It reads the board through the B3 server. See Verify the Bulletin Board.

OptionRequiredDescription
--server-url <url>YesThe address of the B3 server, for example http://127.0.0.1:50051.
--board <name>YesThe board name of the scope.
--batches <n,n,...>NoThe batches that must pass, separated by commas. The check fails if a batch in the list is not verified, or if a batch that is not in the list is verified. Give all batches of the board.
--ballot-hash <hash>NoNot available. The verifier does not use it.

scope.json​

The scope file tells the commands which tally, election, area and contest to audit, and which keys to trust. audit-tally writes one for each scope. You write it only when you run each step separately. All fields are required. See Get the Scope and the Pins.

FieldValue
format_version1
scope.tenant_idThe tenant ID.
scope.election_event_idThe election event ID.
scope.election_idThe election ID.
scope.area_idThe area ID.
scope.tally_session_idThe tally ID.
scope.tally_session_contest_idThe ID of the row of the tally for this area and contest.
scope.board_nameThe name of the event board.
scope.contest_idThe contest ID, or null for a ballot that encrypts all contests together.
scope.base_batchThe base batch of the area and contest.
scope.policyunweighted, weighted or delegated.
scope.public_key_sha512The public key hash, from the election authority.
scope.electoral_log_system_public_keyThe electoral log system public key, from the election authority.
batchesThe list of batches of the scope.

Use lowercase IDs. Do not change the file after you record its pin.

connections.json​

The connections file tells audit-tally and export-ballot-audit how to connect to each restored copy. See Restore the Database Copies.

FieldValue
format_version1
hasura, keycloak, b3One object for each database copy.
<copy>.connection_stringA PostgreSQL connection string to a loopback address, for example host=127.0.0.1 port=55432 dbname=hasura_copy user=ballot_audit_reader password=<password>. A host name, a remote address or sslmode=require is refused.
<copy>.restore_referenceThe identity and the digest of the backup of this copy. The export writes it in acquisition.json.

The commands refuse a field that is not in this list. Only your account can have access to the file: run chmod 600 connections.json.