Skip to content

exec: the bjn_v1 notify token - #400

Merged
jaredLunde merged 1 commit into
mainfrom
jared/notify-token
Oct 19, 2026
Merged

jaredLunde merged 1 commit into
mainfrom
jared/notify-token

Conversation

@jaredLunde

Copy link
Copy Markdown
Contributor

Adds notify_token, the module that mints and verifies exec v1.4 bjn_v1 notify tokens exactly as the spec's "The notify token (bjn_v1)" defines them. It is the only code that makes or checks a token; nothing else builds the MAC input, holds the key or compares a tag.

  • NotifyKey::from_seal_secret derives K = HKDF-SHA256(seal secret, salt empty, info "bjn_v1 notify") from the secret's bytes as given (X25519 clamps only on use), and the kid hex(SHA-256("bjn_v1 kid" ‖ K)[0..4]).
  • mint(tenant, session, job) computes the session's own scope (JobScope::for_session) itself, so a replica cannot mint for another session's scope.
  • verify(token, tenant, session, scope, id) parses the exact grammar (three fields, lowercase-hex kid, 43-char canonical base64url mac), returns UnknownKid for any kid but its own, builds the length-prefixed MAC input from the request alone, and compares the full tag with verify_slice.
  • Verdict::refusal_status: malformed/bad_mac → 401, unknown_kid → 503.

Nothing calls it yet; the job_ended receiver in serve comes next.

Tests (tests/notify_token.rs): every vector in v1.4-token.json, the minted vector reproduced, both fixture kids derived from the raw and the StaticSecret forms, a change to every byte of the token and of each request field (over 10,000 variants), plus the_tag_is_compared_in_constant_time and mints_only_its_own_scope. A mutant that skips the canonical re-encode and the kid check fails three of them.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JimHGjsfk2Ktm5GxyZJKKk

@jaredLunde
jaredLunde enabled auto-merge October 18, 2026 23:25
@jaredLunde
jaredLunde added this pull request to the merge queue Oct 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 18, 2026
A module that mints and verifies v1.4 notify tokens exactly as the spec
defines them, and the only code that makes or checks one: K is
HKDF-SHA256 of the seal secret's bytes as given, the kid its
fingerprint, the MAC input length-prefixed, the tag HMAC-SHA256
compared with verify_slice, and the mac canonical unpadded base64url.

mint computes the session's own scope from the tenant and session, so a
replica cannot mint for another session. verify takes only the kid and
the tag from the token and everything else from the request.

tests/notify_token.rs runs every vector in v1.4-token.json, changes
every byte of the token and of each request field, and holds the named
notify_token checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JimHGjsfk2Ktm5GxyZJKKk
@jaredLunde
jaredLunde added this pull request to the merge queue Oct 19, 2026
Merged via the queue into main with commit e1e8e1b Oct 19, 2026
13 checks passed
@jaredLunde
jaredLunde deleted the jared/notify-token branch October 19, 2026 00:52
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