{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://zk-sbom-passport.org/spec/eu-dpp-vc-v2.schema.json",
  "title": "EU Digital Product Passport W3C Verifiable Credential v2.0",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "@context",
    "id",
    "type",
    "issuer",
    "validFrom",
    "validUntil",
    "credentialSubject",
    "proof"
  ],
  "properties": {
    "@context": {
      "type": "array",
      "minItems": 2,
      "items": { "type": "string", "minLength": 1 }
    },
    "id": { "type": "string", "minLength": 1, "maxLength": 256 },
    "type": {
      "type": "array",
      "minItems": 2,
      "items": { "type": "string", "minLength": 1 }
    },
    "issuer": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "keys"],
      "properties": {
        "id": { "type": "string", "pattern": "^did:[a-z0-9-]+:.+" },
        "keys": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": ["key_id", "ed25519_pk_b64u", "mldsa65_pk_b64u"],
              "properties": {
                "key_id": { "type": "string", "minLength": 3, "maxLength": 64 },
                "pq_alg": { "const": "ml-dsa-65" },
                "ed25519_pk_b64u": { "type": "string", "pattern": "^[A-Za-z0-9_-]{43}$" },
                "mldsa65_pk_b64u": { "type": "string", "minLength": 2000, "maxLength": 3000 }
              }
            },
            {
              "type": "object",
              "additionalProperties": false,
              "required": ["key_id", "pq_alg", "ed25519_pk_b64u", "mldsa87_pk_b64u"],
              "properties": {
                "key_id": { "type": "string", "minLength": 3, "maxLength": 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}$" }
              }
            }
          ]
        }
      }
    },
    "validFrom": { "type": "string", "format": "date-time" },
    "validUntil": { "type": "string", "format": "date-time" },
    "credentialSubject": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "passport_schema_version",
        "passport_id",
        "artifact_sha256",
        "assurance_tier",
        "post_quantum_zk",
        "vex_exemption_count",
        "policy_id",
        "policy_root",
        "passport_digest_sha256",
        "embedded_passport"
      ],
      "properties": {
        "id": { "type": "string", "minLength": 1, "maxLength": 256 },
        "passport_schema_version": {
          "type": "string",
          "enum": ["zk-sbom-passport/v1", "zk-sbom-composite-passport/v1"]
        },
        "passport_id": { "type": "string", "pattern": "^[0-9a-f]{32}$" },
        "artifact_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
        "assurance_tier": {
          "type": "string",
          "enum": ["T1-SelfAttested", "T2-TEE-Attested", "T3-Forensic-ZeroSource"]
        },
        "post_quantum_zk": { "type": "boolean" },
        "vex_exemption_count": { "type": "integer", "minimum": 0, "maximum": 16384 },
        "policy_id": { "type": "string", "pattern": "^[a-zA-Z0-9._-]{3,64}$" },
        "policy_root": { "type": "string", "pattern": "^[0-9]{1,78}$" },
        "passport_digest_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
        "embedded_passport": { "type": "object" }
      }
    },
    "credentialStatus": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "type", "statusPurpose", "statusListIndex", "statusListCredential"],
      "properties": {
        "id": { "type": "string", "minLength": 1, "maxLength": 512 },
        "type": { "type": "string", "const": "BitstringStatusListEntry" },
        "statusPurpose": { "type": "string", "enum": ["revocation", "suspension"] },
        "statusListIndex": { "type": "string", "pattern": "^(0|[1-9][0-9]{0,9})$" },
        "statusListCredential": { "type": "string", "minLength": 1, "maxLength": 512 }
      }
    },
    "proof": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "cryptosuite",
        "created",
        "proofPurpose",
        "verificationMethod",
        "dual_signature"
      ],
      "properties": {
        "type": { "type": "string", "const": "DataIntegrityProof" },
        "cryptosuite": {
          "type": "string",
          "enum": ["zkpass-ed25519-mldsa65-jcs-2026", "zkpass-ed25519-mldsa87-jcs-2026"]
        },
        "created": { "type": "string", "format": "date-time" },
        "proofPurpose": { "type": "string", "const": "assertionMethod" },
        "verificationMethod": { "type": "string", "minLength": 6, "maxLength": 320 },
        "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}$" }
              }
            }
          ]
        }
      }
    }
  }
}
