# AllowedBy test vectors (v0.2.14-draft)

**TEST ONLY.** Every key in these files comes from a public seed. Never use them outside conformance testing.

These are the CONF-1 §4 vectors. They follow `specs/` v0.2.14-draft (CHANGES-0.2 §1–§28).

## What they are for

A spec in prose is read differently by every implementer. These files turn it into exact bytes and verdicts: fixed keys, signed documents, HTTP requests, each with the outcome every implementation MUST reach ("accept" plus the identity tuple, or a precise error code and status).

- **Implementers** (SDKs, nodes, verifiers in any language) run their code over every case. A disagreement means either the code or the spec is wrong, and it shows up before production.
- **Interop**: two independent implementations that both pass are byte-compatible (JCS, signatures, hashes, WebAuthn challenges, Merkle roots).
- **Conformance claims** (CONF-1 §2): "passes the v0.2 vectors" is the testable claim.
- **Spec review**: writing them forces every vague sentence to become a decision; the list below is what they surfaced.
- **Regression**: any spec change regenerates the files; the diff shows exactly what changed on the wire.

`verify.py` + `verify_ext.py` is a small reference verifier that shares no code with the generator (`generate.py` + `generate_ext.py`), so the two cross-check each other.

## Regenerate and check

```bash
python generate.py   # writes every *.json here; needs only `cryptography` (>= 44)
python verify.py     # reference verifier; asserts every case; exit 0 = all pass (601/601)
```

The output is deterministic:
- Ed25519 seeds are `SHA-256("allowedby/test-vectors/0.2/ed25519/" || name)`.
- P-256 scalars are derived the same way.
- ES256 uses RFC 6979 deterministic nonces, so ES256 signatures are reproducible too.
- Time is fixed at `now = 1761480000`.
- ULIDs and jtis are hash-derived.

Running the generator twice gives byte-identical files. The one caveat is the zlib build used for the status list. Do not hand-edit the files: regenerate them and diff.

## Files

Each file has `cases: [{name, kind, input, expected, http_status?, output?, accept_tuple?}]`. `expected` is `"accept"` or a spec error code.

| File | Contents |
|---|---|
| `keys.json` | All keys (public JWK, kid, private seed or scalar), the WebAuthn assertion builder recipe, the pairwise secret |
| `jcs.json` | RFC 8785 cases: key order (UTF-16), `4200.00`→`4200`, number edge cases, unicode and escapes |
| `node-statement.json` | Statements for `node.example.org` (role keys, `revoked_keys`) and `home.example.org` |
| `service.json` | Verifier config: `public_origin`, trust anchors, route map, status max ages, service `initiator` key |
| `human-reg.json` | `oaid-human+jwt` (with `rp_id`) and pairwise ids for two audiences |
| `passport.json` | Passports A1 (tier 1), A2 (renewal, `prev`), A3 (new key), S1 (tier 0, ES256) and a wrong-role passport |
| `grant-core.json` | Grant cores, core JCS, SHA-256, WebAuthn challenge, batch challenge |
| `human-sig.json` | WebAuthn assertion with debug bytes, plus negative vectors: type, challenge, origin, rpIdHash, UP, UV, wrong key, altered display |
| `grant.json` | Countersigned grant, levels chosen by the route (L3 accept, L2 on an L3 route, level 3 on a synced passkey, `qes_required`), wrong role, tampered payload, expired, class lifetime, `*` or other audience, level, `initiator`, amount and currency; then every rule a grant must satisfy, one case each side of its limit: time, status reference, revoked keys, audiences, the registration and its level, `human_sig` members, batches, the ABY-3 constraints, custody tier |
| `proof.json` | Proof valid and invalid: htm, htu, query, normalisation, proxies, bdh, dth, iat ±119/120/121 and +59/60/61, `actor_expired`, kid, `alg none`, RS256, typ confusion, replay, the exact size budget, `jti` length, member types, `actor.exp` boundaries |
| `chain.json` | Depth-1 attenuated child (ES256 leaf) and broken chains: one case per rule of ABY-1 §4 and ABY-3 §3, and which grant of a chain fails first |
| `chain-depth.json` | ABY-2 §2 0.2.14: a chain is at most two JWS, counted before any JWS is parsed (`431 envelope_too_large`). Opt-in of the `verifier` profile: SDKs that still allow four JWS are on its `opt_out` list (CONTRACT Known gaps) |
| `request-digest.json` | `request_digest` computations, single-use accept, reuse, query and body mismatch, bodiless DELETE |
| `rebind.json` | Revisions 0/1/2 of one `gid` (same core and `human_sig`, distinct `jti`), node-side rebind via `prev` and via `operator_sig`, refusals |
| `status.json` | Status-list sets (clean, revoked, stale, age 3599/3601), bit decoding, revoked grant and `human.reg`, fail-closed |
| `revoked-ancestor.json` | Child valid, parent bit revoked → `revoked` |
| `envelope-9421.json` | RFC 9421 / Web Bot Auth profile instead of the proof JWT: Ed25519 and ES256, passport and chain, signature base shown; refusals for uncovered components, `Content-Digest`, `tag`, `created` ±, `expires`, nonce replay, wrong `keyid`, internal `@target-uri` |
| `passport-issuance.json` | `POST {passports}` with node nonce and `dth` over the key: tier 0 `none` (TTL capped), tier 0 `orchestrator` evidence (`valid_until`), node-scoped operator; refusals for nonce used or expired, wrong key, `dth`, tier 0 key reuse, P-384, unbound operator, tier 1 with `none`, stale, foreign or unregistered orchestrator evidence. Renewal: tier 1 accepted (`prev`), tier 0 refused, wrong key, attestation older than 7 days |
| `challenge.json` | Service-initiated `grant_required` (with the service's signed `POST {approvals}`, the node's answer, `WWW-Authenticate`, problem JSON and `request_digest`), runtime-initiated (no `approve`/`poll`/`code`/`summary`), `passport_required` (realm and error only), `403` with no challenge, `503` with `Retry-After`; the challenge `scope` (escaped-path characters, at most 256 bytes, else `400`) |
| `approval-states.json` | All 25 state pairs (4 allowed), poll status per state, who may poll, creation rules (`expires_in` 60–3600, audience, `initiator`, level, callback host, fair-use cap), re-request after `not_me`, `aid` and `code` alphabet |
| `display.json` | `display` built from the service templates (en, fr, `{fields}`); refusals for a missing language, constraint or template, over 280 characters, non-decimal amount, non-ISO currency |
| `log.json` | 8 entries (2 vouches, 6 passports) with salts and commitments, roots at sizes 1/3/4/7/8, checkpoints at 4 and 8 (C2SP signed notes), 2 witness cosignatures, inclusion and consistency proofs (good and bad), witness accept and conflict, log promise kept and broken |
| `trust-list.json` | Signed trust list: anchors, a pinned and an unpinned program, `denied`, vouching at depth 1 and 2 with `min_vouchers` 2; refusals (depth 3, one voucher, expired vouch, old kid, vouching off, impostor statement); `witnesses_min` counting only trusted witnesses within 24 h |

Not covered: positive QES (needs qualified certificate chains and EU trusted lists), and tier 1 and 2 hardware attestation evidence (TPM, Apple, Android, FIDO, cloud KMS, confidential computing). Those formats are vendor-defined and need real certificate chains; the vectors cover `none` and `orchestrator` only.

## Ambiguities found (and the reading used)

All of these are now decided in the specs: see `specs/CHANGES-0.2.md` §16.

1. **File names.** Cases are split by topic; CONF-1 §4 now lists these files.
2. **`jti` in the core.** ABY-1 §3.1 puts `jti` in the core, but a revision is a new document. Per §15, `jti` is outside the core and each revision has its own. `iat`/`nbf`/`exp` stay in the core, so every revision keeps rev 0's `iat`.
3. **Revision numbering.** CONF-1 says "revisions 1 and 2", while ABY-1 says `rev` is 0 at issuance. The vectors use 0, 1 and 2.
4. **Status-list `typ`.** OAID-1 and OAID-2 say `oaid-status+jwt`; OAID-3 says `statuslist+jwt`. Per §15, `statuslist+jwt` is used. List age is measured from the list's `iat`. The read/write ceiling of 3600 s is inclusive.
5. **Error codes the specs don't name.** The vectors use:
   - `invalid_signature` for `human_sig` and chain-link failures (ABY-2 §5 step 3 only says "the failure code");
   - `grant_insufficient` for an audience mismatch or `"*"`, an unmet constraint, a `request_digest` mismatch, and a failed `initiator` check;
   - `invalid_request` for node-side rebind refusals.
6. **`rpId`.** ABY-1 §3.2 says rpId = "approval origin", but an rpId is a host. The vectors follow §15: `human.reg.rp_id`, with origin `https://<rp_id>`.
7. **`htu` normalisation.** The comparison is strict. The proof's `htu` must already be normalised; `HTTPS://API.EXAMPLE.COM:443/…` is rejected. The verifier normalises the request path (percent-encoding, dot segments) and ignores forwarded headers.
8. **Pairwise id.** `‖` is taken as plain UTF-8 concatenation with no separator: `HMAC(home_secret, utf8(internal_id) || utf8(origin))`.
9. **Signature encodings differ.** `human_sig.signature` is ASN.1 DER (WebAuthn), while JWS ES256 is raw `r||s`. clientDataJSON uses the browser member order, not JCS.
10. **Rebind `operator_sig`.** No `typ` was given before §15. The vectors use `aby-operator+jwt` over `{gid, sub, aud, iat, exp ≤ iat+300}`, carried in the body as `{"operator_sig": …}`. The rebind proof is signed by the new passport key.
11. **`initiator` on chains.** Only the root has a core, so `initiator` is checked on the root. A child must carry `human` byte-identical to its parent's, and has no `display`, `human_sig` or `initiator`.
12. **Clock skew on `exp`.** The 60 s skew (OAID-1 §4.4) is applied to a grant's `exp`, so the expired vector uses `exp + 61`. Proof `iat` bounds are inclusive (−120 and +60 accept).
13. **Batch challenge encoding.** The `batch` entries' encoding is unspecified; base64url core hashes are used.
14. **`human.reg` status freshness.** The home node's status list follows the same per-class freshness as the route.
15. **RS256 vector.** It carries a junk 256-byte signature with no RSA key. It must be refused on `alg` alone.
16. **Constraints without state.** The reference verifier keeps no shared counters, so `count`, `amount per: grant` and `window` are treated as unsatisfiable (ABY-3 §3 permits this for services that cannot count).
17. **Vouch signer.** OAID-5 §4 does not say which key signs `oaid-vouch+jwt`. The vectors use the voucher's `issue` role key.
18. **Vouching depth with `min_vouchers`.** A node is at depth *d* when at least `min_vouchers` distinct trusted nodes at depth < *d* vouch for it. Anchors and program nodes are depth 0.
19. **Program level cap.** A program node's `max_level` is the lower of the program's anchor entry and the trust list's `programs[].max_level`.
20. **Program keys.** The trust list pins program keys by thumbprint (`kids`) only. The program list carries its JWK in the JWS header (`jwk`), checked against the pin.
21. **Checkpoint key name.** The signed-note key name is the log origin; cosignature key names are the witness node names.
22. **Witness refusals.** A second checkpoint of the same size with another root, and a failed consistency proof, are both labelled `conflict` here; on the wire the witness uses the C2SP `tlog-witness` statuses.
23. **Log promise.** `promise_broken` and `invalid_proof` are monitor findings, not registered error codes.
24. **RFC 9421 `alg`.** Optional; when present, the vectors use the RFC 9421 registry names `ed25519` and `ecdsa-p256-sha256`. `@target-uri` includes the query (unlike `htu`) and is built from `public_origin`. `Signature-Agent` is the quoted node origin.
25. **Display rendering.** One language for the whole display: the human's if every capability has it, else the first common one; no per-line fallback. `scope`, `fields` and `amount` values must match the ABY-3 §2 grammar before rendering, because they are copied into the text the human signs. `{fields}` is joined with ", ".
26. **Approval creation.** A caller that sends `initiator` gets `invalid_request` (it is not silently dropped). `level` must be 1 or 2. `callback` must be `https` on an audience host.
27. **Re-request after denial.** A repeat within 10 minutes of `not_me` or `unknown_agent` is `rate_limited`.
28. **Runtime-initiated challenge.** It also omits `expires`, since no approval exists yet. The problem JSON carries `status` and `single_use: false`.
29. **Issuance codes.** Nonce failures are `invalid_signature`; an unsupported key, an unverified domain operator and tier 0 key reuse are `invalid_request`. The orchestrator evidence format is defined here (`typ: oaid-orchestrator+jwt`, `{iss, runtime, sandbox, key, iat, exp}` in `custody.evidence.orchestrator`); OAID-6 only describes it.
30. **Renewal without evidence** keeps the old `custody` unchanged, including `valid_until`.
