{
  "lexicon": 1,
  "id": "at.didcomm.keyPackage",
  "description": "Binds an atproto identity to a DIDComm messaging identity. Published by the user in their own PDS; discovered by senders to enable atproto-handle-addressed, end-to-end-encrypted DIDComm messaging. This record is the open interop contract — any client may implement it.",
  "defs": {
    "main": {
      "type": "record",
      "key": "literal:self",
      "description": "MVP uses a single key package at rkey 'self' (one messaging identity per account). Multi-device support is a future extension: switch key to 'tid' so each device publishes its own record, and senders encrypt to every advertised keyAgreement key.",
      "record": {
        "type": "object",
        "required": ["did", "mediators", "createdAt"],
        "properties": {
          "did": {
            "type": "string",
            "format": "did",
            "description": "DIDComm messaging identity (a did:peer:2 carrying the X25519 keyAgreement key). Encryption keys live here, NOT in the atproto did:plc document."
          },
          "mediators": {
            "type": "array",
            "minLength": 1,
            "description": "Mediator DIDs (did:web) that accept forwarded messages for this identity, in failover preference order. The sender delivers a DIDComm forward envelope to the first reachable one.",
            "items": { "type": "string", "format": "did" }
          },
          "label": {
            "type": "string",
            "maxGraphemes": 64,
            "maxLength": 640,
            "description": "Human-readable device/identity label, e.g. 'phone'."
          },
          "createdAt": {
            "type": "string",
            "format": "datetime",
            "description": "When this key package was published."
          }
        }
      }
    }
  }
}
