# vectors/

Known-answer vectors for mdip-agent-kit's signature crypto. Docs and expected outputs are in the
main README under "Known-answer vectors (verify with stock OpenSSL, no install)".

| Path | What it is |
|---|---|
| `kav-1/` | Synthetic vector: public test key, non-empty JCS payload, compact + DER signature, tampered negative case |
| `mdip-challenge-1/` | Real MDIP create operations for verifier agent, responder agent, challenge and response, plus the verifier's decrypted `verifyResponse` result (recorded; not re-derivable offline). Also `*.signed-op.bin` so each DID can be recomputed from its op |
| `mdip-challenge-2/` | Real challenge -> response whose **verifier is a PUBLIC TEST identity** (mnemonic + private key published), so the encrypted response can be decrypted offline and its `challenge` field checked against the challenge DID. Also `*.signed-op.bin` so each DID can be recomputed from its op. Suggested by @homies |
| `expiry-cases.txt` | Expiry table (`challenge \| response \| expect \| note`): response.validUntil must be <= challenge.validUntil + 2 h (stock keymaster skew allowed, +2 h + 1 ns rejected), strict RFC 3339 grammar, fail closed |
| `decrypt-openssl.sh` | Stock-OpenSSL decrypt of an MDIP encrypted message (secp256k1 ECDH + XChaCha20-Poly1305, tag checked) |
| `verify-openssl.sh` | Install-free check (bash 3.2+ and OpenSSL ≥ 3.0 only; on macOS set `OPENSSL` to Homebrew's openssl@3). Prints `ALL VECTORS OK` and exits 0 |
| `verify-with-kit.js` | Same checks via `@mdip/cipher` (needs `npm install`), plus re-deriving the PUBLIC TEST verifier key from its mnemonic (BIP32; the one check the shell script can't do) |
| `*/SHA256SUMS` | sha256 of every other file in the dir, one `<64 hex>  <plain name>` per line; unlisted files, dotfiles, symlinks and duplicate lines are rejected (by both checkers) |
| `*.json` | Convenience copies, pretty-printed with keys in JCS order so `verify-openssl.sh` can tie each one to the signed bytes without jq. None is trusted on its own |
| `generate.js` | Regenerates `kav-1/` deterministically |
| `make-mdip-fixture.js` | Re-captures `mdip-challenge-1/` against a gatekeeper (publishes throwaway DIDs) |
| `make-mdip-fixture-2.js` | Re-captures `mdip-challenge-2/` (publishes throwaway DIDs; verifier from the published label mnemonic) |

`test/vectors-negative.sh` (shipped in the package) checks that tampered copies of these vectors are rejected.

Both checkers pin the known answers (kav-1 hash, signature and key label; every DID in both
challenge dirs) and require low-S signatures. Re-capturing a challenge fixture creates new DIDs, so
update the pins in `verify-openssl.sh` and `verify-with-kit.js` when you do.

MDIP does not sign `signature.signed`, so changing it yields a different, still-"valid" DID for the
same signed content. The checkers pin it for these fixtures; see the main README.

No real secrets are in here. `kav-1/test-key.json`, `mdip-challenge-2/test-verifier.json` and
`mdip-challenge-2/verifier-agent.PUBLIC-TEST-KEY.priv.pem` are test keys published on purpose. Never use them.
