Skip to content

CryptoError

1 min read

Import: import system.crypto;

Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.

CryptoError

Cryptographic operation failure implementing Error (currently AesGcm/AesGcmKey).

public class CryptoError: Error

constructor

Creates an error with a machine code and message.

public constructor(code: string, message: string)

message

Human-readable explanation of the cryptographic failure, suitable for logs and error output.

public fun message(): string

code

Stable machine code (EINVAL_KEY, EINVAL_NONCE, EDECRYPT, …).

public fun code(): string

invalid_key

Key material has the wrong length or shape.

public static fun invalid_key(message: string): CryptoError

invalid_nonce

Nonce/IV has the wrong length.

public static fun invalid_nonce(message: string): CryptoError

decrypt_failed

Decryption failed: authentication tag mismatch, truncated ciphertext, or tampering.

public static fun decrypt_failed(message: string): CryptoError