{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://rootz.global/schemas/ask-orders/common.schema.json",
  "title": "ASK Orders \u2014 shared definitions",
  "$defs": {
    "Digest": {
      "description": "sha256 over canonical (JCS) bytes for objects, or raw bytes for payloads; base64url without padding.",
      "type": "string",
      "pattern": "^sha256:[A-Za-z0-9_-]{43}$"
    },
    "Time": {
      "description": "RFC 3339, UTC, millisecond precision, Z suffix.",
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$"
    },
    "Caip10": {
      "description": "CAIP-10 account id, e.g. eip155:1:0xD36AAf65a91bB7dc69942cF6B6d1dBa4Ef171664.",
      "type": "string",
      "pattern": "^eip155:[0-9]+:0x[0-9a-fA-F]{40}$"
    },
    "Account": {
      "description": "A chain account (CAIP-10) or a published key id (kid) for non-chain signers.",
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "Nonce": {
      "description": "128 random bits, base64url without padding.",
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{22}$"
    },
    "ReasonCode": {
      "description": "Enumerated in @ask-orders/objects reasons.ts; lower-kebab-case.",
      "type": "string",
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
    },
    "ByteCommitment": {
      "description": "Commitment to exact bytes without re-encoding them (rootz-wrapped-node bodyCommitment).",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "bytes",
        "sha256"
      ],
      "properties": {
        "bytes": {
          "type": "integer",
          "minimum": 0
        },
        "sha256": {
          "$ref": "#/$defs/Digest"
        }
      }
    },
    "Proof": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "suite",
            "envelope"
          ],
          "properties": {
            "suite": {
              "const": "rootz.sign-mcp.v1"
            },
            "envelope": {
              "type": "object",
              "description": "A sign-mcp envelope over the JCS bytes of the body; ctx.kind must equal body.kind."
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "suite",
            "signer",
            "signature"
          ],
          "properties": {
            "suite": {
              "const": "eip191.personal-sign.jcs"
            },
            "signer": {
              "$ref": "#/$defs/Caip10"
            },
            "signature": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{130}$"
            }
          }
        }
      ]
    },
    "Proofs": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/Proof"
      }
    },
    "Route": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "verifier",
        "resolver"
      ],
      "properties": {
        "verifier": {
          "type": "string",
          "pattern": "^https://[^\\s]{1,500}$"
        },
        "resolver": {
          "type": "string",
          "pattern": "^https://[^\\s]{1,500}$"
        },
        "spec": {
          "type": "string",
          "pattern": "^https://[^\\s]{1,500}$"
        }
      }
    }
  }
}
