{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://usedeed.app/contracts/deed.proof_card.external_attestation.v1.schema.json",
  "title": "DEED proof-card external attestation v1",
  "type": "object",
  "required": ["schema", "cardId", "head", "mark", "attester", "independence", "verification", "issuedAt", "sig"],
  "properties": {
    "schema": { "const": "https://usedeed.app/contracts/deed.proof_card.external_attestation.v1.schema.json" },
    "cardId": { "type": "string", "pattern": "^zvpc_sha256_[0-9a-f]{64}$" },
    "head": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
    "mark": { "type": "string", "minLength": 1 },
    "attester": {
      "type": "object",
      "required": ["type", "entity"],
      "properties": {
        "type": { "const": "independent-verifier" },
        "entity": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "independence": {
      "type": "object",
      "required": [
        "schema",
        "deedControlOrEmployment",
        "deedHostedVerifierDependencies",
        "deedNetworkAccessRequired",
        "deedProvidedSigningKey",
        "counterSignatureGrantsCustody",
        "counterSignatureGrantsRevocationAuthority",
        "statement"
      ],
      "properties": {
        "schema": { "const": "https://usedeed.app/contracts/deed.proof_card.external_independence.v1.schema.json" },
        "deedControlOrEmployment": { "const": false },
        "deedHostedVerifierDependencies": { "const": false },
        "deedNetworkAccessRequired": { "const": false },
        "deedProvidedSigningKey": { "const": false },
        "counterSignatureGrantsCustody": { "const": false },
        "counterSignatureGrantsRevocationAuthority": { "const": false },
        "statement": { "const": "The attester is a non-DEED independent verifier, ran the published standalone verifier without DEED-hosted dependencies or DEED network access, used a non-DEED-provided signing key, and this counter-signature grants no custody or revocation authority." }
      },
      "additionalProperties": false
    },
    "verification": {
      "type": "object",
      "required": ["method", "command", "result", "controlsVerified", "repoCommit", "cardPayloadSha256", "formalTreeHash", "verifierPackage"],
      "properties": {
        "method": { "const": "standalone-verifier" },
        "command": { "type": "string", "pattern": "packages/deed-card-verify/index\\.mjs" },
        "result": { "const": "exit 0" },
        "controlsVerified": { "const": 9 },
        "repoCommit": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
        "cardPayloadSha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
        "formalTreeHash": { "type": "object" },
        "verifierPackage": {
          "type": "object",
          "required": ["path", "hashAlgorithm", "sha256", "npmPackage"],
          "properties": {
            "path": { "const": "packages/deed-card-verify/index.mjs" },
            "hashAlgorithm": { "const": "sha256-source-v1" },
            "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
            "npmPackage": { "type": "object" }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "issuedAt": { "type": "string", "format": "date-time" },
    "sig": {
      "type": "object",
      "required": ["alg", "keyId", "value", "publicKeyJwk"],
      "properties": {
        "alg": { "const": "ECDSA-P256-SHA256" },
        "keyId": { "type": "string", "minLength": 1 },
        "value": { "type": "string", "minLength": 1 },
        "publicKeyJwk": {
          "type": "object",
          "required": ["kty", "crv", "x", "y"],
          "properties": {
            "kty": { "const": "EC" },
            "crv": { "const": "P-256" },
            "x": { "type": "string", "minLength": 1 },
            "y": { "type": "string", "minLength": 1 },
            "d": false
          },
          "additionalProperties": true
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
