// file: crates/ksp-wallet-lib/src/constants.rs // version: 5 //! Wallet-owned constants. /// Exact magic string required by every native `.kspwallet` document. pub const KSPWALLET_MAGIC: &str = "KSPWALLET"; /// Native Wallet format version implemented by the V1 codec. pub const KSPWALLET_FORMAT_VERSION_V1: u32 = 1; /// Maximum accepted `.kspwallet` document size before JSON parsing. pub const KSPWALLET_MAX_FILE_BYTES: usize = 1024 * 1024; /// Maximum accepted Solana CLI keypair JSON transfer size before parsing. pub const KSPWALLET_TRANSFER_MAX_SOLANA_CLI_JSON_BYTES: usize = 1024; /// Maximum accepted canonical Base58 keypair transfer size before decoding. pub const KSPWALLET_TRANSFER_MAX_BASE58_BYTES: usize = 128; /// Maximum protected alias size in UTF-8 bytes for metadata V1. pub const KSPWALLET_V1_MAX_ALIAS_BYTES: usize = 256; /// Maximum number of protected notes in metadata V1. pub const KSPWALLET_V1_MAX_NOTES: usize = 64; /// Maximum protected note text size in UTF-8 bytes for metadata V1. pub const KSPWALLET_V1_MAX_NOTE_TEXT_BYTES: usize = 8 * 1024; /// Maximum metadata plaintext size before V1 encryption. pub const KSPWALLET_V1_MAX_METADATA_PLAINTEXT_BYTES: usize = 64 * 1024; /// Maximum password size in exact UTF-8 input bytes. pub const KSPWALLET_V1_MAX_PASSWORD_BYTES: usize = 1024; /// Byte length of every V1 key-slot identifier. pub const KSPWALLET_V1_SLOT_ID_BYTES: usize = 16; /// Byte length of every protected metadata note identifier. pub const KSPWALLET_V1_NOTE_ID_BYTES: usize = 16; /// Byte length of an Ed25519 public key used as Wallet format authority. pub const KSPWALLET_V1_ED25519_PUBLIC_KEY_BYTES: usize = 32; /// Byte length of an Ed25519 detached state signature. pub const KSPWALLET_V1_ED25519_SIGNATURE_BYTES: usize = 64; /// Byte length of every Solana Ed25519 message signature returned by Wallet OWNER. pub const KSPWALLET_SOLANA_SIGNATURE_BYTES: usize = 64; /// Byte length of an XChaCha20-Poly1305 nonce. pub const KSPWALLET_V1_XCHACHA_NONCE_BYTES: usize = 24; /// Byte length of the Poly1305 authentication tag appended to each ciphertext. pub const KSPWALLET_V1_AEAD_TAG_BYTES: usize = 16; /// Argon2 version serialized by V1 key slots. pub const KSPWALLET_V1_ARGON2_VERSION: u32 = 19; /// Default Argon2id memory cost for newly created V1 key slots, calibrated on the 2026-08-19 operator benchmark. pub const KSPWALLET_V1_DEFAULT_ARGON2_MEMORY_KIB: u32 = 65_536; /// Default Argon2id iteration count for newly created V1 key slots. pub const KSPWALLET_V1_DEFAULT_ARGON2_ITERATIONS: u32 = 3; /// Default Argon2id parallelism for newly created V1 key slots. pub const KSPWALLET_V1_DEFAULT_ARGON2_PARALLELISM: u32 = 1; /// Salt size generated independently for every newly created V1 key slot. pub const KSPWALLET_V1_DEFAULT_KDF_SALT_BYTES: usize = 32; /// Exact plaintext size of the V1 OWNER-control compartment. pub const KSPWALLET_V1_OWNER_CONTROL_PLAINTEXT_BYTES: usize = 96; /// Exact plaintext size of the V1 Solana secret compartment. pub const KSPWALLET_V1_SECRET_PLAINTEXT_BYTES: usize = 64; /// Minimum accepted Argon2 salt size in bytes. pub const KSPWALLET_V1_MIN_KDF_SALT_BYTES: usize = 16; /// Maximum accepted Argon2 salt size in bytes. pub const KSPWALLET_V1_MAX_KDF_SALT_BYTES: usize = 64; /// Structural V1 ceiling for serialized Argon2 memory cost; creation defaults are benchmarked separately. pub const KSPWALLET_V1_MAX_ARGON2_MEMORY_KIB: u32 = 1024 * 1024; /// Structural V1 ceiling for serialized Argon2 iteration cost; creation defaults are benchmarked separately. pub const KSPWALLET_V1_MAX_ARGON2_ITERATIONS: u32 = 64; /// Structural V1 ceiling for serialized Argon2 parallelism; creation defaults are benchmarked separately. pub const KSPWALLET_V1_MAX_ARGON2_PARALLELISM: u32 = 64; /// Maximum number of key slots understood by format V1: exactly one OWNER plus optional VIEW. pub const KSPWALLET_V1_MAX_KEY_SLOTS: usize = 2; /// Maximum ciphertext size of one wrapped capability payload. pub const KSPWALLET_V1_MAX_KEY_WRAP_CIPHERTEXT_BYTES: usize = 4096; /// Maximum OWNER-control ciphertext size accepted by envelope V1. pub const KSPWALLET_V1_MAX_OWNER_CONTROL_CIPHERTEXT_BYTES: usize = 4096; /// Maximum metadata ciphertext size, including the AEAD tag over the bounded 64-KiB plaintext. pub const KSPWALLET_V1_MAX_METADATA_CIPHERTEXT_BYTES: usize = KSPWALLET_V1_MAX_METADATA_PLAINTEXT_BYTES + KSPWALLET_V1_AEAD_TAG_BYTES; /// Maximum OWNER-only secret ciphertext size accepted by envelope V1. pub const KSPWALLET_V1_MAX_SECRET_CIPHERTEXT_BYTES: usize = 4096; /// Initial protected payload version used independently by control, metadata and secret compartments. pub const KSPWALLET_V1_INITIAL_PAYLOAD_VERSION: u32 = 1; /// Domain separator for the OWNER state-signature transcript. pub const KSPWALLET_V1_STATE_TRANSCRIPT_DOMAIN: &[u8] = b"KSPWALLET-V1-STATE"; /// Domain separator for OWNER key-slot wrapping AAD. pub const KSPWALLET_V1_OWNER_SLOT_AAD_DOMAIN: &[u8] = b"KSPWALLET-V1-AAD-OWNER-SLOT"; /// Domain separator for VIEW key-slot wrapping AAD. pub const KSPWALLET_V1_VIEW_SLOT_AAD_DOMAIN: &[u8] = b"KSPWALLET-V1-AAD-VIEW-SLOT"; /// Domain separator for OWNER-control compartment AAD. pub const KSPWALLET_V1_OWNER_CONTROL_AAD_DOMAIN: &[u8] = b"KSPWALLET-V1-AAD-OWNER-CONTROL"; /// Domain separator for metadata compartment AAD. pub const KSPWALLET_V1_METADATA_AAD_DOMAIN: &[u8] = b"KSPWALLET-V1-AAD-METADATA"; /// Domain separator for OWNER-only secret compartment AAD. pub const KSPWALLET_V1_SECRET_AAD_DOMAIN: &[u8] = b"KSPWALLET-V1-AAD-SECRET"; /// Owning tracing target for events emitted by the Wallet crate. pub(crate) const TRACING_TARGET: &str = "ksp-wallet-lib";