Skip to content

Freebird uses RFC 9578 type-2 tokens with one-use admission

Freebird uses the RFC wire formats and adds a one-use admission rule. The implementation is experimental and not ready for production deployment.

Blind RSA supports public verification

RFC 9578 defines issuance and the token type. RFC 9474 defines blind RSA. RFC 9577 defines challenges and HTTP authentication. RFC 9576 defines the roles and privacy properties. Freebird sets deployment policy where the RFCs leave a choice and uses their wire formats unchanged.

The protocol uses the following rules for token encoding and key handling:

  • Token type 0x0002 uses publicly verifiable 2048-bit blind RSA as specified in RFC 9578 Section 6. RSABSSA-SHA384-PSS-Deterministic uses identity message preparation, SHA-384, MGF1-SHA-384, and a 48-byte PSS salt. Deterministic message preparation does not mean zero-salt PSS. Freebird does not support VOPRF or privately verifiable tokens.
  • Each request can yield at most one token. The 259-byte request is TokenRequest = uint16(0x0002) || uint8(truncated_token_key_id) || blinded_msg[256]. The response is TokenResponse = blind_sig[256]. The 354-byte token is Token = uint16(0x0002) || nonce[32] || challenge_digest[32] || token_key_id[32] || authenticator[256]. Require exact lengths and complete consumption. Reject trailing bytes.
  • The client blinds a 98-byte input that includes a fresh 32-byte nonce: 0x0002 || nonce || SHA256(serialized TokenChallenge) || SHA256(exact advertised RSA-PSS SPKI bytes). The blinded request exposes neither the nonce nor the challenge to the Issuer. Hash the exact RFC 9578 Section 6.5 SPKI bytes with SHA-256 to get the key ID. Hashing PKCS#1 DER, arbitrary strings, or a re-encoded SPKI would not give the specified identity. The advertised SPKI must encode id-RSASSA-PSS with explicit SHA-384, MGF1-SHA-384, and salt length 48. The Issuer selects the request key by the last byte of its full key ID, so keys that are eligible for issuance at the same time must have distinct suffixes.
  • The Issuer alone stores the private signing key. The Origin pins the trusted Issuer's name and public SPKI and does not load, mount, or fetch a signing secret. The RFCs define the Issuer, Attester, Client, and Origin roles. Freebird may operate the Attester and Issuer together. Public verification does not prevent a compromised Origin from authorizing its own requests or prevent correlation by issuance and redemption timing.

HTTP routes separate discovery, issuance, and redemption

Role Surface Contract
Issuer GET /.well-known/private-token-issuer-directory This route serves an RFC 9578 JSON directory as application/private-token-issuer-directory. It includes issuer-request-uri and token-keys with type 2 and canonical SPKI in padded base64url. The cache lifetime follows the key policy.
Issuer POST /private-token/issue This route accepts one 259-byte RFC request with Content-Type: application/private-token-request. A successful response contains 256 bytes with Content-Type: application/private-token-response. An unsupported type, key suffix, or length returns 422. The route accepts no JSON wrapper. With batch_size above 1, it also accepts a generic batch, and with public_metadata on, a type 0xDA7A request, as described below.
Origin GET /private-token/protected A request without a valid token receives 401 with RFC 9577 WWW-Authenticate: PrivateToken challenge="...", token-key="...", max-age=.... A request with one accepted Authorization: PrivateToken token="..." receives 200. nginx calls the route through auth_request, and an application on the same host may call it directly to verify and spend a token that arrived in its own messages. Either way, 200 means that the Origin verified and spent the token. No route checks a token without spending it.

HTTP authentication uses padded base64url values and quotes them when the syntax requires it. Scheme and parameter names are case-insensitive. The parser ignores unknown authorization parameters and rejects duplicate mandatory parameters, malformed encodings, and trailing binary bytes. RFC 9577 Section 2.1.1 defines challenge parsing with length-prefixed ASCII server names, exactly 0 or 32 context bytes, and no userinfo. The Origin puts its own name in origin_info and uses one pinned Issuer name and the selected token type. It advertises the selected public key with the challenge. The context is shared, not client-specific.

The Issuer accepts exactly one nonstandard Freebird-Admission header containing 32 CSPRNG bytes encoded as 43 unpadded base64url ASCII characters. Duplicate headers, whitespace, other encodings, or wrong lengths return 400. This header is separate from the standard binary request body and is not an RFC parameter. Do not log it.

For operator-only admission, a local CLI provisions one random invitation and prints it once to the operator. It durably stores SHA256(generation || invitation_bytes) with an absolute 24-hour expiration. No public endpoint mints invitations in this mode. The reference client obtains its invitation from the operator. A missing, unknown, expired, or consumed invitation receives the same 403 response, and the Issuer does not sign the request.

Malformed RFC request bodies of 0–4096 bytes that are not exactly 259 bytes return 422 before the Issuer consumes the invitation. An unsupported media type returns 415, and a body that exceeds the separate 4096-byte transport cap returns 413. Exhausted signer capacity returns 429, and storage or commit failures return 503. All signing routes must enforce admission. Issuance, renewal, batch, or administrative routes must not bypass that requirement.

The Issuer consumes admission before signing

One invitation permits one signing attempt, or one generic batch of at most batch_size attempts when batching is enabled. The Issuer validates the request and atomically consumes the invitation in a crash-durable transaction before signing. Only one of several concurrent contenders can consume an invitation. A lost response or crash can consume it, and the Issuer must not refund an uncertain signing attempt. Do not cache the blind response with the invitation or link it to a redeemed token. This is Freebird policy, not a standardized Privacy Pass quota.

Applications prove possession of their keys

app-add prints a key of the form fba_<name>.<secret>: the application's name and 32 CSPRNG bytes in unpadded base64url. The Issuer stores mac_key = HMAC-SHA256(secret, "freebird-app-mac-v1") and never the secret, which therefore never crosses the network. Every request to POST /freebird/app/admission, POST /freebird/app/reverse, and POST /freebird/app/credit/settle carries exactly one header:

Authorization: Freebird-App app="<name>", time="<unix seconds>", nonce="<16 bytes>", mac="<32 bytes>"

The parameters appear in that order, separated by ,. The time is a canonical decimal, and the nonce and MAC are canonical unpadded base64url. mac = HMAC-SHA256(mac_key, M) with

M = "freebird-app-request-v1" || u16(len(name)) || name || u64(time) || nonce
    || u16(len(method)) || method || u16(len(path)) || path
    || H(Freebird-Scope) || H(Freebird-Expires) || SHA-256(body)

where H(h) is 0x00 when the header is absent and 0x01 || u16(len(value)) || value otherwise, and integers are big-endian.

  • The Issuer accepts each proof once, while it is fresh. A missing or malformed proof, a time more than 60 seconds from the Issuer's clock, an unknown or revoked application, a MAC that does not verify, and a nonce that the Issuer has already accepted all return 401 with WWW-Authenticate: Freebird-App. A repeated Freebird-Scope or Freebird-Expires header returns 400.
  • Accepted nonces live in memory until their proof expires, at most 65,536 of them; a full table returns 503. A restart forgets them, so replaying a proof would still require reading it from TLS within its 60-second window.
  • Recorded traffic yields nothing reusable, even if its TLS were broken later, because a proof covers one request at one time. Whoever reads the Issuer's state can act as any application, but that state also holds the Issuer's signing keys.
  • Stores from before this format are refused without migration. Move app-clients.sqlite aside, run init-issuer-app-admission, and add each application again.

The Origin commits each spend before granting access

The Origin derives one shared 32-byte pseudorandom redemption context per UTC hour as HMAC-SHA256(origin_context_secret, "freebird-pp-context-v1" || u64_be(hour_index)). The Origin generates the secret once and persists it separately from the Issuer key. Challenges for the active hour remain acceptable until five minutes after that hour ends. Challenges from the hour that just ended are accepted only during the grace period. The Origin reconstructs the exact accepted TokenChallenge bytes and compares their SHA-256 digests with the authenticated challenge_digest. The max-age value gives the seconds until the deadline for the challenge of the active hour. It does not indicate token expiry.

The Origin persists the greatest observed Unix second in the same durable transaction as challenge issuance or redemption and bounded replay pruning. If the wall clock falls below that high-water mark, the Origin refuses both challenge issuance and redemption until the clock catches up. At now >= acceptance_deadline, the Origin rejects the challenge. A restart or clock step cannot reopen it after it closes. Changing the fixed deadline rules requires an explicit migration of persisted state.

The Origin checks the full token before marking it spent. It checks the type, trusted public key ID, signature, binding to the Origin, Issuer, and challenge, and acceptance deadline. The Origin atomically records a spend key from the authenticated key ID, challenge digest, and nonce. Only one concurrent redemption can succeed, and restart does not clear the spent state.

Each admitted request begins an IMMEDIATE transaction that checks metadata and replay invariants before deleting any rows. The transaction refuses clock regression and advances the durable high-water mark. At now >= acceptance_deadline + 120, the Origin prunes at most 256 challenges. It then prunes at most 256 expired spends whose challenge row is absent. Spend rows for challenges outside the batch remain intact. A partial sweep may leave spends without challenges. The Origin calculates the cutoffs with checked integer arithmetic, not SQLite deadline addition.

Pruning, redemption or challenge persistence, and high-water advancement commit together. Any failure rolls back the transaction and denies access. The Origin returns 200 or 401 only after commit. Pruning by a time limit is safe only with the enforced deadlines and rollback rules, including the restriction on rolling back snapshots.

Pruning neither retires a key nor deletes its permanent record. Even a superseded key without challenge and spend rows cannot retire before S+420. Offline installation and retirement do not prune request state. A frozen clock or high request volume can accumulate unexpired spends because pruning does not impose an absolute storage quota. The Origin never evicts redeemable spends to meet a cap.

The Origin admits at most two blocking jobs for SQLite and RSA work. It samples the clock after it acquires the connection mutex and starts the transaction, not while the job waits. Saturation returns 429 without a challenge or state change. Store, clock, worker, or join errors return 503. Cancelling an HTTP future does not cancel its admitted blocking job or release the permit before completion. A lost response can spend a token. Do not refund an uncertain spend.

Each role runs once and holds an exclusive store lock

The deployment guide uses one Ubuntu 26.04 host with nginx terminating TLS, version 1.3 with hybrid post-quantum key exchange only, in front of one loopback-only process per role. The setup does not provide automatic failover. Each process takes an exclusive lifetime lock on its local transactional store, which prevents a second process from starting. Transactions must withstand crashes and be recoverable after restart. SQLite uses WAL and synchronous=FULL for this purpose. Reject or disable multi-replica deployment manifests before the services start. Freebird does not support multiple replicas or shared-store failover.

Restoring state invalidates old tokens and invitations

Keep the Origin stopped during recovery because the store cannot detect its own rollback to an older snapshot. Generate and persist a fresh context secret outside the restored snapshot and discard old accepted contexts before reopening the Origin. All old tokens become unusable, and the restore retains the clock high-water mark.

When restoring the Issuer admission store, rotate the invitation generation outside the restored snapshot and invalidate every invitation from the old generation before reopening. Local software cannot protect against an unannounced rollback of the store and the recovery marker together. Signing keys, context secrets, invitation generation, and one-use state each have a dedicated storage namespace.

The recovery runbook specifies the supported backup and restore steps and their limits.

Both roles schedule rotation for the same UTC hour

Each role stores key state in a SQLite manifest: schema v2 for the Issuer's issuer-keys.sqlite and schema v3 for the Origin's origin.sqlite, whose key rows also record their token type. Each key row stores its full key ID, which is the SHA-256 hash of its canonical SPKI, and the exact SPKI bytes. The row also stores an activation time in whole UTC hours, expressed as Unix seconds divisible by 3600. Issuer staging and activation support one local instance. The offline commands require the lifetime lock while the Issuer is stopped. The -live commands make the same changes, with the same checks, over the Issuer's UID-restricted control socket while it serves, and the Issuer reloads its keys, directory, and key history without a restart. Run activate-issuer-key <issuer-state-dir> <key-id-hex> <S> to schedule the staged candidate for hour S. The ID must name its staged or scheduled candidate. The Issuer signs each request with exactly one key. It selects the key with the greatest activation hour at or before the clock hour. The Issuer retains the greatest clock hour for the life of the process, so a backward clock step does not restore an older key. The Issuer rejects suffix collisions among the private keys that it holds.

The directory follows RFC 9578 Section 4. token-keys lists the scheduled key first with not-before set to S in Unix seconds, then the selected key without not-before. A Client uses the first entry whose not-before is absent or in the past, which is the selected key. Omitting not-before from the selected key keeps it usable for a Client whose clock is slightly behind. Superseded keys leave the directory when their successor activates. The directory cache lifetime is at most 60 seconds and cannot exceed the seconds until the next scheduled activation.

The Issuer also publishes GET /freebird/key-history, a Freebird-specific document outside RFC 9578. It lists every key that has started signing, including retired keys, with token-type, token-key, and not-before in start order, so that anyone can verify an old token offline after its key has left the directory. The list is derived from the key store and only grows, because started keys keep their start times and public records and new keys must start later. Each entry carries a hash chain value: chain_0 = SHA-256("freebird-key-history-v1\0" || u16(len(name)) || name || E_0) and chain_i = SHA-256(chain_{i-1} || E_i), where E_i = u16(2) || u64(not-before) || u32(len(spki)) || spki in big-endian. Anyone who kept an earlier head can check that a later list extends it. The chain does not prevent an Issuer from showing different lists to different readers; readers who compare heads detect that. Key i's tokens are issued from its not-before until the next key's, and an Origin accepts them for 300 seconds after that.

The Origin installs the candidate public key with activation hour S before S. It advertises the key from S and accepts its tokens only for challenges that it records from S. An Origin started with serve-origin --config and follow_issuer = true reads the Issuer's directory at startup and every 300 seconds. It installs an announced key in its running store only if all of these hold:

  • not-before is a whole hour at least key_notice_hours away, one hour by default, when the Origin first sees the key.
  • The key is later than every key in the store, no other key is pending, and the superseded key has been retired.
  • The key ID is the SHA-256 hash of a canonical type-2 SPKI and has never been retired at this Origin.

The Origin reads the directory over loopback HTTP from an Issuer on the same host, or over HTTPS from https://<issuer_name> with Web PKI roots or one configured CA. Whoever can serve that directory can add a key that the Origin accepts. This is the trust that Clients already place in the directory; the notice period and logging limit a brief takeover. A failed fetch or malformed directory changes nothing. An Origin without following uses install-origin-key while offline, before the Issuer is scheduled. Live and offline key changes share one transaction body with the same checks. A live change also replaces the Origin's in-memory schedule, after commit and under the same lock as its requests.

The Origin accepts only stored tuples of full key ID, challenge digest, and acceptance deadline. It verifies only with the key that the token names. The Origin rejects a token for a key without a stored challenge. A matching digest alone cannot authorize a key because the challenge does not contain the key. Once a successor activates, the superseded Origin key enters verifying state until retirement. The Origin accepts redemptions for that key only while its recorded challenge is within its deadline. The last deadline is S + 300 seconds. The Origin rejects all redemptions for that key at and after that deadline.

Retirement removes superseded material and keeps key IDs

Run retire-issuer-key <dir> <old-id> once now >= S, when the successor is active. Run retire-origin-key <dir> <old-id> once now >= S+420, which is the final S+300 acceptance deadline plus a 120-second safety margin. A following Origin retires the key itself at that time. The Issuer sets pkcs8=NULL for the superseded key and advances high-water in one transaction. The Origin deletes that key's challenges and spends, sets retired=1, and advances high-water in one transaction. Both stores retain public key records permanently, so a retired ID cannot be reinstalled. Retire the superseded keys before a second rotation. The Issuer stops signing with a key when its successor activates, even if retirement has not run.

Origin installation and rescheduling check streamed canonical SHA-256 digests of replay state before and after all changes within the transaction, including updates to the high-water mark. The retirement check excludes only the target key. The digests cover every replay column in canonical row order, separate domains and scopes, and include row counts without loading the whole replay store into memory. This check relies on SHA-256 collision resistance and does not compare literal snapshots row by row. Unexpected SQLite column types or digest mismatches abort the transaction. The checks on schema objects still apply.

Both key stores use secure_delete=ON. Issuer retirement attempts wal_checkpoint(TRUNCATE) after commit. A failed checkpoint neither rolls back retirement nor changes the reported success. This best-effort cleanup does not guarantee destruction of journal copies, backups, snapshots, or process memory. Freebird does not guarantee zeroization. Freebird also does not support HSMs or multiple instances per role.

Tests check each protocol rule

common/src/privacy_pass/ contains serialization and shared types. crypto/ contains the narrow adapter for the RFC 9474 primitive. common/test-fixtures/privacy-pass/ contains verbatim vectors from RFC 9577 Appendix A and RFC 9578 Appendix A.2 with source URLs, hashes, and the RFC's license notice for code extraction. Expected values come from sources independent of the code under test. Exact SPKI bytes, RFC vectors, and dependency advisories are verified before the primitive version and lockfile are pinned.

The tests check these properties:

  1. Independent RFC vectors pass, and negative tests reject invalid encodings and signatures.
  2. The Rust reference client receives a real HTTP challenge, requests exactly one blind signature with one-use admission, finalizes the token, and redeems it once. Tests verify rejection of replay, wrong Origin, challenge, key, or type, trailing bytes, and store outage. The signer limits concurrency.
  3. Durable one-use state prevents invitation and token reuse under concurrency and after restart. Tests cover commit failure, exclusive store ownership, crash recovery, and same-hour clock rollback. They also cover now == acceptance_deadline, irreversible closure after restart and retirement of spend records, and the operator-run procedure that invalidates restored credentials. These tests establish local acceptance policy, not a token expiration field.
  4. Public-key verification requires an Origin with no path to a private key, environment fallback, or mounted signing secret. Every issuance and token-check route enforces the applicable admission or redemption rule. Tests cover offline staged-key activation with the Origin first, agreement between the roles on key status, refused operations, collisions in truncated key IDs, and retirement of superseded keys. Live Origin changes repeat the offline refusal table without changing the store or schedule. The follower refuses malformed directories and keys with too little notice, and installs announced keys over loopback and HTTPS. The rotation drill checks Issuer retirement at S, Origin refusal at S+419 and success at S+420, rejection of retired tokens and IDs, and a second full rotation.

The security policy lists the release gates and their evidence, records the Git-pinned fork and stable RSA backend, and states the limits of the tests. Independent security review is the only open gate. Passing these tests does not establish production readiness.

Freebird implements token type 0x0002 and, as an experimental option, type 0xDA7A (below). It excludes type 0x0001 by design: those tokens are privately verifiable, so an Origin would need the Issuer's private key, which breaks the rule that Origins hold only public keys and rules out Origins on other hosts. The contract also excludes tokens that name no Origin or several Origins, a token check that does not spend the token, and HSM guarantees.

Generic batches follow draft-ietf-privacypass-batched-tokens-10

With batch_size set to N between 2 and 64, the issuance route also accepts Content-Type: application/private-token-generic-batch-request, as specified in Section 7 of draft-ietf-privacypass-batched-tokens-10. This is an experimental extension; a later revision may change the wire format. The body is a vector with a QUIC variable-length integer length prefix holding RFC 9578 TokenRequests. The response, application/private-token-generic-batch-response, holds one optional entry per request, in request order. One Freebird-Admission code buys the whole batch. The Issuer refuses a batch with more than N entries, a malformed body, or no entry that it can issue, with 422 and without consuming the code. A body larger than a full batch, 8 + 259·N bytes or 4096 if that is larger, is refused with 413 before it is parsed. Entries of another token type, or for a key other than the selected one, are returned absent, as the draft allows. The Issuer commits the code's removal before signing, and a lost response consumes it. The Origin needs no change: each token in a batch is an ordinary type-2 token for the same challenge and redeems once. The Issuer sees how many tokens arrive together. Freebird's clients request exactly N so that the size does not distinguish them.

Scoped tokens follow draft-ietf-privacypass-public-metadata-issuance-03

With public_metadata = true, Freebird also implements token type 0xDA7A from draft-ietf-privacypass-public-metadata-issuance-03. It uses RSAPBSSA-SHA384-PSS-Deterministic from draft-irtf-cfrg-partially-blind-rsa-02 and the Extensions structure from draft-ietf-privacypass-auth-scheme-extensions-03. All three are expired Internet-Drafts, so a later revision may change the wire format.

  • The metadata is the route's scope. Freebird uses one extension of the provisional, unregistered type 0xFB01, whose value is the scope: Extensions = uint16(4 + len) || uint16(0xFB01) || uint16(len) || scope, with 1 to 128 visible ASCII bytes. The Issuer and the Origin refuse any other list.
  • The keys are a separate series. Each modulus is the product of two safe primes, and a key is never used for type 2. The Issuer keeps these keys in issuer-metadata-keys.sqlite (schema version 0xDA7A), and the Origin keeps them in its v3 store with token type 55930. Signing and verification derive a per-scope key from the base key, as the CFRG draft specifies, so a token verifies only for its own scope. A key ID is the SHA-256 hash of the same RSASSA-PSS SPKI encoding that type 2 uses. The Origin cannot check the safe-prime property from public material, so a key's series comes from the directory's token-type.
  • The directory and key history list both series. The directory lists 0xDA7A keys after the type-2 keys, with token-type 55930 and the same not-before rules. The key history includes them, ordered by start time and then token type, and its hash chain covers each entry's own type. The first 0xDA7A key starts at the hour the Issuer generated it, so the history only grows.
  • Issuance checks the scope before consuming the code. The body is the 259-byte TokenRequest with type 0xDA7A, followed by the Extensions (ExtendedTokenRequest), sent as application/private-token-request. The token input is 0xDA7A || nonce || SHA256(TokenChallenge) || token_key_id. A malformed body, an Extensions that is not one Freebird scope, or a key other than the current 0xDA7A key returns 400 without consuming the code, as the draft specifies. The code must have been provisioned for that scope. Any other code, including an unscoped one, returns 403 and stays unspent. A generic batch with a 0xDA7A entry is refused with 422, because the batch format cannot size an entry that carries extensions.
  • A scoped code matches only its own scope. Its stored hash is SHA256(generation || code_bytes || "freebird-scope-v1\0" || uint8(len) || scope), so the admission schema is unchanged. App admission issues a scoped code when the request carries one Freebird-Scope header. A malformed scope, or a scope sent to an Issuer that does not serve 0xDA7A, returns 400 without charging the app's cap.
  • Redemption requires the route's scope. On a request where nginx, or a co-located application, sets Freebird-Scope, the Origin challenges with a 0xDA7A TokenChallenge and suggests the scope with the extensions challenge parameter: WWW-Authenticate: PrivateToken challenge="...", token-key="...", extensions="...", max-age=.... It accepts only Authorization: PrivateToken token="...", extensions="..." with a 0xDA7A token whose extensions equal the route's scope, verifies it with a 0xDA7A key, and records the spend in the same transaction as for type 2. Type-2 tokens are refused on such routes, and 0xDA7A tokens are refused on unscoped routes. With public_metadata = false, scoped routes keep using type-2 tokens that the challenge binds to the scope.
  • Setup and rotation cover both series. Set public_metadata before setup, which generates the first key, in seconds to a minute, and installs it at the Origin. setup-origin installs the directory's current 0xDA7A key. Turning the setting on after setup is not supported. The follower installs and retires 0xDA7A keys under the same rules as type-2 keys, and rotate schedules both series for the same hour. issuer-key-status and origin-key-status list the scoped-token keys after the type-2 keys, with a metadata- prefix on each state.
  • The scope is visible to both roles. The Issuer sees each request's scope, and the Origin sees it at redemption. A token is unlinkable only among tokens for the same scope, so a scope that few users share, or one that identifies a user, removes that protection. Keep scopes coarse.

Fetch-ahead scoped tokens follow draft-ietf-privacypass-expiration-extension-00

With max_token_lifetime_hours set to L hours (0 turns it off; otherwise 2 to 2160, and public_metadata must be on), scoped tokens carry an expiry and can be obtained ahead of use. The expiration extension is an expired Internet-Draft with one revision, so a later revision may change it. Set L before setup: the Origin records it at initialization and refuses to serve if the config later differs.

  • The expiry is metadata. Every scoped token carries exactly two extensions in type order: Expiration (type 0x0001, an ExpirationTimestamp with timestamp_precision = 3600 and an expiry E that is a whole hour), then the Freebird scope. Unscoped tokens and type-2 tokens carry no expiry.
  • The application chooses the expiry. App admission accepts one Freebird-Expires header between an hour ahead and L hours ahead. Without it, the expiry is the latest UTC midnight that is at least an hour away and within L hours, or, if there is none, the latest whole hour within L hours. The response reports the expiry as expires. The expiry is bound into the code's stored hash with the scope, so the Issuer signs only a request with that exact scope and expiry. A wrong expiry returns 403 and leaves the code unspent. An expiry that has passed or lies more than L hours ahead returns 400.
  • The challenge is fixed per scope. On a scoped route, the challenge's redemption context is HMAC-SHA256(origin_context_secret, "freebird-pp-fetch-ahead-v1" || uint8(len) || scope), with no hour component. Every client sees the same challenge for a scope, and a client can obtain its token long before it redeems it. The extensions challenge parameter suggests only the scope, because the client adds the expiry it received with its code. The Origin stores no challenge rows for these routes.
  • Redemption checks the expiry. The Origin accepts a scoped token before its expiry E, for the route's scope, when E is at most L hours ahead and at most L hours after the next key's start. It keeps the token's spend record until E and then prunes it.
  • Keys stay installed until their tokens expire. A superseded scoped-token key retires at the Origin at S_next + L hours plus 420 seconds instead of S_next + 420. The follower, retire, rotation-due, and key status follow that rule. Because a rotation waits for the previous key's retirement, both series rotate at most once every L hours plus the notice period.
  • Recovery invalidates fetched-ahead tokens. Context recovery rotates the secret that derives the fixed challenge, so every token fetched before a restore, spent or not, stops verifying. Applications must give users new codes for scopes that are still open.
  • The expiry adds no information when it is shared. When an application gives every code for a scope the same expiry, such as the close of a ballot, the expiry reveals nothing beyond the scope. Different expiries within one scope split its users into smaller groups.

Reverse issuance follows draft-meunier-privacypass-reverse-flow-07

With reverse_max_tokens set to N (0 turns it off; otherwise 1 to 64, and app_admission must be on), an application can give a user new tokens in the same exchange in which it spends one. Freebird uses the draft's shared deployment, in which one operator runs the Issuer and the Origin, and the HTTP transport from draft-meunier-privacypass-reverse-flow-http-00. Both are individual Internet-Drafts, not working-group documents, so the format may change.

  • The client sends its request with the token. Alongside Authorization: PrivateToken token="...", the client sends PrivacyPass-Reverse: "<base64url CredentialRequest>". The request has the same kind as the token it accompanies: one TokenRequest, or a draft-10 generic batch of 2 to N type-2 requests, for a type-2 token; exactly one ExtendedTokenRequest with the same extensions for a scoped token. The draft says a CredentialRequest is prefixed by its token type. RFC 9578 and 0xDA7A requests already begin with their type, and a generic batch carries one per entry, so Freebird sends them unchanged.
  • The application decides. After auth_request succeeds, nginx forwards the spent token as Freebird-Redeemed and the reverse request unchanged. The application posts both to POST /freebird/app/reverse with a proof of its app key, in a JSON body {"authorization": "...", "request": "..."}, and returns the Issuer's {"response": "..."} value to the client as PrivacyPass-Reverse: "...".
  • The Issuer signs, and the Origin stays public-key-only. The Issuer verifies the token with its own public key records and signs the request with its current key of that kind. New tokens are therefore indistinguishable from freshly issued ones. A token from a superseded key is accepted until 600 seconds after its successor starts, and a fetch-ahead token until its expiry, matching what the Origin would still accept. Other tokens return 403.
  • Each token yields at most one issuance. reverse.sqlite records each token's request hash and the response. A retry with the same request returns the identical response for the token's whole window, and the same token with a different request returns 409. Rows are pruned when the window closes, and the Issuer refuses any token outside its window. Each first issuance charges the application's daily cap once.
  • The Issuer trusts the application. The Issuer cannot see that the Origin spent the token, so it trusts the application to forward only tokens that reached it through nginx. The application's daily cap bounds the effect of a dishonest application.
  • New tokens bind the challenge the client chooses. Freebird's clients bind the same challenge as the redeemed token. A refunded ordinary token is therefore usable only while that hourly challenge is accepted, and a fetch-ahead scoped token's refund lasts until its expiry.

Standing tokens close the loop back to the Issuer

With standing_tokens = true (which needs public_metadata and reverse_max_tokens), an application can vouch for a client by handing out a standing token instead of a refund. The client later presents it to the Issuer instead of an admission code. This is the draft's Attester feedback loop.

  • A standing token is a scoped token for one application. It is a 0xDA7A token whose extensions are exactly the scope standing:<app-name>, with no expiry. All well-behaved users of one application share that scope.
  • The Issuer is its Origin. GET /freebird/standing/<app-name> returns 401 with a challenge that names the Issuer as both issuer and origin, the current 0xDA7A key, and the scope as extensions. Its redemption context is HMAC-SHA256(admission generation, "freebird-standing-v1" || uint8(len) || scope), so admission recovery invalidates every earlier standing token. An unknown or revoked application returns 404.
  • The application hands it out through the reverse flow. The client sends a request for the standing challenge and scope as its PrivacyPass-Reverse request. The Issuer accepts it whatever kind of token was redeemed, as the application's one issuance for that token. Standing tokens cannot themselves be presented for reverse issuance.
  • It buys what an admission code buys. At POST /private-token/issue, a request without Freebird-Admission may carry the standing token in Authorization: PrivateToken token="...", extensions="...". It buys one type-2 token, or a generic batch of up to batch_size. The Issuer records the spend before signing, so each standing token works once, and it charges no application cap, because the application paid when it handed the token out. Tokens from the current key, or from a superseded key until 24 hours after its successor starts, are accepted. A request with Freebird-Admission takes the unchanged code path.
  • Applications decide what is required. An application that wants returning users to show a standing token stops giving them admission codes, and gives standing tokens only to users whose requests it accepted.

Anonymous credits follow draft-schlesinger-privacypass-act-01

With credit_amount above 0, the Issuer sells anonymous credentials that hold a number of credits, following draft-schlesinger-privacypass-act-01 (token type 0xE5AD) and its cryptography in draft-schlesinger-cfrg-act-01. Both are expired individual Internet-Drafts. Freebird uses the anonymous-credit-tokens 0.4.2 crate, pinned and unaudited, with 24-bit credit amounts.

  • Only the Issuer verifies a spend. Credit tokens are not publicly verifiable, so the draft requires one operator for the Issuer and the Origin. In Freebird the Issuer checks every spend, and Freebird's Origin role never holds a credit key. Credit routes therefore need nginx on the Issuer's host. Remote Origins cannot serve them.
  • Credentials belong to an epoch. The epoch is credit_epoch_days long. Its credential_context is HMAC-SHA256(admission generation, "freebird-credit-v1" || u64_be(epoch)), so admission recovery invalidates every credential, and leftover credits expire with the epoch. The challenge from GET /freebird/credit/challenge names the Issuer, the Origin (origin_name), that context, and an empty redemption context, because the nullifier and not the challenge prevents double spending. The draft's request_context concatenates the Issuer name, Origin, credential context, and key ID but does not define how to turn that into a scalar. Freebird reduces a SHA-512 hash of a label and the length-prefixed fields, which is its own choice.
  • An admission buys one credential. At POST /private-token/issue, an unscoped admission code or a standing token buys one credential holding credit_amount credits, with Content-Type: application/private-credential-request. Every credential starts with the same amount, so the amount does not distinguish users. A malformed request returns 422 and leaves the code unspent, and scoped codes are refused.
  • nginx asks the Issuer to check each spend. For a credit route, nginx's auth_request calls the Issuer's loopback-only GET /freebird/credit/spend with the route's price in Freebird-Cost. Without a valid token, the Issuer answers 401 with WWW-Authenticate: PrivateToken challenge="...", token-key="...", cost=N, which nginx passes to the client. With a token, the Issuer verifies the spend proof against the current epoch's context, requires the charge to equal the price, and records the nullifier in credit.sqlite, so a credential grants access once.
  • Fixed price returns the balance at once. The Issuer returns the refund, a new credential for the remaining balance, in PrivacyPass-Reverse, and nginx copies it to the client. The draft names no header for this refund. Freebird uses the reverse-flow HTTP transport's header, because the reverse-flow draft lists credit tokens as one of its instances.
  • Pay-for-usage holds the price. With Freebird-Credit-Mode: hold, the Issuer records the spend and gives the application a spend ID in Freebird-Credit-Spend. After serving, the application posts {"spend": ..., "used": n} to POST /freebird/app/credit/settle with a proof of its key. The Issuer refunds the price minus n, and the application returns the refund in PrivacyPass-Reverse. Settling twice with the same amount returns the same refund, and a different amount returns 409.
  • Settlement is bound to the route's application. A hold route's internal location names its application in Freebird-Credit-App. The Issuer stores the name with the held spend, refuses a hold without it with 400, and accepts a settlement only from that application's key; any other returns 403.
  • Credit keys rotate at epoch boundaries. A new credit key starts at the first epoch boundary at least 15 minutes away, where every older credential expires anyway. The superseded key keeps its private material until a day after that boundary, so held spends from the old epoch can still be settled and refunded with the key recorded on the spend. rotate, retire, rotate-live, and retire-live cover the credit series, and the recovery catalogs record its store.
  • Lost refunds are collected, not re-spent. A replayed token is refused and never grants access twice. The client collects its refund from POST /freebird/credit/refund with its exact token instead. A hold that no application settles within 300 seconds is settled there at the full price, so the client still gets its remaining balance back. Spend records are kept until a day after their epoch ends.

Exchange between Issuers is Freebird's own extension

With exchange = true and the store that init-issuer-exchange or setup creates, an Issuer B accepts a type-2 token from a trusted source Issuer A in place of an admission code. Origins keep trusting only B. No Internet-Draft defines this exchange. It is the client-mediated feedback loop of draft-meunier-privacypass-reverse-flow-07 Section 2.3 applied between Issuers. The design explains the rationale.

  • Sources live in exchange.sqlite. Each source has a name (1–64 characters from [a-z0-9-]), the source's issuer name and directory URL (HTTPS, or numeric loopback HTTP), an optional CA, a daily cap of 1 to 100,000, a rate of 1 to 64, an output, an optional fixed expiry, an optional cutoff, notice hours, and a random 32-byte epoch drawn by every exchange-add. exchange-add, exchange-set, exchange-remove, and exchange-list use the control socket while B serves and open the store directly while it is stopped. The store records nothing about clients.
  • The challenge is fixed per source. GET /freebird/exchange/<name> returns 401 with WWW-Authenticate: PrivateToken challenge="...", token-key="..." and no max-age. The TokenChallenge has type 2, issuer_name set to the source's issuer name, origin_info set to B's issuer name, and redemption_context = HMAC-SHA256(admission generation, "freebird-exchange-v1" || epoch || uint8(len(name)) || name). token-key is the source's current key. An unknown, removed, or keyless source returns 404. Admission recovery and re-adding a source both change the context.
  • Issuance checks the source token before signing. A request to POST /private-token/issue without Freebird-Admission and with a type-2 token in Authorization is an exchange. Freebird-Admission takes precedence, and a 0xDA7A token in Authorization is a standing token. B parses the body first: a malformed body returns 422, and a body that the source's output cannot satisfy, or more entries than its rate, returns 400. B then finds the source by the token's full key ID among non-retired keys that started before the source's cutoff, rebuilds the fixed challenge, and verifies the signature; any failure returns 403. In one immediate transaction it rechecks the source's policy and cutoff, checks the UTC-day cap (429 with Retry-After until the next UTC midnight), records the spend under the key ID, challenge digest, and nonce (a replay returns 403), and counts the exchange. It signs only after the commit. A lost response spends the source token. An exchange charges no application's cap.
  • A browser can complete an exchange on its own retry. POST /freebird/exchange/<name> accepts the same bodies and media types as POST /private-token/issue, and B parses the body first with the same 422 and 400 answers, so a client never obtains a source token for a request that cannot succeed. An unknown, removed, or keyless source returns 404. Without a type-2 token in Authorization, the route returns 401 with the same WWW-Authenticate header as GET and Cache-Control: no-store, and spends nothing. With one, the exchange proceeds as on the issuance route, except that only the named source's keys and challenge can match; a token for any other source returns 403. The route ignores Freebird-Admission. For a configured browser origin, CORS exposes WWW-Authenticate on this 401. Safari attaches a Private Access Token only to its own retry of the request that received the 401, with the identical method and body, so a page's single fetch to this route completes the exchange.
  • The output decides what the client receives. ordinary buys up to rate type-2 tokens in one request or generic batch. scoped:<scope> buys one 0xDA7A token whose extensions must equal the scope, preceded by an Expiration extension when max_token_lifetime_hours is above 0. The expiry is the source's fixed expiry, which must be a whole hour between one hour and max_token_lifetime_hours ahead at the time of the exchange, or otherwise the app-admission default. credit buys one credential holding credit_amount. Scoped and credit outputs require rate 1. Every refusal leaves the source token unspent.
  • B follows each source's keys. One follower per active source reads the source's directory at startup and every 300 seconds with the Origin follower's transport and retry rules. It installs an announced key whose not-before is a whole hour at least the source's notice hours away (the Issuer's key_notice_hours unless set per source), holds at most one pending key, never installs a key that would start before an existing one or a retired key ID, and retires a superseded key 420 seconds after its successor starts. With 0 notice hours, it installs a newly current key at once, and an unknown key ID at issuance wakes it at most once a minute. Each change is logged with the prefix exchange follower:.
  • Start times and cutoffs fail closed. A key's start time comes from the source's key history, accepted only when its issuer name, entries, and head verify; else from the key's not-before when B saw it announced; else from when B first saw it. A key is usable only if its start time is strictly before the source's cutoff, which B checks when it installs a key, when it finds a source, and in the spend transaction.
  • Spend records last as long as their key. B prunes a spend, at most 256 rows per sweep, once its key has been retired for 120 seconds. Retired key rows remain, so their IDs are never reinstalled for that source.
  • The trust list is hash-chained. Every management change and every follower installation or retirement appends a version in the same transaction. GET /freebird/exchange-sources returns {"format": "freebird-exchange-sources-v1", "issuer-name", "versions", "head"}. Each version lists every source's name, issuer name, directory, rate, output, expiry, cutoff, notice hours ("default" when the store recorded the version before it knew the Issuer's default), active flag, and accepted key IDs in lowercase hex. Daily caps, usage, spends, epochs, and CAs are never published. The entry encoding E_i is documented in privacy_pass_service/src/exchange/trust.rs. Versions are numbered from 1, with chain_0 = SHA-256("freebird-exchange-sources-v1\0" || u16(len(issuer_name)) || issuer_name || E_0) and chain_i = SHA-256(chain_{i-1} || E_i).
  • Amplification across a direct pair is refused. For a rate above 1, exchange-add and exchange-set read the source's trust list. If it verifies and lists B with a rate whose product with B's rate exceeds 1, they refuse unless the operator passes --allow-amplification. Followers warn on later cycles without disabling the source. Longer cycles are not detected; daily caps bound them.
  • Recovery disables every source. recover-issuer-admission marks every source inactive, deletes exchange spends and usage, and appends one trust-list version, in one transaction, before the admission generation rotates. The recovery catalog records the trust list's issuer name, version count, head, and each source's retired and non-retired key IDs. A restored store must match the cataloged head at its version, and an extension may not lose or unretire a cataloged key.