zera-sdk 0.1.0

Rust SDK for ZERA transactions, validator APIs, and bridge workflows
Documentation
use crate::crypto::constants::{HashType, KeyType};

pub const ZERA_TYPE: u32 = 1110;
pub const ZERA_TYPE_HEX: &str = "0x80000456";
pub const ZERA_SYMBOL: &str = "ZRA";
pub const ZERA_NAME: &str = "ZERA";

pub const MNEMONIC_LENGTHS: [usize; 5] = [12, 15, 18, 21, 24];
pub const SLIP0010_DERIVATION_PATH: &str = "m/44'/1110'/0'/0'/0'";
pub const DERIVATION_SCHEME: &str = "slip0010";

pub const EXTENDED_PRIVATE_VERSION: u32 = 0x04b2430c;
pub const EXTENDED_PUBLIC_VERSION: u32 = 0x04b2430d;

#[derive(Debug, Clone, Copy, Default)]
pub struct HdOptions {
    pub account_index: u32,
    pub change_index: u8,
    pub address_index: u32,
}

pub fn is_valid_mnemonic_length(length: usize) -> bool {
    MNEMONIC_LENGTHS.contains(&length)
}

pub fn validate_slip0010_path(path: &str) -> bool {
    if path.is_empty() || !path.starts_with("m/") {
        return false;
    }

    let parts: Vec<&str> = path.split('/').collect();
    if parts.len() != 6 {
        return false;
    }

    for part in parts.iter().skip(1) {
        if !part.ends_with('\'') {
            return false;
        }
    }

    let purpose = parts[1].trim_end_matches('\'').parse::<u32>().ok();
    let coin_type = parts[2].trim_end_matches('\'').parse::<u32>().ok();

    matches!(purpose, Some(44)) && matches!(coin_type, Some(ZERA_TYPE))
}

pub const VALID_KEY_TYPES: [KeyType; 2] = [KeyType::Ed25519, KeyType::Ed448];
pub const VALID_HASH_TYPES: [HashType; 3] =
    [HashType::Sha3_256, HashType::Sha3_512, HashType::Blake3];