{
  "$defs": {
    "Direction": {
      "description": "Direction of a sibling node in a Merkle proof path.",
      "oneOf": [
        {
          "const": "left",
          "description": "Sibling is on the left.",
          "type": "string"
        },
        {
          "const": "right",
          "description": "Sibling is on the right.",
          "type": "string"
        }
      ]
    },
    "MerkleProof": {
      "description": "A Merkle inclusion proof linking a leaf hash to a root hash.\n\nVerifiers walk the `path` from the `leaf_hash` to the `root`, combining\neach `ProofNode` in sequence according to its `direction`.\n\n## MARS Merkle Proof v1 encoding\n\n`root`, `leafHash`, and every sibling `hash` are textual lowercase\nhexadecimal SHA-256 digests. Each level hashes the UTF-8 bytes of the\nconcatenated left and right hexadecimal strings, then lowercase-hex\nencodes the resulting digest before processing the next level. This is a\ncompatibility contract; it is intentionally not raw 32-byte digest\nconcatenation.",
      "properties": {
        "leafHash": {
          "description": "Hash of the leaf being proved.",
          "type": "string"
        },
        "path": {
          "description": "Ordered path of sibling hashes from leaf to root.",
          "items": {
            "$ref": "#/$defs/ProofNode"
          },
          "type": "array"
        },
        "root": {
          "description": "Merkle root hash.",
          "type": "string"
        }
      },
      "required": [
        "root",
        "path",
        "leafHash"
      ],
      "type": "object"
    },
    "ProofNode": {
      "description": "A single node in a Merkle proof path.",
      "properties": {
        "direction": {
          "$ref": "#/$defs/Direction",
          "description": "Whether this sibling is to the left or right of the current node."
        },
        "hash": {
          "description": "Sibling hash at this level of the tree.",
          "type": "string"
        }
      },
      "required": [
        "hash",
        "direction"
      ],
      "type": "object"
    }
  },
  "$id": "urn:mars:schema:v1:anchor-record",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "A confirmed on-chain anchor for a MARS entry.\n\nCreated after a transaction is committed to the Sigil blockchain, this\nrecord links a MARS entry to a specific block and transaction hash, and\noptionally includes a Merkle proof for independent verification.",
  "properties": {
    "anchorTime": {
      "description": "Timestamp when the anchor was created on-chain.",
      "format": "date-time",
      "type": "string"
    },
    "blockHeight": {
      "description": "Block height at which the anchor was committed.",
      "format": "uint64",
      "minimum": 0,
      "type": "integer"
    },
    "entryDid": {
      "description": "DID of the anchored entry.",
      "type": "string"
    },
    "itemDataHash": {
      "description": "SHA-256 content hash of the entry's `item_data`.",
      "type": "string"
    },
    "proof": {
      "anyOf": [
        {
          "$ref": "#/$defs/MerkleProof"
        },
        {
          "type": "null"
        }
      ],
      "description": "Optional Merkle proof for independent verification."
    },
    "txHash": {
      "description": "Transaction hash on the Sigil chain.",
      "type": "string"
    }
  },
  "required": [
    "entryDid",
    "itemDataHash",
    "blockHeight",
    "txHash",
    "anchorTime"
  ],
  "title": "AnchorRecord",
  "type": "object"
}
