{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.helloorigo.com/chronicle/audio-entry-protected-v2.schema.json",
  "title": "Chronicle protected audio entry envelope v2",
  "type": "object",
  "additionalProperties": false,
  "required": ["envelopeVersion", "format", "kdf", "cipher", "ciphertextBase64"],
  "properties": {
    "envelopeVersion": { "const": 2 },
    "format": { "const": "origo-chronicle-audio-entry" },
    "kdf": {
      "type": "object", "additionalProperties": false,
      "required": ["algorithm", "iterations", "saltBase64"],
      "properties": {
        "algorithm": { "const": "PBKDF2-HMAC-SHA256" },
        "iterations": { "const": 600000 },
        "saltBase64": { "type": "string", "pattern": "^[A-Za-z0-9+/]{22}==$" }
      }
    },
    "cipher": {
      "type": "object", "additionalProperties": false,
      "required": ["algorithm", "nonceBase64"],
      "properties": {
        "algorithm": { "const": "AES-256-GCM" },
        "nonceBase64": { "type": "string", "pattern": "^[A-Za-z0-9+/]{16}$" }
      }
    },
    "ciphertextBase64": { "type": "string", "minLength": 24, "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" }
  }
}
