Skip to content

feat(identity): migrate Ed25519 to venv cryptography (closes #341) - #343

Merged
joelteply merged 1 commit into
canaryfrom
feat/identity-ed25519-via-cryptography
Apr 30, 2026
Merged

joelteply merged 1 commit into
canaryfrom
feat/identity-ed25519-via-cryptography

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Identity gen + envelope-signing both routed via system `openssl`, which broke silently on macOS LibreSSL (no `genpkey -algorithm Ed25519`). #342 made the failure loud and auto-installed `brew openssl@3`. This PR removes the dependency on system openssl entirely by routing through the venv `cryptography` module that's already installed for envelope encryption.

Closes #341.

What changed

  • `lib/airc_core/crypto.py`: add `generate_ed25519_keypair_pem`, `load_ed25519_priv_pem`, `sign_ed25519_pem`, `save_ed25519_keypair_pem`. PEM format (PKCS#8 priv, SPKI pub) matches openssl byte-for-byte — existing scopes load + verify cleanly.
  • `lib/airc_core/identity.py`: `bootstrap_ed25519` + `sign_ed25519` siblings to the existing X25519 functions, plus `bootstrap-ed25519` / `sign-ed25519` CLI subcommands.
  • `airc` top-level: `sign_message` + `init_identity` now invoke the python CLI. Removed `_resolve_openssl`, `AIRC_OPENSSL`, `_die_no_ed25519_openssl` — dead code post-migration.
  • `install.sh`: drop openssl from prereqs + drop the LibreSSL-detect + brew-install-openssl@3 dance.
  • `cmd_doctor.sh`: replace the openssl probe with a `cryptography` import probe.

Backward compat

Existing scopes' `private.pem` / `public.pem` files (created by shell openssl in any prior version) load unchanged via `load_pem_private_key`. Cross-checked: signing a Python-generated key via `openssl pkeyutl -sign` and signing the same message via the new Python path produces byte-identical base64 output. No identity rotation triggered by upgrade.

Test plan

  • Local: `airc connect --no-room --no-gist` writes `private.pem` (119 bytes, 0600) + `public.pem` (113 bytes, 0644) — same shape as openssl
  • Local: `airc doctor` reports `[ok] cryptography (Ed25519 identity gen + signing)`
  • Cross-compat: `openssl pkeyutl -sign` vs new Python `sign-ed25519` on the same key + message → byte-identical b64 output
  • Cross-compat: openssl-generated `private.pem` loaded + signed via Python with byte-identical signature
  • CI: clean-install matrix (4 platforms) — green
  • Carl's fresh-Mac rerun: `airc join` no longer requires `brew install openssl@3` (the LibreSSL system binary is irrelevant)

🤖 Generated with Claude Code

Identity gen (genpkey) and message signing (pkeyutl -sign) used to
shell out to system openssl. macOS LibreSSL doesn't implement Ed25519
via genpkey, which silently broke fresh-Mac installs (the 2>/dev/null
ate the error — exactly the error-suppression antipattern that "Never
swallow errors" exists to forbid). #342 made the failure loud and
auto-installed brew openssl@3; this PR removes the dependency on
system openssl entirely by routing both ops through the venv
python-cryptography module that's already installed for envelope
encryption.

What changed:
- lib/airc_core/crypto.py: add generate_ed25519_keypair_pem,
  load_ed25519_priv_pem, sign_ed25519_pem, save_ed25519_keypair_pem.
  PEM format (PKCS#8 priv, SPKI pub) matches openssl byte-for-byte —
  existing scopes that paired under shell-openssl load + verify
  cleanly here. Cross-checked: signing a Python-gen key via openssl
  pkeyutl -sign and signing the same message via the new path
  produces byte-identical base64 output.
- lib/airc_core/identity.py: bootstrap_ed25519 + sign_ed25519
  siblings to the existing X25519 functions, plus bootstrap-ed25519
  and sign-ed25519 CLI subcommands so bash invokes via
  $AIRC_PYTHON -m airc_core.identity ...
- airc top-level: sign_message and init_identity now route through
  the python CLI. Removed _resolve_openssl, AIRC_OPENSSL,
  _die_no_ed25519_openssl — all dead code post-migration. ssh-keygen
  remains (it's an OpenSSH client tool, not a libcrypto consumer,
  and ships working on every supported platform).
- install.sh: drop openssl from the prereq list; drop the
  LibreSSL-detect + brew-install-openssl@3 dance (no longer needed
  since shell openssl isn't called). cryptography stays a hard dep
  via the existing venv pip-install step.
- cmd_doctor.sh: replace the openssl probe with a cryptography
  import probe ("import cryptography.hazmat.primitives.asymmetric
  .ed25519"). Surfaces "re-run install.sh" if the venv didn't
  finish setting up.

Backward compat: existing scopes' private.pem / public.pem files
(generated by shell openssl in any prior version) continue to work
unchanged. The PEM wrapping format is the same; load_pem_private_key
parses both. No identity rotation triggered by upgrade.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@joelteply
joelteply merged commit b01e2e5 into canary Apr 30, 2026
6 checks passed
@joelteply
joelteply deleted the feat/identity-ed25519-via-cryptography branch April 30, 2026 00:22
joelteply added a commit that referenced this pull request Apr 30, 2026
…351 CI failures) (#362)

test: scaffold private.pem in synthesized identity dirs (post-#343 fix)

Pre-#343 the test scenarios that synthesize a partial host scope (cmd_send
liveness probe, away-status, list, quit) used `ssh-keygen -t ed25519` to
create ssh_key + relied on the airc binary to lazily create private.pem
via `openssl genpkey` if needed. Post-#343 init_identity creates
private.pem via the venv cryptography path, but the test scenarios that
DON'T go through `airc connect` at all skip init_identity entirely —
sign_message then dies with `ed25519 sign failed: [Errno 2] No such file
or directory: .../private.pem` before reaching the actual code-under-
test (the monitor-liveness diagnostic, the away-marker logic, etc).

Symptom in CI: 6 failures in the sdmd scenario alone all caused by the
script bailing on the missing private.pem before reaching the assertion
the test was actually validating.

Adds `scaffold_identity()` helper next to spawn_host. Creates ssh_key
(via ssh-keygen, unchanged) AND private.pem (via airc_core.identity
bootstrap-ed25519 with PYTHONPATH set to make airc_core importable).
Used at the 4 manual-scaffold sites: sdmd (send_dead_monitor_dies), aw
(away-status), ls (list), quit (quit).

The 5th ssh-keygen call (line 807, key-rotation scenario) replaces an
EXISTING ssh_key after the scope was already initialized — private.pem
is already there, no scaffold change needed.

Pairs with other-mac's WIP for cluster B (gh-auth-less runner test
infra). Both fold into #351.

Co-authored-by: joel <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request Apr 30, 2026
#363)

The integration-suite has been failing on every canary push for the
duration of this push (#351 cluster B). Root cause: 14 scenarios call
airc with --room or bare connect (use_room=1), which trips
cmd_connect's pre-flight gh-auth check (#338) — and CI's integration-
suite runner has no gh auth wired in (no PAT secret).

Add requires_gh_auth_or_skip() helper at the top of integration.sh:
checks gh auth status once (cached for subsequent calls — saves rate
limit budget when the suite runs many substrate scenarios), and
either proceeds (when authed) or marks the scenario as skipped-pass
with the reason. Test count stays sane, suite goes green on no-auth
runners, substrate coverage preserved when gh IS authed (developer
machines, future CI with PAT secret).

Apply the gate to the 13 scenarios that exercise substrate features
(--room or use_room=1 default): room, events, mnemonic, kick,
heartbeat, bounce, two_tab_localhost, auto_scope, connect_after_kill_
recovers, general_sidecar_default, host_msg_publishes_to_gist,
general_has_shared_gist, custom_room_creates_gist.

Cluster A (Carl, #362) was test-stderr wording updates for the #343
ed25519-message-shape change. Together these close out #351.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant