v0.5.2-pre.003
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: ks-wallet/src/constants.rs
|
||||
// version: 3
|
||||
// version: 5
|
||||
|
||||
//! Local constants for the `ks-wallet` crate.
|
||||
|
||||
@@ -9,9 +9,52 @@ pub(crate) const TRACING_TARGET: &str = "ks-wallet";
|
||||
pub const KSWALLET_FILE_EXTENSION: &str = "kswallet";
|
||||
/// Native wallet format identification magic.
|
||||
pub(crate) const KSWALLET_MAGIC: &[u8; 8] = b"KSWALLET";
|
||||
/// Native wallet format version used by the identification prefix.
|
||||
/// Native wallet format version.
|
||||
pub(crate) const KSWALLET_FORMAT_VERSION: u16 = 1;
|
||||
/// Number of bytes required to identify a native wallet file.
|
||||
pub(crate) const KSWALLET_IDENTIFICATION_LENGTH: usize = 10;
|
||||
/// Fixed version-one header length before the variable alias bytes.
|
||||
pub(crate) const KSWALLET_FIXED_HEADER_LENGTH: usize = 72;
|
||||
/// Maximum wallet alias length encoded by version one.
|
||||
pub(crate) const KSWALLET_MAX_ALIAS_LENGTH: usize = 64;
|
||||
/// Native version-one flag value when no optional feature is enabled.
|
||||
pub(crate) const KSWALLET_FLAGS_NONE: u16 = 0;
|
||||
/// Version-one KDF identifier for Argon2id.
|
||||
pub(crate) const KSWALLET_KDF_ARGON2ID: u8 = 1;
|
||||
/// Argon2 version 19 identifier required by version one.
|
||||
pub(crate) const KSWALLET_ARGON2_VERSION: u8 = 0x13;
|
||||
/// Version-one AEAD identifier for XChaCha20-Poly1305.
|
||||
pub(crate) const KSWALLET_AEAD_XCHACHA20_POLY1305: u8 = 1;
|
||||
/// Salt length used by the version-one Argon2id profile.
|
||||
pub(crate) const KSWALLET_SALT_LENGTH: usize = 16;
|
||||
/// Nonce length used by XChaCha20-Poly1305.
|
||||
pub(crate) const KSWALLET_NONCE_LENGTH: usize = 24;
|
||||
/// Authentication tag length appended by XChaCha20-Poly1305.
|
||||
const KSWALLET_AEAD_TAG_LENGTH: usize = 16;
|
||||
/// Minimum accepted Argon2id memory cost in KiB.
|
||||
pub(crate) const KSWALLET_ARGON2_MIN_MEMORY_KIB: u32 = 65_536;
|
||||
/// Maximum accepted Argon2id memory cost in KiB.
|
||||
pub(crate) const KSWALLET_ARGON2_MAX_MEMORY_KIB: u32 = 262_144;
|
||||
/// Minimum accepted Argon2id pass count.
|
||||
pub(crate) const KSWALLET_ARGON2_MIN_ITERATIONS: u32 = 3;
|
||||
/// Maximum accepted Argon2id pass count.
|
||||
pub(crate) const KSWALLET_ARGON2_MAX_ITERATIONS: u32 = 10;
|
||||
/// Minimum accepted Argon2id lane count.
|
||||
pub(crate) const KSWALLET_ARGON2_MIN_PARALLELISM: u32 = 1;
|
||||
/// Maximum accepted Argon2id lane count.
|
||||
pub(crate) const KSWALLET_ARGON2_MAX_PARALLELISM: u32 = 8;
|
||||
/// Number of bytes stored by the standard Solana keypair JSON format.
|
||||
pub(crate) const SOLANA_KEYPAIR_LENGTH: usize = 64;
|
||||
/// Exact ciphertext length for one 64-byte keypair plus the AEAD tag.
|
||||
pub(crate) const KSWALLET_CIPHERTEXT_LENGTH: usize =
|
||||
SOLANA_KEYPAIR_LENGTH + KSWALLET_AEAD_TAG_LENGTH;
|
||||
/// Minimum complete version-one file length with a one-byte alias.
|
||||
pub(crate) const KSWALLET_MIN_FILE_LENGTH: usize = KSWALLET_FIXED_HEADER_LENGTH
|
||||
+ 1
|
||||
+ KSWALLET_SALT_LENGTH
|
||||
+ KSWALLET_NONCE_LENGTH
|
||||
+ KSWALLET_CIPHERTEXT_LENGTH;
|
||||
/// Maximum complete version-one file length with the longest supported alias.
|
||||
pub(crate) const KSWALLET_MAX_FILE_LENGTH: usize = KSWALLET_FIXED_HEADER_LENGTH
|
||||
+ KSWALLET_MAX_ALIAS_LENGTH
|
||||
+ KSWALLET_SALT_LENGTH
|
||||
+ KSWALLET_NONCE_LENGTH
|
||||
+ KSWALLET_CIPHERTEXT_LENGTH;
|
||||
|
||||
Reference in New Issue
Block a user