{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/rivaire-pro/json-schema/rivaire-pro-account-keys-schema.json",
  "title": "AccountKeys",
  "description": "Your encryption keys, wrapped. Your 12-word phrase unlocks the money key, which unlocks the workspace keys and your private key.",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/rivaire-pro-openapi.json#/components/schemas/AccountKeys",
  "type": "object",
  "properties": {
    "moneyKdfSalt": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "wrappedMoneyKey": {
      "type": "object",
      "properties": {
        "ciphertext": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024
        },
        "iv": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "algorithm": {
          "type": "string",
          "const": "AES-GCM"
        },
        "keyVersion": {
          "type": "integer",
          "exclusiveMinimum": 0
        },
        "keyId": {
          "type": "string",
          "format": "uuid"
        }
      },
      "required": [
        "ciphertext",
        "iv",
        "algorithm",
        "keyVersion"
      ]
    },
    "moneyEncryptionCheck": {
      "type": "object",
      "properties": {
        "ciphertext": {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024
        },
        "iv": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "algorithm": {
          "type": "string",
          "const": "AES-GCM"
        },
        "keyVersion": {
          "type": "integer",
          "exclusiveMinimum": 0
        },
        "keyId": {
          "type": "string",
          "format": "uuid"
        }
      },
      "required": [
        "ciphertext",
        "iv",
        "algorithm",
        "keyVersion"
      ]
    },
    "moneyKeyVersion": {
      "type": "integer",
      "exclusiveMinimum": 0
    },
    "mainWorkspaceId": {
      "type": "string",
      "format": "uuid"
    },
    "publicKey": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        {
          "type": "null"
        }
      ]
    },
    "encryptedPrivateKey": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "ciphertext": {
              "type": "string",
              "minLength": 1,
              "maxLength": 1024
            },
            "iv": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "algorithm": {
              "type": "string",
              "const": "AES-GCM"
            },
            "keyVersion": {
              "type": "integer",
              "exclusiveMinimum": 0
            },
            "keyId": {
              "type": "string",
              "format": "uuid"
            }
          },
          "required": [
            "ciphertext",
            "iv",
            "algorithm",
            "keyVersion"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "workspaceKeys": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "workspaceId": {
            "type": "string",
            "format": "uuid"
          },
          "generation": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "wrappedKey": {
            "type": "object",
            "properties": {
              "ciphertext": {
                "type": "string",
                "minLength": 1,
                "maxLength": 1024
              },
              "iv": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "algorithm": {
                "type": "string",
                "const": "AES-GCM"
              },
              "keyVersion": {
                "type": "integer",
                "exclusiveMinimum": 0
              },
              "keyId": {
                "type": "string",
                "format": "uuid"
              }
            },
            "required": [
              "ciphertext",
              "iv",
              "algorithm",
              "keyVersion"
            ]
          }
        },
        "required": [
          "id",
          "workspaceId",
          "generation",
          "wrappedKey"
        ]
      }
    },
    "pendingWorkspaceKeys": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "workspaceId": {
            "type": "string",
            "format": "uuid"
          },
          "generation": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "sealedKey": {
            "type": "object",
            "properties": {
              "algorithm": {
                "type": "string",
                "const": "ECDH-P256+HKDF-SHA256+AES-GCM"
              },
              "ephemeralPublicKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "iv": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "ciphertext": {
                "type": "string",
                "minLength": 1,
                "maxLength": 1024
              }
            },
            "required": [
              "algorithm",
              "ephemeralPublicKey",
              "iv",
              "ciphertext"
            ]
          }
        },
        "required": [
          "id",
          "workspaceId",
          "generation",
          "sealedKey"
        ]
      }
    }
  },
  "required": [
    "moneyKdfSalt",
    "wrappedMoneyKey",
    "moneyEncryptionCheck",
    "moneyKeyVersion",
    "mainWorkspaceId",
    "publicKey",
    "encryptedPrivateKey",
    "workspaceKeys",
    "pendingWorkspaceKeys"
  ]
}