CVR Anonymization Tool
Software to anonymize Cast Vote Records (CVR) files to meet Colorado's requirement that styles with fewer than 10 ballots per style must be anonymized to protect voter privacy.
Background
This tool addresses the requirement from Colorado Open Records Act (C.R.S. 24-72-205.5) which requires counties to cover or redact before "making available for public inspection" a voted ballot if there are fewer than 10 instances of the ballot's style in the election.
The anonymization process aggregates rare styles (those with fewer than 10 ballots) together to meet the minimum threshold while preserving ballot anonymity for Risk-Limiting Tabulation Audits.
Status
This is alpha-quality software. Use at your own risk.
Legal and Research Foundation
- Colorado Open Records Act (C.R.S. 24-72-205.5): Requires anonymization of ballots with fewer than 10 instances per style
- Colorado Risk-Limiting Tabulation Audit: CVRs must be available for public audit purposes while preserving ballot anonymity
- Colorado Risk-Limiting Tabulation Audit: Preserving Anonymity of Cast Vote Record (Branscomb et al., March 9, 2018) - Endorsed by John McCarthy, Neal McBurnett, Harvie Branscomb, Ron Rivest, Philip Stark
Documentation
- specification.md: Detailed specification of requirements, algorithms, and implementation details
- AGENTS.md: Guidelines for AI agent interactions with this codebase
Tools
anonymize_cvr.py
Anonymizes CVR files by aggregating rare styles to meet the 10-ballot minimum threshold. Reads CVR exports in CSV format.
Usage:
python3 anonymize_cvr.py input.csv output.csv
python3 anonymize_cvr.py input.csv output.csv --min-ballots 15
python3 anonymize_cvr.py --check input.csv
python3 anonymize_cvr.py input.csv output.csv --no-redact-on-precinct
Features:
- Reads CSV CVR exports
--checkreports whether redaction is needed, without writing output- Redacts any contest present on fewer than 10 cards in the whole file, which no aggregation can
protect: its columns stay, every cell in them is emptied, and the aggregation line says
Redactedin them (adding an aggregation line that stands for no ballots if there is none). ReadRedactedas unknown, never as zero - Treats a ballot as rare when its
BallotTypelabel (or--stylecollabel) is carried by fewer than 10 ballots, since the label alone picks it out;--drop-ballottypedrops the column instead - Combines all rare styles (< 10 ballots) into a single aggregation
- Ensures at least 10 ballots per contest in the aggregation
- Adds contrasting votes to prevent unanimous/near-unanimous patterns
- Redacts by precinct by default: a ballot style with fewer than the minimum ballots within a precinct is treated as rare, so those ballots are redacted, and the PrecinctPortion column is kept. With
--no-redact-on-precinctthe PrecinctPortion column is removed instead, and precincts are not used to decide which ballots are rare. That is safe only if you will never release ballot images that show precinct information (on the ballot's header or barcode). The precinct portion is read from each ballot and may be a real precinct, a split, or a ballot style, depending on how the county set up the election - Removes CountingGroup: the CountingGroup column, which shows how a ballot was cast, is removed from the output. In Colorado this is required: CORLA rejects a CVR that has this column, and the Secretary of State's guidance releases the CVR without it
- Preserves BallotType: BallotType is preserved in every row, including redacted rows, except the aggregation line, where it is "AGGREGATED". The tool warns if BallotType varies for ballots with the same contest pattern, which could indicate information leakage. BallotType values are displayed in the style mapping output
- Computes descriptive style names based on contest patterns
- Detects information leakage when different CVR style names map to the same contest pattern
- Automatic tally verification ensures vote totals match between original and anonymized CVR
- Comprehensive aggregation statistics showing:
- Totals after including all rare styles (with ballot counts, vote counts, and undervotes)
- Contests needing additional ballots (with reasons: had X, needed Y more to reach Z)
- Contests needing balancing (unanimous/near-unanimous patterns)
- Total extra CVRs added to aggregate
- Final aggregate totals (with ballot counts, vote counts, and undervotes)
- Style mapping output includes BallotType information for each CVR style
Options:
-
--check,-c: report whether redaction is needed, without writing output -
--min-ballots N: minimum ballots required per style or precinct (default: 10, and at least 2) -
--redact-on-precinct: the default. Keep the PrecinctPortion column and treat a ballot style with fewer than the minimum ballots within a precinct as rare, so its ballots are redacted -
--no-redact-on-precinct: remove the PrecinctPortion column instead, judging rarity by ballot style alone. Use only if you will never release ballot images that show precinct information (on the ballot's header or barcode): a ballot whose style is rare only within its precinct stays visible, and--redacted-listlists it so the precinct can be hidden on its image -
--stylecol N: column index (0-based) of a named style field, if present -
--no-contest-balancing(not recommended): don't enforce contest balancing, which requires, for each contest on the redacted ballots, that:- at least
--min-ballotsof the redacted ballots carry it, and - their votes in it are not unanimous or nearly so.
Only the total of
--min-ballotsballots in the aggregate is then enforced. A contest carried by only a few of the rare ballots then has its votes for those ballots shown in the aggregation line. The report lists any contests this leaves exposed - at least
-
--keep-rare-contests: do not redact contests present on fewer than--min-ballotscards -
--drop-ballottype: drop theBallotTypecolumn, and the--stylecolcolumn if given, from the output, instead of redacting the ballots whose label is carried by fewer than--min-ballotsballots. Either remedy protects only the CVR: a label printed on the ballot also shows on any released ballot image, which needs redacting too -
--force: replace the output file, and the--redacted-listfile, if they already exist. Without it an existing file is left alone and the run stops, and the output is never allowed to be the input file itself -
--report FILENAME: also save a report of the run in FILENAME: the version, the time, the input's name and SHA-256, the options, the files written, and everything the run printed. The window always saves one, as<input>-report.txtbeside the redacted CVR (<input>-redacted.csv) and the ballot list (<input>-redacted-ballots.txt), in the folder chosen -
--redacted-list FILENAME: write to FILENAME every ballot whose image also needs redaction: a header rowImprintedId,Reason, then one row per ballot with its reason: "redacted"; "visible but carried a redacted contest"; or, when the precinct or ballot-type column is removed, "visible but rare within its precinct portion (column removed)" or "visible but its ballot-type label is rare (column removed)" -
--version: print the version
Example Workflow
-
Check whether a CVR file needs redaction:
python3 anonymize_cvr.py --check original_cvr.csv
-
Anonymize the CVR file:
python3 anonymize_cvr.py original_cvr.csv anonymized_cvr.csv
-
Verify that vote totals are preserved:
python3 verify_redaction.py original_cvr.csv anonymized_cvr.csv
Aggregation Approach
The anonymization tool uses a balance-focused approach:
- Redact contests too rare to protect: A contest on fewer than 10 cards county-wide is set
aside before rare styles are found, so a ballot rare only because of it stays visible. Its cells
are emptied and the aggregation line says
Redactedin its columns. Images of those ballots still show the contest and need redacting as well - Combine all rare styles: All ballots from rare styles (< 10 ballots), and all ballots whose
BallotTypelabel is carried by fewer than 10 ballots, are combined into a single aggregation - Meet minimum thresholds: If needed, ballots are borrowed from common styles to ensure:
- At least 10 ballots total in the aggregation
- At least 10 ballots per contest in the aggregation
- Balance votes: The tool checks for unanimous or near-unanimous patterns (all but 2 votes for the same candidate) and adds contrasting votes from common styles to break these patterns
- Anonymize identifying fields: CountingGroup is removed from the output. PrecinctPortion is kept, with rare style/precinct combinations grouped (the default), or removed with
--no-redact-on-precinct. BallotType is preserved in non-aggregated rows (it should only reflect contest pattern, not additional identifying information). Note that if this sort of information is visible on the printed ballot, that should be taken into account when procedures for releasing ballot images are designed. - Verify tallies: Before delivering the redacted CVR, vote tallies are automatically verified to match the original
This approach minimizes the number of ballots that need to be redacted while ensuring both anonymity and statistical balance.
Style Analysis
The anonymization tool automatically:
- Computes descriptive style names based on contest patterns (format:
<n><R|S><m>where n=contest count, R=rare/S=common, m=style number) - Maps CVR style names to descriptive style names, including BallotType information for each style
- Detects information leakage when different CVR style names or BallotType values are used for ballots with the same contest pattern
- Displays detailed aggregation statistics including totals (with ballot counts, vote counts, and undervotes), contests needing balancing, and extra CVRs added
Requirements
- Python 3.9 or later
- Standard library only (csv, collections, typing); no third-party packages are needed
tkinteronly for the optional graphical interface, which starts when the program is run with no command-line arguments. The command line works without it.
To install it as two commands, anonymize_cvr and anonymize_cvr_gui (the window), from PyPI:
pipx install anonymize_cvr. Releases and their checksums are on the
releases page.
Testing
python3 run_tests.py runs the test cases: it generates synthetic CVRs, redacts them, and checks the
results. If node is installed it also runs tests/web_matches_python.js, which runs the same
files through the web version (anonymize_cvr.html) and checks that it writes the same output.
make lint runs mypy and black. GitHub runs both automatically on every push and pull request (see
.github/workflows/ci.yml), on Python 3.9 and 3.12, and shows a green check or a red X on the pull
request.
License
Licensed under the Apache License, Version 2.0. See LICENSE.
Metadata
Release files for anonymize-cvr 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| anonymize_cvr-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for anonymize_cvr-0.4.0-py3-none-any.whl |
Release files / anonymize_cvr-0.4.0-py3-none-any.whl
| Download URL | anonymize_cvr-0.4.0-py3-none-any.whl |
|---|---|
| Size | 48.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
da2de50da10a9a0a9c74a5146c379fbc53f1405b320f796fdcfa578f8f5798fb
|
|
BLAKE2b-256 checksum How to use checksums |
45099bade06aa50f915d1fe787b46df0fea2113115c5432c324f2107807cefdb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for anonymize-cvr 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
1 file in this release has been uploaded with provenance metadata.
Attestation for anonymize_cvr-0.4.0-py3-none-any.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.