{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://golfsga.com/sga-ois/schema/0.1/attest.schema.json",
  "title": "SGA-OIS contribution signature",
  "description": "A device's signature over one contribution (02 section 3a). Carried inline as attest, or afterwards in its own record.attest message when signing must not delay the contribution (02 section 3a.1).",
  "type": "object",
  "required": [
    "type",
    "counter",
    "attest"
  ],
  "additionalProperties": false,
  "properties": {
    "type": {
      "const": "record.attest",
      "description": "Message type discriminator. Always record.attest."
    },
    "shot_id": {
      "$ref": "common.schema.json#/$defs/sgaId",
      "description": "The shot the signed contribution belongs to, where it had one."
    },
    "counter": {
      "type": "integer",
      "minimum": 0,
      "description": "The contribution counter this signature covers."
    },
    "attest": {
      "$ref": "#/$defs/attest"
    }
  },
  "$defs": {
    "attest": {
      "type": "object",
      "required": [
        "counter",
        "key_id",
        "sig"
      ],
      "additionalProperties": false,
      "properties": {
        "counter": {
          "type": "integer",
          "minimum": 0,
          "description": "Monotonic per device per session (02 section 3a)."
        },
        "alg": {
          "enum": [
            "ed25519",
            "p256"
          ],
          "default": "ed25519"
        },
        "key_id": {
          "type": "string",
          "maxLength": 128
        },
        "sig": {
          "type": "string",
          "contentEncoding": "base64",
          "description": "Over the canonical form 02 section 3a defines."
        }
      },
      "patternProperties": {
        "^x-[a-z0-9_-]+\\.": {}
      }
    }
  },
  "patternProperties": {
    "^x-[a-z0-9_-]+\\.": {}
  }
}
