{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://zk-sbom-passport.org/spec/zk-sbom-passport-v1.schema.json",
  "title": "zk-sbom-passport/v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "payload", "dual_signature"],
  "properties": {
    "schema_version": { "type": "string", "const": "zk-sbom-passport/v1" },
    "payload": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "passport_id",
        "assurance_tier",
        "issued_at",
        "valid_until",
        "max_age_seconds",
        "subject",
        "policy",
        "commitments",
        "zk_proof",
        "supplier_keys",
        "legal_attestation_boundary"
      ],
      "properties": {
        "passport_id": { "type": "string", "pattern": "^[0-9a-f]{32}$" },
        "assurance_tier": {
          "type": "string",
          "enum": ["T1-SelfAttested", "T2-TEE-Attested", "T3-Forensic-ZeroSource"]
        },
        "issued_at": { "type": "string", "format": "date-time" },
        "valid_until": { "type": "string", "format": "date-time" },
        "max_age_seconds": { "type": "integer", "minimum": 60, "maximum": 31536000 },
        "subject": {
          "type": "object",
          "additionalProperties": false,
          "required": ["artifact_sha256", "sbom_format"],
          "properties": {
            "artifact_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
            "sbom_format": { "type": "string", "enum": ["CycloneDX-1.6", "CycloneDX-1.7", "SPDX-2.2", "SPDX-2.3", "SPDX-3.0.1"] }
          }
        },
        "policy": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "policy_id",
            "policy_root",
            "policy_issued_at",
            "policy_valid_until",
            "authority_key_id"
          ],
          "properties": {
            "policy_id": { "type": "string", "pattern": "^[a-zA-Z0-9._-]{3,64}$" },
            "policy_root": { "type": "string", "pattern": "^[0-9]{1,78}$" },
            "policy_issued_at": { "type": "string", "format": "date-time" },
            "policy_valid_until": { "type": "string", "format": "date-time" },
            "authority_key_id": { "type": "string", "pattern": "^[a-zA-Z0-9._-]{3,64}$" }
          }
        },
        "commitments": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "sbom_commitment",
            "bucket_capacity",
            "chunk_size",
            "chunk_count",
            "vex_root",
            "vex_exemption_count",
            "vex_justification_histogram"
          ],
          "properties": {
            "sbom_commitment": { "type": "string", "pattern": "^[0-9]{1,78}$" },
            "bucket_capacity": { "type": "integer", "enum": [8, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384] },
            "chunk_size": { "type": "integer", "const": 4 },
            "chunk_count": { "type": "integer", "enum": [1, 2, 8, 16, 32, 64, 128, 256] },
            "vex_root": { "type": "string", "pattern": "^[0-9]{1,78}$" },
            "vex_exemption_count": { "type": "integer", "minimum": 0, "maximum": 128 },
            "vex_justification_histogram": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "component_not_present",
                "vulnerable_code_not_present",
                "vulnerable_code_not_in_execute_path",
                "vulnerable_code_cannot_be_controlled_by_adversary",
                "inline_mitigations_already_exist"
              ],
              "properties": {
                "component_not_present": { "type": "integer", "minimum": 0, "maximum": 128 },
                "vulnerable_code_not_present": { "type": "integer", "minimum": 0, "maximum": 128 },
                "vulnerable_code_not_in_execute_path": { "type": "integer", "minimum": 0, "maximum": 128 },
                "vulnerable_code_cannot_be_controlled_by_adversary": { "type": "integer", "minimum": 0, "maximum": 128 },
                "inline_mitigations_already_exist": { "type": "integer", "minimum": 0, "maximum": 128 }
              }
            }
          }
        },
        "zk_proof": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": ["system", "curve", "vk_sha256", "chunks"],
              "properties": {
                "system": { "type": "string", "const": "plonk-snarkjs" },
                "curve": { "type": "string", "const": "bn128" },
                "vk_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
                "chunks": {
                  "type": "array",
                  "minItems": 2,
                  "maxItems": 256,
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": ["index", "public_signals", "proof"],
                    "properties": {
                      "index": { "type": "integer", "minimum": 0, "maximum": 255 },
                      "public_signals": {
                        "type": "array",
                        "minItems": 15,
                        "maxItems": 15,
                        "items": { "type": "string", "pattern": "^[0-9]{1,78}$" }
                      },
                      "proof": { "type": "object" }
                    }
                  }
                }
              }
            },
            {
              "type": "object",
              "additionalProperties": false,
              "required": ["system", "field", "hash", "transparent_setup", "security_bits", "proof_b64u", "public_inputs"],
              "properties": {
                "system": { "type": "string", "const": "stark-winterfell-pq" },
                "field": { "type": "string", "const": "f128" },
                "hash": { "type": "string", "const": "blake3_256" },
                "transparent_setup": { "type": "boolean", "const": true },
                "security_bits": { "type": "integer", "minimum": 128 },
                "proof_bytes": { "type": "integer", "minimum": 1 },
                "proof_b64u": { "type": "string", "pattern": "^[A-Za-z0-9_-]{64,}$" },
                "public_inputs": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": ["policy_root_stark", "vex_root_stark", "artifact_hash_stark", "sbom_commitment_stark", "vex_just_counts"],
                  "properties": {
                    "policy_root_stark": { "type": "array", "minItems": 2, "maxItems": 2, "items": { "type": "string", "pattern": "^[0-9]{1,39}$" } },
                    "vex_root_stark": { "type": "array", "minItems": 2, "maxItems": 2, "items": { "type": "string", "pattern": "^[0-9]{1,39}$" } },
                    "artifact_hash_stark": { "type": "array", "minItems": 3, "maxItems": 3, "items": { "type": "string", "pattern": "^[0-9]{1,39}$" } },
                    "sbom_commitment_stark": { "type": "array", "minItems": 2, "maxItems": 2, "items": { "type": "string", "pattern": "^[0-9]{1,39}$" } },
                    "vex_just_counts": { "type": "array", "minItems": 5, "maxItems": 5, "items": { "type": "integer", "minimum": 0, "maximum": 16384 } }
                  }
                }
              }
            }
          ]
        },
        "supplier_keys": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": ["key_id", "ed25519_pk_b64u", "mldsa65_pk_b64u"],
              "properties": {
                "key_id": { "type": "string", "pattern": "^[a-zA-Z0-9._-]{3,64}$" },
                "pq_alg": { "const": "ml-dsa-65" },
                "ed25519_pk_b64u": { "type": "string", "pattern": "^[A-Za-z0-9_-]{43}$" },
                "mldsa65_pk_b64u": { "type": "string", "pattern": "^[A-Za-z0-9_-]{2600,2610}$" }
              }
            },
            {
              "type": "object",
              "additionalProperties": false,
              "required": ["key_id", "pq_alg", "ed25519_pk_b64u", "mldsa87_pk_b64u"],
              "properties": {
                "key_id": { "type": "string", "pattern": "^[a-zA-Z0-9._-]{3,64}$" },
                "pq_alg": { "const": "ml-dsa-87" },
                "ed25519_pk_b64u": { "type": "string", "pattern": "^[A-Za-z0-9_-]{43}$" },
                "mldsa87_pk_b64u": { "type": "string", "pattern": "^[A-Za-z0-9_-]{3456}$" }
              }
            }
          ]
        },
        "legal_attestation_boundary": {
          "type": "object",
          "additionalProperties": false,
          "required": ["opening_protocol", "regulatory_scope", "notified_body_disclaimer_code"],
          "properties": {
            "opening_protocol": { "type": "string", "const": "EU-CRA-Annex-VII-Vault-v1" },
            "regulatory_scope": {
              "type": "array",
              "minItems": 1,
              "maxItems": 10,
              "items": {
                "type": "string",
                "enum": [
                  "EU-CRA-2024-2847",
                  "NIS2-BSIG-30",
                  "CISA-KEV-2026",
                  "DORA",
                  "FDA-SBOM",
                  "BSI-TR-03183-2",
                  "EU-AI-ACT-2024-1689",
                  "CNSA-2.0-PQC"
                ]
              }
            },
            "notified_body_disclaimer_code": { "type": "string", "const": "MODULE-A-AND-PRE-VERIFICATION-ONLY" }
          }
        },
        "t2_attestation": {
          "type": "object",
          "additionalProperties": false,
          "required": ["schema_version", "payload", "quote_b64u", "dual_signature"],
          "properties": {
            "schema_version": { "type": "string", "const": "t2-tee-attestation/v1" },
            "payload": {
              "type": "object",
              "additionalProperties": false,
              "required": ["tee_platform", "measurement_hex", "report_data_hex", "quote_sha256", "issued_at", "tee_endorser_keys"],
              "properties": {
                "tee_platform": { "type": "string", "enum": ["intel-tdx", "amd-sev-snp", "aws-nitro-enclave"] },
                "measurement_hex": { "type": "string", "pattern": "^[0-9a-f]{64,96}$" },
                "report_data_hex": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
                "quote_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
                "issued_at": { "type": "string", "format": "date-time" },
                "tee_endorser_keys": { "type": "object" },
                "slsa_builder_id": { "type": "string" },
                "slsa_provenance_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
              }
            },
            "quote_b64u": { "type": "string", "pattern": "^[A-Za-z0-9_-]+$" },
            "dual_signature": { "type": "object" },
            "slsa_provenance": { "type": "object" }
          }
        }
      }
    },
    "dual_signature": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["digest_sha256", "ed25519_sig_b64u", "mldsa65_sig_b64u"],
          "properties": {
            "digest_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
            "pq_alg": { "const": "ml-dsa-65" },
            "ed25519_sig_b64u": { "type": "string", "pattern": "^[A-Za-z0-9_-]{86}$" },
            "mldsa65_sig_b64u": { "type": "string", "pattern": "^[A-Za-z0-9_-]{4410,4420}$" }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["digest_sha256", "pq_alg", "ed25519_sig_b64u", "mldsa87_sig_b64u"],
          "properties": {
            "digest_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
            "pq_alg": { "const": "ml-dsa-87" },
            "ed25519_sig_b64u": { "type": "string", "pattern": "^[A-Za-z0-9_-]{86}$" },
            "mldsa87_sig_b64u": { "type": "string", "pattern": "^[A-Za-z0-9_-]{6170}$" }
          }
        }
      ]
    },
    "scitt_receipt": {
      "type": "object",
      "additionalProperties": false,
      "required": ["schema_version", "entry", "inclusion_path", "sth", "sth_dual_signature"],
      "properties": {
        "schema_version": { "type": "string", "const": "scitt-receipt/v1" },
        "entry": { "type": "object" },
        "inclusion_path": { "type": "array" },
        "sth": { "type": "object" },
        "sth_dual_signature": { "type": "object" }
      }
    }
  }
}
