Readiness checks for the keypers of Shutter's Permanent Private Voting suite (shutter-network/shutter-governance-protocol).
Status: in development. The work is split into the milestones below, each defined in its own issue.
- The problem
- What's here now
- Prerequisites
- Check a keyper
- The check against the local set
- Run the tests
- Reproduce the gaps
- Milestones
- Licence
A keyper's /health endpoint says whether the process is up. It does not say whether the keyper can do its part in a vote. Several failures pass /health and go unnoticed until key generation or the vote count fails:
- A keyper restarts without its key share. It keeps answering
/healthwith200, and the vote count is abandoned when the count needs its share, as when a second keyper is also down. - One keyper of three loses its share. The vote still completes on the remaining shares, and
/healthstill answers200. Nothing raises an alarm: the coordinator logs warnings, and the keyper's/statusshows it holds no election, so the lost redundancy can go unnoticed until another keyper fails. - The coordinator identity is wrong. Nothing reports it until key generation fails.
- The clock is about five minutes off. The keyper does not finish bootstrapping.
Operators learn about these when a vote fails.
- The reproduction (M1).
repro/reproduces the four gaps above on a local set of three keypers and a coordinator, with the output of each saved. - The default check (M2).
check/check_keyper.pychecks a keyper from outside, with no secrets: its status, its announced key and address, its clock, and the elections it holds.check/demo.pyruns it against the local set from M1, andtests/holds its tests.
From outside, the default check sees three of the four gaps: a keyper that lost its key share, in both forms, until the election's result is published; and a clock that is off, as the keyper's Date header shows it. It does not see a wrong coordinator identity. The deep check and the restore test are the next milestones and are not here yet; see Milestones.
- Python 3.11 or later, the voting suite's own minimum. The reproduction, the check and its tests were run on Python 3.14.4.
- The voting suite's code. It is not published on PyPI, so
requirements.txtinstalls it from GitHub at commitd3fadc5, with itskeyperextra. Git is not needed. The archive is pinned by commit, not by a byte hash: GitHub keeps a commit archive's files the same but may change its compression, which would break a hash. - The Python packages in
requirements.txt, each pinned to the version the reproduction and the check were run with: Flask, Werkzeug, requests, cryptography, the suite's BLS12-381 and Ethereum libraries, pytest for the tests, and what they depend on.
python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements.txtInstalling needs access to GitHub and PyPI. The check needs to reach the keyper and the public API, and nothing else. Running the reproduction, the demo or the tests needs no network: everything talks over 127.0.0.1. The reproduction and the demo refuse any connection they make to another address, and a test fails if the check connects to any address but the two it was given. Fresh test keys are generated on every run, and the keypers' state lives in a temporary folder that is removed at the end (a failing test keeps its folder, so it can be looked at).
Run it from outside your network, against the keyper's public URL, with the URL of the deployment's public API and the keyper address you registered with the admin:
python check/check_keyper.py --url https://keyper.example.org \
--api-url https://vote.example.org --address 0x<your keyper address>Run it before the election is registered, after the key generation, and after any restart or restore. It reads the keyper's GET /status once and the public API's election records, and runs five checks:
| Check | What it checks |
|---|---|
status |
GET /status answers 200 with its five fields. |
pubkey-sig |
The announced encryption key's signature verifies against the address /status serves. The coordinator checks this signature before it bootstraps the keyper. |
address |
That address is the --address you registered. |
clock |
The answer's Date header is within 300 s of this machine's clock, the window in which the keyper accepts a bootstrap. |
elections |
/status lists every election the public API says this keyper must still hold a share for: a finalized key, this address in the committee, no result published yet. It also warns when such an election exists and the keyper is not bootstrapped. |
| Exit code | Meaning |
|---|---|
0 |
Ready: every check ran and passed. |
1 |
Not ready: a check failed. |
2 |
Needs attention: nothing failed, but a check was skipped or warned, or the arguments were wrong. |
It needs no secret and is read-only: it opens no key, state or env file, writes nothing, connects only to the two URLs given, ignores proxy settings, and does not follow redirects. Its output never holds a key, share or token. Each answer must arrive in full within --deadline seconds (default 30) and be at most --max-bytes long (default 8 MiB); --timeout (default 10) bounds each wait for data. python check/check_keyper.py --help lists the options.
What it cannot see from outside:
- The coordinator identity the keyper trusts. It is only in the keyper's environment, so a wrong one shows only when key generation fails. The deep check (M3) reads it.
- Whether the saved state would load. A lost share shows only once the keyper has restarted without it, and only until the election's result is published. The deep check reads the state files.
- A clock offset the
Dateheader does not carry. The keyper stamps its answers and checks a bootstrap with the same clock, so the header shows its offset. Behind a proxy that sets its ownDate, as nginx does by default, it is the proxy's clock that is checked.
check/demo.py runs the check against the local set from M1 (repro/committee.py, unchanged), with the public API's read surface served over the same data layer. It checks a ready keyper, then a keyper in each of M1's four states:
python check/demo.pyThe run takes about 20 seconds and ends with:
AS EXPECTED ready ready, exit code 0
AS EXPECTED restart-without-share 'elections' FAILED, exit code 1
AS EXPECTED lost-share-of-three 'elections' FAILED until the result is published, exit code 1
AS EXPECTED wrong-coordinator-identity not seen: ready, exit code 0 (needs the deep check)
AS EXPECTED clock-skew 'clock' FAILED at 305 s either way, exit code 1
| State | What the check reports | Saved output |
|---|---|---|
ready |
Every check passes, before and after the key generation. | log |
restart-without-share |
Keyper 2 fails elections: the API expects its share and /status lists no election. It also warns that keyper 2 is not bootstrapped. Keyper 3, which is down, fails status. |
log |
lost-share-of-three |
Keyper 2 fails elections before the count. Once the count has tallied on the two other shares and the result is published, the API expects no share and the check passes. |
log |
wrong-coordinator-identity |
Every check passes, before and after the failed key generation. The default check cannot see this gap. | log |
clock-skew |
Keyper 2 fails clock at 305 s ahead and 305 s behind, and passes at 295 s. M1's set shifts only the clock the keyper's bootstrap check reads, so the demo shifts keyper 2's Date header by the same amount, as a host whose clock is off does. Without that, the check passes, which the log also shows. |
log |
The exit code is 0 when every state gave the result above and 1 when one did not. To run one state, give its name, such as python check/demo.py clock-skew. The output holds no key, port or path, so it can be compared with the saved run; a clock line can differ by a second:
python check/demo.py | diff - check/logs/all.logpython -m pytestThe 84 tests take about two minutes. They run the check in its own process against keypers built from the suite's code on 127.0.0.1 (tests/keyper_committee.py) and stand-ins that answer badly. Each check has a test that fails on a broken keyper, and the ready keyper passes every check. Every run of the check is searched for each test key, share and token, in hex, decimal and base64, in what it printed, what it sent, and what any server received from it, and fails if it wrote a file, read the signing key or connected to any other address.
python repro/reproduce_gaps.pyThe run takes about 15 seconds. It prints what each reproduction did and saw, and ends with:
REPRODUCED restart-without-share
REPRODUCED lost-share-of-three
REPRODUCED wrong-coordinator-identity
REPRODUCED clock-skew
The exit code is 0 when every gap was reproduced and 1 when one was not. To run one gap, give its name, such as python repro/reproduce_gaps.py clock-skew. The output holds no key, port or path, so it can be compared line by line with the saved run:
python repro/reproduce_gaps.py | diff - repro/logs/all-gaps.logrepro/SETUP-NOTES.md lists every snag I hit following the suite's docs.
Every set has three keypers, any two of which can decrypt, and runs an election with two ballots whose totals are [6, 15, 0].
| Gap | What the run shows | Saved output |
|---|---|---|
restart-without-share |
Keyper 2 restarts on an empty state folder and keyper 3 is down at count time. Keyper 2 answers /health with 200; the count ends tally_abandoned, no result is published, and no decryption share is published. |
log |
lost-share-of-three |
Keyper 2 restarts on an empty state folder. It answers /health with 200; the count still ends tallied with [6, 15, 0], on 2 decryption shares instead of 3. The coordinator logs keyper 2's errors as warnings; keyper 2's /status shows bootstrapped=False and no elections. |
log |
wrong-coordinator-identity |
Keyper 2 trusts another coordinator's address. It answers /health with 200, refuses the bootstrap with 401, and the key generation ends dkg_failed when voting opens. |
log |
clock-skew |
Keyper 2's clock is 305 s ahead, then 305 s behind; the keyper accepts a bootstrap only within 300 s of its own clock. It answers /health with 200, does not bootstrap, and the key generation ends dkg_failed. At 295 s it bootstraps and the key is generated. |
log |
All four in one run: repro/logs/all-gaps.log.
The set is the voting suite's own keyper (build_keyper_app) and coordinator (AutoDKG) code, with its real cryptography, run in one process. Each keyper is served over HTTP on 127.0.0.1, and the coordinator bootstraps them, runs the key generation and drives the count over those HTTP calls, as the suite's own tests do. Three things are test doubles: the data layer is the suite's in-memory adapter, taking one call at a time, eligibility is the suite's stub issuer, and the election's clock is moved by hand. The keypers write to the data layer directly, not through the coordinator's relay as in a deployment. A keyper's wall clock is shifted by standing in for the time source in the suite's bootstrap module. This is not the suite's container stack (no Docker, Postgres or chain, and no TLS), and it is not a mock of the keyper. repro/committee.py sets it up.
| Milestone | Issue | ||
|---|---|---|---|
| M1 | Reproduce the gaps on a local three-keyper set | #1 | done |
| M2 | The default check, no secrets needed | #2 | this release |
| M3 | The deep check, inside the keyper container | #3 | coming |
| M4 | The restore test | #4 | coming |
| M5 | Install, docs and an operator checklist | #5 | coming |
| M6 | Feedback from operators | #6 | coming |
| M7 | Optional: a pointer from the suite's own operator docs | #7 | coming |
The checks:
- Default mode, no secrets needed (here now). Run from outside the keyper, it checks the keyper's status, its announced key and address against the deployment's public API, its clock, and the elections it holds. See Check a keyper.
- Deep mode (M3, coming). Run inside the keyper's container with
--deep, it also checks the coordinator identity, the stored state, and the key share for each election. - Restore test (M4, coming). Proves that a restored keyper still holds the share the vote count needs, and that a bad restore is caught: an empty folder, a backup from before key generation, or a missing secrets file.
- Read-only. It writes nothing, prints no key, share or token, and connects only to the keyper and the public API.
- Exit codes:
0ready,1not ready,2needs attention.
AGPL-3.0, the same licence as Shutter's voting suite.