{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "commit": {
      "description": "Hash commitment; the owner later writes a com.professorbutts.sports.unseal record with the salt and the record.",
      "type": "token"
    },
    "gameKey": {
      "description": "Encrypted to the subject game's lock key; opened when the game's publisher adds the unlock key at kickoff. The publisher could open it early.",
      "type": "token"
    },
    "lock": {
      "description": "Sealing keys carried on a game record (its optional `seal` field). The publisher adds privateKey, lockedAt and onTime at kickoff, then leaves them unchanged.",
      "properties": {
        "lockedAt": {
          "description": "When the publisher stopped accepting sealed entries.",
          "format": "datetime",
          "type": "string"
        },
        "onTime": {
          "ref": "#onTime",
          "type": "ref"
        },
        "privateKey": {
          "description": "The unlock key, added at kickoff (the tombstone).",
          "maxLength": 32,
          "minLength": 32,
          "type": "bytes"
        },
        "publicKey": {
          "description": "X25519 lock key fans encrypt to.",
          "maxLength": 32,
          "minLength": 32,
          "type": "bytes"
        }
      },
      "required": [
        "publicKey"
      ],
      "type": "object"
    },
    "main": {
      "key": "tid",
      "record": {
        "properties": {
          "ciphertext": {
            "description": "The inner record as canonical JSON (keys sorted, no spaces, UTF-8). gameKey: 12-byte nonce + AES-256-GCM ciphertext + 16-byte tag, key = HKDF-SHA256(X25519(ephemeral, game lock key), salt = ephemeralKey || publicKey, info 'com.professorbutts.sports.sealed'). tlock: tlock-js armored output as UTF-8 bytes.",
            "maxLength": 16000,
            "type": "bytes"
          },
          "collection": {
            "description": "Type of the hidden record, e.g. com.professorbutts.sports.prediction or com.professorbutts.sports.bracket.",
            "format": "nsid",
            "type": "string"
          },
          "createdAt": {
            "format": "datetime",
            "type": "string"
          },
          "drandChain": {
            "description": "tlock: drand chain hash, e.g. quicknet 52db9ba7...e971.",
            "maxLength": 128,
            "type": "string"
          },
          "ephemeralKey": {
            "description": "gameKey: the sealer's one-time X25519 public key.",
            "maxLength": 32,
            "minLength": 32,
            "type": "bytes"
          },
          "hash": {
            "description": "commit: hex sha256 of the salt bytes followed by the inner record as canonical JSON (keys sorted, no spaces, UTF-8, including $type).",
            "maxLength": 128,
            "type": "string"
          },
          "revealAt": {
            "description": "When it may be opened, normally the subject's startsAt.",
            "format": "datetime",
            "type": "string"
          },
          "round": {
            "description": "tlock: drand round whose beacon opens it. Its time must not be earlier than revealAt.",
            "minimum": 1,
            "type": "integer"
          },
          "scheme": {
            "knownValues": [
              "com.professorbutts.sports.sealed#gameKey",
              "com.professorbutts.sports.sealed#tlock",
              "com.professorbutts.sports.sealed#commit"
            ],
            "maxLength": 128,
            "type": "string"
          },
          "subject": {
            "description": "What it is about (game, leaderboard or contest); required for gameKey, which uses this game's lock key. Viewers can show 'sealed prediction' on the right card.",
            "format": "at-uri",
            "type": "string"
          }
        },
        "required": [
          "collection",
          "scheme",
          "revealAt",
          "createdAt"
        ],
        "type": "object"
      },
      "type": "record"
    },
    "onTime": {
      "description": "Fingerprint of every sealed record the publisher saw before lockedAt. Covered by the publisher's signed repo commit, so anyone can check a given entry was on time against the published list.",
      "properties": {
        "count": {
          "minimum": 0,
          "type": "integer"
        },
        "list": {
          "description": "Where the full list can be fetched.",
          "format": "uri",
          "type": "string"
        },
        "root": {
          "description": "Hex sha256 of the sorted lines '<at-uri> <cid>\\n'.",
          "maxLength": 64,
          "type": "string"
        }
      },
      "required": [
        "root",
        "count"
      ],
      "type": "object"
    },
    "tlock": {
      "description": "Time-lock encrypted to a future drand beacon; opens itself at revealAt.",
      "type": "token"
    }
  },
  "description": "A record kept hidden until a set time, e.g. a prediction or bracket nobody can read or copy before kickoff. Default scheme gameKey: encrypted to the lock key published in the game record; the game's publisher adds the unlock key at kickoff (the tombstone), so any viewer of the game can open it. tlock (drand) and commit (hash, owner reveals) need no trust in the game's publisher. Indexers count it from when they first saw it.",
  "id": "com.professorbutts.sports.sealed",
  "lexicon": 1
}
