{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/authority-qualification-v1.json",
  "title": "Authority Qualification Receipt, v1",
  "description": "Canonical schema for the Hive authority qualification receipt, canonical type authority.qualification. The instrument evaluates the step before a grant: whether the granting party was itself entitled to grant the scope it granted, at the instant it granted it, as independently qualified by a party disjoint from both granter and grantee, strictly before issuance.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_authority[.]qualification_[0-9]{10,}_[0-9a-f]{12}$"
    },
    "payload_sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "sig_b64u": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{86}$"
    },
    "key_id": {
      "type": "string",
      "pattern": "^did:(hive|web|key):[A-Za-z0-9._:%-]+$"
    },
    "algorithm": {
      "type": "string",
      "const": "Ed25519"
    },
    "ts": {
      "type": "integer",
      "minimum": 1000000000
    },
    "signed_body": {
      "type": "object",
      "required": [
        "receipt_type",
        "schema",
        "qualification_id",
        "granter",
        "grantee",
        "entitlement",
        "grant",
        "qualifier",
        "containment",
        "qualification",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "authority.qualification"
        },
        "schema": {
          "type": "string",
          "const": "r1.0.0"
        },
        "qualification_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$"
        },
        "granter": {
          "type": "object",
          "required": [
            "granter_commitment",
            "salt_commitment"
          ],
          "additionalProperties": false,
          "properties": {
            "granter_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "salt_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        },
        "grantee": {
          "type": "object",
          "required": [
            "grantee_commitment"
          ],
          "additionalProperties": false,
          "properties": {
            "grantee_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        },
        "entitlement": {
          "type": "object",
          "required": [
            "source_receipt",
            "granter_commitment",
            "scope_class_commitments",
            "residual_minor_units",
            "residual_commitment",
            "numeraire_commitment",
            "not_before",
            "not_after"
          ],
          "additionalProperties": false,
          "properties": {
            "source_receipt": {
              "type": "object",
              "required": [
                "receipt_id",
                "receipt_type",
                "envelope_sha256",
                "issuance_instant"
              ],
              "additionalProperties": false,
              "properties": {
                "receipt_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                },
                "receipt_type": {
                  "type": "string",
                  "const": "authority.entitlement"
                },
                "envelope_sha256": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                },
                "issuance_instant": {
                  "type": "object",
                  "required": [
                    "utc",
                    "drift_seconds"
                  ],
                  "additionalProperties": false,
                  "properties": {
                    "utc": {
                      "type": "string",
                      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$"
                    },
                    "drift_seconds": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 86400
                    }
                  }
                }
              }
            },
            "granter_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "scope_class_commitments": {
              "type": "array",
              "minItems": 1,
              "maxItems": 64,
              "items": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              }
            },
            "residual_minor_units": {
              "type": "integer",
              "minimum": 0,
              "maximum": 999999999999999
            },
            "residual_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "numeraire_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "not_before": {
              "type": "object",
              "required": [
                "utc",
                "drift_seconds"
              ],
              "additionalProperties": false,
              "properties": {
                "utc": {
                  "type": "string",
                  "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$"
                },
                "drift_seconds": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 86400
                }
              }
            },
            "not_after": {
              "type": "object",
              "required": [
                "utc",
                "drift_seconds"
              ],
              "additionalProperties": false,
              "properties": {
                "utc": {
                  "type": "string",
                  "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$"
                },
                "drift_seconds": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 86400
                }
              }
            }
          }
        },
        "grant": {
          "type": "object",
          "required": [
            "grant_receipt",
            "granter_commitment",
            "grantee_commitment",
            "scope_class_commitments",
            "granted_minor_units",
            "granted_commitment",
            "numeraire_commitment",
            "issuance_instant"
          ],
          "additionalProperties": false,
          "properties": {
            "grant_receipt": {
              "type": "object",
              "required": [
                "receipt_id",
                "receipt_type",
                "envelope_sha256"
              ],
              "additionalProperties": false,
              "properties": {
                "receipt_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                },
                "receipt_type": {
                  "type": "string",
                  "const": "authority.grantinstrument"
                },
                "envelope_sha256": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$"
                }
              }
            },
            "granter_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "grantee_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "scope_class_commitments": {
              "type": "array",
              "minItems": 1,
              "maxItems": 64,
              "items": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              }
            },
            "granted_minor_units": {
              "type": "integer",
              "minimum": 0,
              "maximum": 999999999999999
            },
            "granted_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "numeraire_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "issuance_instant": {
              "type": "object",
              "required": [
                "utc",
                "drift_seconds"
              ],
              "additionalProperties": false,
              "properties": {
                "utc": {
                  "type": "string",
                  "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$"
                },
                "drift_seconds": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 86400
                }
              }
            }
          }
        },
        "qualifier": {
          "type": "object",
          "required": [
            "qualifier_commitment",
            "qualification_class",
            "record_id",
            "record_sha256",
            "qualification_instant"
          ],
          "additionalProperties": false,
          "properties": {
            "qualifier_commitment": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "qualification_class": {
              "type": "string",
              "enum": [
                "independent_registry_check",
                "countersigned_source",
                "self_asserted"
              ]
            },
            "record_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "record_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "qualification_instant": {
              "type": "object",
              "required": [
                "utc",
                "drift_seconds"
              ],
              "additionalProperties": false,
              "properties": {
                "utc": {
                  "type": "string",
                  "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$"
                },
                "drift_seconds": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 86400
                }
              }
            }
          }
        },
        "containment": {
          "type": "object",
          "required": [
            "scope_relation",
            "quantity_relation",
            "interval_relation",
            "qualifier_relation"
          ],
          "additionalProperties": false,
          "properties": {
            "scope_relation": {
              "type": "string",
              "enum": [
                "granted_scope_within_entitled_scope",
                "granted_scope_exceeds_entitled_scope"
              ]
            },
            "quantity_relation": {
              "type": "string",
              "enum": [
                "granted_within_residual",
                "granted_exceeds_residual"
              ]
            },
            "interval_relation": {
              "type": "string",
              "enum": [
                "issuance_within_entitlement_interval",
                "issuance_outside_entitlement_interval",
                "indeterminate"
              ]
            },
            "qualifier_relation": {
              "type": "string",
              "enum": [
                "qualifier_disjoint_from_parties",
                "qualifier_is_a_party"
              ]
            }
          }
        },
        "qualification": {
          "type": "string",
          "enum": [
            "qualified",
            "unqualified",
            "indeterminate"
          ]
        },
        "boundary": {
          "type": "string",
          "const": "This receipt attests only that a named grant, a named entitlement source held by the granting party, and a named qualification record satisfy the stated deterministic containment and ordering procedure over disclosed commitments. It does not establish that the entitlement source is genuine, accurate, current, lawfully obtained, or sufficient under any contract, mandate, charter, licence, regulation, or statute. It does not establish that the qualifier is competent, diligent, independent in fact, or free of conflict. A qualification of qualified does not make the grant valid, enforceable, or binding, does not ratify the grant, and does not authorize the grantee to act. A qualification of unqualified does not make the grant void, does not establish fault, breach, negligence, or bad faith, and does not allocate risk, responsibility, liability, loss, or remedy. This receipt decides no contractual, statutory, regulatory, evidentiary, or legal consequence, and it authorizes no action, payment, sanction, denial, or remedy."
        }
      }
    }
  }
}
