{
  "$defs": {
    "SiwsChallenge": {
      "description": "SIWS challenge issued by MARS and signed by a Sigil wallet.",
      "properties": {
        "audience": {
          "description": "Sign-in audience.",
          "type": "string"
        },
        "chainId": {
          "description": "Sigil chain identifier.",
          "type": "string"
        },
        "expiresAtMs": {
          "description": "Challenge expiry time in Unix milliseconds.",
          "format": "int64",
          "type": "integer"
        },
        "hmrDid": {
          "description": "HMR DID expected to sign.",
          "pattern": "^did:oas:",
          "type": "string"
        },
        "issuedAtMs": {
          "description": "Challenge issue time in Unix milliseconds.",
          "format": "int64",
          "type": "integer"
        },
        "kind": {
          "description": "Protocol discriminator. Current value is `sigil.signin`.",
          "pattern": "^sigil\\.signin$",
          "type": "string"
        },
        "nonce": {
          "description": "Single-use challenge nonce.",
          "type": "string"
        },
        "origin": {
          "description": "Request origin.",
          "type": "string"
        },
        "requestId": {
          "description": "Single-use request identifier.",
          "type": "string"
        },
        "rootDid": {
          "description": "Optional authorizing HMR, MHR, or ENR root DID.",
          "type": [
            "string",
            "null"
          ]
        },
        "version": {
          "description": "SIWS wire version. Current value is `1`.",
          "format": "uint8",
          "maximum": 1,
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "kind",
        "version",
        "origin",
        "audience",
        "chainId",
        "nonce",
        "requestId",
        "hmrDid",
        "issuedAtMs",
        "expiresAtMs"
      ],
      "type": "object"
    },
    "SiwsSignedResponse": {
      "description": "Signed SIWS response produced by a Sigil wallet.",
      "properties": {
        "chainId": {
          "description": "Chain identifier copied from the challenge.",
          "type": "string"
        },
        "digest": {
          "description": "Hex-encoded BLAKE3 transcript digest.",
          "type": "string"
        },
        "kind": {
          "description": "Response discriminator. Current value is `message`.",
          "pattern": "^message$",
          "type": "string"
        },
        "message": {
          "description": "Canonical SIWS message.",
          "type": "string"
        },
        "origin": {
          "description": "Origin copied from the challenge.",
          "type": "string"
        },
        "signature": {
          "description": "Hex-encoded Ed25519 signature.",
          "type": "string"
        },
        "signerDid": {
          "description": "DID of the HMR signer.",
          "pattern": "^did:oas:",
          "type": "string"
        },
        "signerPublicKey": {
          "description": "Hex-encoded Ed25519 public key.",
          "type": "string"
        },
        "transcript": {
          "description": "Canonical transcript signed by the wallet.",
          "type": "string"
        }
      },
      "required": [
        "kind",
        "origin",
        "chainId",
        "signerDid",
        "message",
        "signature",
        "signerPublicKey",
        "digest",
        "transcript"
      ],
      "type": "object"
    }
  },
  "$id": "urn:mars:schema:v1:siws-verify-request",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "Request body for `POST /v1/auth/siws/verify`.",
  "properties": {
    "audience": {
      "description": "Expected audience; must equal the challenge audience.",
      "type": "string"
    },
    "challenge": {
      "$ref": "#/$defs/SiwsChallenge",
      "description": "Originally issued challenge."
    },
    "response": {
      "$ref": "#/$defs/SiwsSignedResponse",
      "description": "Wallet-signed response."
    }
  },
  "required": [
    "challenge",
    "response",
    "audience"
  ],
  "title": "SiwsVerifyRequest",
  "type": "object"
}
