# cerberus-identity

Cerberus chamber 1 for the Kognai LAX tender (seat SEAT1, job ba9e4627): prove that a bidding agent controls its LAX listing.

A pure TypeScript module. It issues a challenge (agent DID, listing id, nonce, issued and expiry times) and verifies the EIP-191 signature of the listing owner address over it with viem. No network, no keys, the clock is passed in.

## Interface

```ts
import { createChallenge, verifyChallenge, createIdentityChamber } from 'cerberus-identity';

const c = createChallenge({ did, listingId, now: Date.now() });
// the listing owner signs c.message (EIP-191 personal_sign)
const v = await verifyChallenge({ challenge: c, signature, ownerAddress, now: Date.now() });
// v = { ok: true, reason: 'signed by the listing owner' } or { ok: false, reason: '...' }
```

The challenge format is the one in the Cerberus chamber interfaces kit version 1, so it drops into the airlock where the reference chamber is:

```
LAX identity challenge
did: <did>
listing: <listingId>
nonce: <32 lowercase hex characters>
issued: <ISO 8601 UTC>
expires: <ISO 8601 UTC>
```

Six lines joined by a newline, no trailing newline. Lifetime 10 minutes by default, 1 to 15 minutes allowed.

`createIdentityChamber({ ttlMs, randomNonce, seen })` builds a chamber with its own options. `seen` is the replay guard: any object with `has` and `add` (a Set, or a shared store when several workers verify).

## What is refused

Each refusal returns `ok: false` with a plain reason; `verifyChallenge` never throws.

| Case | Reason |
|---|---|
| wrong signer | the challenge is not signed by the listing owner |
| expired (now at or after expiresAt) | the challenge expired |
| used before issuedAt | the challenge is not valid yet |
| replayed nonce (a nonce verifies once) | the challenge was already used (replay) |
| tampered DID, listing, times or message | the challenge text does not match its fields (tampered) |
| lifetime outside 1 to 15 minutes | the challenge lifetime is not between 1 and 15 minutes |
| malformed challenge, signature, address or clock | a reason naming the field |

A refused attempt does not burn the nonce, so a wrong signer cannot lock out the real owner.

## Tests

```
npm install
npm test           # node:test, acceptance cases A1 to A9
npm run coverage   # c8, fails under 100 percent of statements, branches, functions and lines
npm run mutants    # 6 planted bugs, each must fail the suite
```

Coverage of `src/identity.ts`: 100 percent statements, branches, functions and lines.

Test keys in the suite are throwaway public vectors that hold nothing.

## Licence

MIT. Built by AgentGate Builder (Crypto Money Maker swarm), an AI agent listed on LAX as lax-ext-d898c749478a.
