{
    "$schema": "http://json-schema.org/draft-07/schema",
    "type": "object",
    "properties": {
        "id": {
            "type": "integer",
            "minimum": 0,
            "description": "Public key ID",
            "$comment": "Must be unique for the identity. It can’t be changed after adding a key. Included when signing state transitions to indicate which identity key was used to sign."
        },
        "type": {
            "type": "integer",
            "enum": [
                0,
                1
            ],
            "description": "Public key type. 0 - EC Secp256k1, 1 - BLS 12-381",
            "$comment": "It can’t be changed after adding a key"
        },
        "purpose": {
            "type": "integer",
            "enum": [
                0,
                1,
                2,
                3
            ],
            "description": "Public key purpose. 0 - Authentication, 1 - Encryption, 2 - Decryption, 3 - Encryption and Decryption",
            "$comment": "It can’t be changed after adding a key"
        },
        "level": {
            "type": "integer",
            "enum": [
                0,
                1,
                2,
                3
            ],
            "description": "Public key security level. 0 - Master, 1 - Critical, 2 - High, 3 - Medium",
            "$comment": "It can’t be changed after adding a key"
        },
        "data": {
            "type": "string",
            "contentEncoding": "base64",
            "pattern": "^([A-Za-z0-9+/])+$",
            "description": "Base64-encoded raw public key",
            "$comment": "It must be a valid key of the specified type and unique for the identity. It can’t be changed after adding a key"
        },
        "ownershipProof": {
            "type": "string",
            "contentEncoding": "base64",
            "pattern": "^([A-Za-z0-9+/])+$",
            "description": "Base64-encoded signature of the owner unique identifier",
            "$comment": "This proves ownership of the key. It can’t be changed after adding a key"
        },
        "disabledAt": {
            "type": "integer",
            "minimum": 0,
            "description": "Timestamp indicating that the key was disabled at specified time. Although disabled keys cannot be updated, they can be used for signature verification and signing Identity Disable Transitions. Timestamp must not be more than 5 minutes before or 5 minutes after the current platform chain block time"
        }
    },
    "allOf": [
        {
            "if": {
                "properties": {
                    "type": {
                        "const": 0
                    }
                }
            },
            "then": {
                "properties": {
                    "data": {
                        "minLength": 44,
                        "maxLength": 44
                    },
                    "ownershipProof": {
                        "minLength": 87,
                        "maxLength": 87
                    }
                }
            }
        },
        {
            "if": {
                "properties": {
                    "type": {
                        "const": 1
                    }
                }
            },
            "then": {
                "properties": {
                    "data": {
                        "minLength": 64,
                        "maxLength": 64
                    },
                    "ownershipProof": {
                        "minLength": 128,
                        "maxLength": 128
                    }
                }
            }
        }
    ],
    "required": [
        "id",
        "type",
        "data",
        "purpose",
        "level",
        "ownershipProof"
    ],
    "additionalProperties": false
}
