{
  "lexicon": 1,
  "id": "net.bisks.alicemeetsbob.pubkey",
  "defs": {
    "main": {
      "type": "record",
      "description": "A person's public ECDH (P-256) key, published so others can derive a shared secret with them for the crush protocol (see net.bisks.alicemeetsbob.crush). Singleton per repo: always written and read at rkey \"self\", overwritten in place if the local keypair is ever regenerated. The matching private key never leaves the owner's browser (stored in IndexedDB). Written and read by alice-meets-bob (https://alice-meets-bob.bisks.net).",
      "key": "literal:self",
      "record": {
        "type": "object",
        "required": ["key", "createdAt"],
        "properties": {
          "key": {
            "type": "ref",
            "ref": "#ecdhPublicJwk",
            "description": "The public half of the account's ECDH P-256 keypair, as a JWK. Used by other users to derive a shared secret via ECDH(theirPrivate, thisPublic)."
          },
          "createdAt": {
            "type": "string",
            "format": "datetime",
            "description": "When this key record was last written, as an ISO 8601 datetime."
          }
        }
      }
    },
    "ecdhPublicJwk": {
      "type": "object",
      "description": "A public EC JWK, exported via SubtleCrypto's exportKey(\"jwk\", ...) and trimmed to just the fields needed to reimport it (kty, crv, x, y — no key_ops/ext/private fields, since this is always a public key).",
      "required": ["kty", "crv", "x", "y"],
      "properties": {
        "kty": { "type": "string", "maxLength": 16, "description": "JWK key type, always \"EC\" for this site's P-256 keys." },
        "crv": { "type": "string", "maxLength": 16, "description": "JWK curve name, always \"P-256\" for this site." },
        "x": { "type": "string", "maxLength": 100, "description": "Base64url-encoded x coordinate of the public point." },
        "y": { "type": "string", "maxLength": 100, "description": "Base64url-encoded y coordinate of the public point." }
      }
    }
  }
}
