{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/voting-verifiable-v2.json",
  "title": "Hive Verifiable Voting System v1",
  "description": "Hive Verifiable Voting System commitment checkpoint. It verifies manifest timing, a canonical ballot leaf, RFC 6962 inclusion in a declared batch, and optional anonymized tally set consistency. It does not establish voter eligibility, ballot secrecy, coercion resistance, election authority, or a legally valid result.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_voting\\.verifiable_[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",
        "ballot_id",
        "evidence_digest_sha256",
        "recorded_at",
        "verdict",
        "boundary",
        "election_ref",
        "election_manifest_sha256",
        "manifest_committed_at",
        "poll_open_at",
        "ballot_commitment_sha256",
        "tracker_commitment_sha256",
        "accepted_at",
        "batch_root_sha256",
        "inclusion_path",
        "leaf_index",
        "batch_size",
        "ballot_leaf_sha256",
        "inclusion_relation",
        "tracker_uniqueness_relation",
        "tally_root_relation",
        "elements",
        "outcome"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "voting.verifiable"
        },
        "schema": {
          "type": "string",
          "const": "r2.0.0"
        },
        "ballot_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "evidence_digest_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "SHA-256 of the caller-held evidence bundle this receipt attests was recorded. The service never receives or inspects the underlying evidence, only its digest."
        },
        "recorded_at": {
          "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$"
        },
        "verdict": {
          "type": "object",
          "description": "Service-computed honesty boundary fields. Never caller overridable; recomputed and checked at verify time.",
          "required": [
            "system_operational",
            "voter_eligibility_confirmed",
            "ballot_secrecy_confirmed",
            "election_authority_confirmed",
            "legal_validity_confirmed"
          ],
          "additionalProperties": false,
          "properties": {
            "system_operational": {
              "type": "boolean",
              "const": false
            },
            "voter_eligibility_confirmed": {
              "type": "boolean",
              "const": false
            },
            "ballot_secrecy_confirmed": {
              "type": "boolean",
              "const": false
            },
            "election_authority_confirmed": {
              "type": "boolean",
              "const": false
            },
            "legal_validity_confirmed": {
              "type": "boolean",
              "const": false
            }
          }
        },
        "boundary": {
          "type": "string",
          "const": "Hive Verifiable Voting System commitment checkpoint. It verifies manifest timing, a canonical ballot leaf, RFC 6962 inclusion in a declared batch, and optional anonymized tally set consistency. It does not establish voter eligibility, ballot secrecy, coercion resistance, election authority, or a legally valid result."
        },
        "election_ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "election_manifest_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "manifest_committed_at": {
          "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$"
        },
        "poll_open_at": {
          "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$"
        },
        "ballot_commitment_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "tracker_commitment_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "accepted_at": {
          "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$"
        },
        "batch_root_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "inclusion_path": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "minItems": 0,
          "maxItems": 64
        },
        "leaf_index": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "batch_size": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "anonymized_tally_set": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "tracker_commitment_sha256",
              "ballot_commitment_sha256"
            ],
            "additionalProperties": false,
            "properties": {
              "tracker_commitment_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "ballot_commitment_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              }
            }
          },
          "minItems": 1,
          "maxItems": 4096
        },
        "tally_method": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "published_tally_root_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "ballot_leaf_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "inclusion_relation": {
          "type": "string",
          "enum": [
            "included",
            "not_included"
          ]
        },
        "tracker_uniqueness_relation": {
          "type": "string",
          "enum": [
            "not_supplied",
            "unique",
            "duplicate"
          ]
        },
        "tally_root_relation": {
          "type": "string",
          "enum": [
            "not_supplied",
            "matches",
            "mismatch"
          ]
        },
        "elements": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "manifest_not_precommitted",
              "inclusion_path_mismatch",
              "duplicate_tracker",
              "tally_root_mismatch"
            ]
          },
          "minItems": 0,
          "maxItems": 4
        },
        "outcome": {
          "type": "string",
          "enum": [
            "ballot_included_in_declared_batch",
            "ballot_not_included",
            "inclusion_indeterminate"
          ]
        }
      }
    }
  }
}
