{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/spectralzk-v1.json",
  "title": "SpectralZK v1 — Spectral Zero-Knowledge Receipt",
  "description": "Canonical schema for SpectralZK v1 non-interactive zero-knowledge proofs of policy-bound action satisfaction. A Hive Civilization canonical primitive. Proves three statements without revealing the policy text or which constraint satisfied the action: (1) PREIMAGE knowledge of policy_id under commitment C, (2) MEMBERSHIP of a satisfying constraint in the policy's Merkle tree, (3) SATISFACTION of the public action by the hidden constraint. Construction: Schnorr signature of knowledge (Ed25519) over a Fiat-Shamir transcript with blinded Merkle path commitments under RFC 8785 JCS canonicalization.",
  "type": "object",
  "required": [
    "protocol",
    "policy_commitment",
    "merkle_root",
    "action",
    "path",
    "issuer_pubkey",
    "challenge_sha256",
    "schnorr_sig"
  ],
  "additionalProperties": false,
  "properties": {
    "protocol": {
      "type": "string",
      "const": "spectralzk/1",
      "description": "Protocol identifier. Must be the literal 'spectralzk/1' for this schema version."
    },
    "policy_commitment": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{43}$",
      "description": "Base64url-encoded 32-byte SHA-256 commitment to (policy_id || '||' || merkle_root). Public. Hides the policy_id and constraint set."
    },
    "merkle_root": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{43}$",
      "description": "Base64url-encoded 32-byte SHA-256 root of the constraint Merkle tree. Public. Hides individual constraint leaves."
    },
    "action": {
      "type": "object",
      "required": ["attr", "value"],
      "additionalProperties": false,
      "properties": {
        "attr": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "description": "Action attribute name (e.g. 'spend_usd_per_day')."
        },
        "value": {
          "type": "integer",
          "description": "Action attribute value being attested. Public."
        }
      },
      "description": "The public action whose satisfaction is being proven."
    },
    "path": {
      "type": "array",
      "minItems": 0,
      "maxItems": 64,
      "items": {
        "type": "object",
        "required": ["side", "commit", "witness"],
        "additionalProperties": false,
        "properties": {
          "side": {
            "type": "string",
            "enum": ["L", "R"],
            "description": "Direction of the sibling node relative to the current node on the Merkle path."
          },
          "commit": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{43}$",
            "description": "Base64url-encoded 32-byte SHA-256(sibling_hash || blind). Hides the sibling node."
          },
          "witness": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_-]{43}$",
            "description": "Base64url-encoded 32-byte SHA-256(blind). Binds the blinding factor into the transcript without revealing the sibling hash."
          }
        }
      },
      "description": "Blinded Merkle inclusion path for the satisfying constraint. Path length reveals tree depth but not which leaf satisfied."
    },
    "issuer_pubkey": {
      "type": "string",
      "pattern": "^ed25519:[A-Za-z0-9_-]{43}$",
      "description": "Issuer Ed25519 public key in 'ed25519:<b64u>' form. 32 bytes when decoded."
    },
    "challenge_sha256": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{43}$",
      "description": "Base64url-encoded 32-byte SHA-256 of the canonical (RFC 8785 JCS) transcript bytes. Recomputed by the verifier; must match exactly."
    },
    "schnorr_sig": {
      "type": "string",
      "pattern": "^ed25519:[A-Za-z0-9_-]{86}$",
      "description": "Issuer Ed25519 signature over challenge_sha256, in 'ed25519:<b64u>' form. 64 bytes when decoded. Provides PREIMAGE knowledge proof via Schnorr-style signature of knowledge."
    }
  },
  "examples": [
    {
      "protocol": "spectralzk/1",
      "policy_commitment": "2J6l5ZKt_G3BEqK0EoNF75YgOYVtfziencyZsj7gZXQ",
      "merkle_root": "Cd-oNZoDQXTa5FOiraKdj0mftZmyXdOFAt4FNjMqYyc",
      "action": {
        "attr": "spend_usd_per_day",
        "value": 145
      },
      "path": [
        {
          "side": "L",
          "commit": "USTW5rHhEk2UYEq3sJgD7C4Cw-rKGcYP6EecPpVYAOs",
          "witness": "o3Kq3g6pyQyuvh0DkDQGJOon9RXin2wBwKhXOVWkLsg"
        }
      ],
      "issuer_pubkey": "ed25519:-_HdEFXF_wfSt1n9DO41fga7B1i8Wo03R79_usXCmTA",
      "challenge_sha256": "gkx30gXSPb0_ll5VQEfO7ILSbciHFHD-rPY_BV8ch3M",
      "schnorr_sig": "ed25519:Runf1m0CIEquVLaO6XczpQtJfD3ehyeJZHPgcyFAldD1A86JsQ-Lht-Dvwplvmpl3OhAk975Y8vhTaBqJEf6AQ"
    }
  ]
}
