{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:orbiplex:schema:nym-issuance-request:v1",
  "title": "nym-issuance-request.v1",
  "type": "object",
  "additionalProperties": false,
  "x-dia-workflow": "project",
  "x-dia-status": "draft",
  "x-dia-basis": [
    "doc/project/40-proposals/015-nym-certificates-and-renewal-baseline/contextual-whisper-authorship.md"
  ],
  "required": [
    "schema",
    "operation",
    "applicant/id",
    "issuer/id",
    "reply/recipient",
    "reply/key",
    "profile/digest",
    "context/digest",
    "epoch",
    "nym/id",
    "request/nonce",
    "issued/at",
    "expires/at",
    "nym/proof",
    "signature",
    "topic/key",
    "exchange/handle",
    "bootstrap/key-public",
    "bootstrap/proof"
  ],
  "properties": {
    "schema": {
      "const": "nym-issuance-request.v1"
    },
    "operation": {
      "enum": [
        "issue",
        "renew",
        "private-reset"
      ]
    },
    "applicant/id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 180,
      "pattern": "^participant:did:key:z[1-9A-HJ-NP-Za-km-z]+$"
    },
    "issuer/id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 180,
      "pattern": "^council:did:key:z[1-9A-HJ-NP-Za-km-z]+$"
    },
    "reply/recipient": {
      "type": "string",
      "minLength": 1,
      "maxLength": 180,
      "pattern": "^participant:did:key:z[1-9A-HJ-NP-Za-km-z]+$"
    },
    "reply/key": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "pattern": "^[A-Za-z0-9_-]{43}$"
    },
    "profile/digest": {
      "type": "string",
      "minLength": 1,
      "maxLength": 50,
      "pattern": "^sha256:[A-Za-z0-9_-]{43}$"
    },
    "context/digest": {
      "type": "string",
      "minLength": 1,
      "maxLength": 50,
      "pattern": "^sha256:[A-Za-z0-9_-]{43}$"
    },
    "epoch": {
      "type": "integer",
      "minimum": 1
    },
    "nym/id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 180,
      "pattern": "^nym:did:key:z[1-9A-HJ-NP-Za-km-z]+$"
    },
    "request/nonce": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "pattern": "^[A-Za-z0-9_-]{43}$"
    },
    "issued/at": {
      "type": "string",
      "format": "date-time"
    },
    "expires/at": {
      "type": "string",
      "format": "date-time"
    },
    "prior/certificate-digest": {
      "type": "string",
      "minLength": 1,
      "maxLength": 50,
      "pattern": "^sha256:[A-Za-z0-9_-]{43}$"
    },
    "nym/proof": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "alg",
        "value"
      ],
      "properties": {
        "alg": {
          "const": "ed25519"
        },
        "value": {
          "type": "string",
          "minLength": 1,
          "maxLength": 86,
          "pattern": "^[A-Za-z0-9_-]{86}$"
        }
      }
    },
    "signature": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "alg",
        "value"
      ],
      "properties": {
        "alg": {
          "const": "ed25519"
        },
        "value": {
          "type": "string",
          "minLength": 1,
          "maxLength": 86,
          "pattern": "^[A-Za-z0-9_-]{86}$"
        }
      }
    },
    "topic/key": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "pattern": "^[^*]+$"
    },
    "exchange/handle": {
      "type": "string",
      "minLength": 52,
      "maxLength": 52,
      "pattern": "^exchange:[A-Za-z0-9_-]{43}$",
      "description": "Independent opaque 256-bit transport correlation; never the private signed request digest."
    },
    "bootstrap/key-public": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^z[1-9A-HJ-NP-Za-km-z]+$",
      "description": "Domain-separated ephemeral Ed25519 bootstrap proof key; not the participant or nym public key."
    },
    "bootstrap/proof": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "alg",
        "value"
      ],
      "properties": {
        "alg": {
          "const": "ed25519"
        },
        "value": {
          "type": "string",
          "minLength": 1,
          "maxLength": 86,
          "pattern": "^[A-Za-z0-9_-]{86}$"
        }
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "operation": {
            "const": "issue"
          }
        },
        "required": [
          "operation"
        ]
      },
      "then": {
        "not": {
          "required": [
            "prior/certificate-digest"
          ]
        }
      },
      "else": {
        "required": [
          "prior/certificate-digest"
        ]
      }
    }
  ]
}
