--- tags: - safetensors - zkaedi-prime - hamiltonian-dynamics - vulnerability-detection - bytecode-analysis - bare-metal - evm - smart-contracts - security - ensemble-specialist license: mit --- # πŸ”± Kraken v2.2 β€” Bytecode Feature Vulnerability Classifier **Ensemble Specialist #2** (Leviathan v2 = Specialist #1) 8 independent binary MLP classifiers detecting EVM bytecode vulnerability patterns. Each classifier answers one question: "Is this bytecode vulnerable to [specific class]?" ## Architecture ``` EVM Bytecode β†’ Disassemble (skip PUSH immediates) β†’ 32-dim hand-crafted feature vector: [0-15] Category ratios (16 opcode categories) [16] Unguarded CALLβ†’SSTORE (reentrancy signal) [17] SSTORE before CALL (CEI safe pattern) [18-21] Dangerous opcode flags (DELEGATECALL, SELFDESTRUCT, ORIGIN, TIMESTAMP) [22] Guarded CALLβ†’SSTORE (anti-reentrancy) [23] Arithmetic without guard ratio (overflow risk) [24-25] Context (CALLVALUE, BALANCE) [26] Consecutive CALLs without SSTORE (flash loan) [27] Unchecked CALL (CALLβ†’POP) [28-31] Statistical (total ops, unique ops, entropy, CALL density) β†’ 8Γ— BinaryMLP(32 β†’ 32 β†’ 1) β†’ 19-dim score vector ``` ## Performance | Class | F1 | Precision | Recall | |-------|-----|-----------|--------| | Reentrancy (SWC-107) | 1.000 | 1.000 | 1.000 | | Integer Overflow (SWC-101) | 1.000 | 1.000 | 1.000 | | tx.origin Auth (SWC-115) | 1.000 | 1.000 | 1.000 | | Delegatecall Inj (SWC-112) | 1.000 | 1.000 | 1.000 | | Flash Loan Attack | 1.000 | 1.000 | 1.000 | | Selfdestruct (SWC-106) | 1.000 | 1.000 | 1.000 | | Timestamp Dep (SWC-116) | 1.000 | 1.000 | 1.000 | | Unchecked Return (SWC-104) | 1.000 | 1.000 | 1.000 | **Total parameters: 8,712** (1,089 per classifier Γ— 8 classifiers) ## Ensemble Fusion (v2.2) For 2 specialists (Leviathan + Kraken), simple rule-based fusion: - Both flag > 0.5 β†’ **THREAT** (mean + 0.10 agreement boost) - One flags > 0.8 β†’ **THREAT** (max Γ— 0.85 single-detect) - One flags > 0.5 β†’ **UNCERTAIN** (max Γ— 0.50) - Neither flags β†’ **CLEAN** (pass through) No FHN Laplacian coupling (caused cross-class energy leaking in v2.1). FHN with kappa=0 reserved for 3+ specialists. ## ZKAEDI Security Pipeline ``` Solidity Code β†’ gemma-2-9b-solidity-merged (vulnerability energy signatures) β†’ prime-swarm-hunter (12-agent temporal compound detection) β†’ LEVIATHAN v2 (EVM trace topology: 265K params) β†’ KRAKEN v2.2 (bytecode features: 8,712 params) ← THIS MODEL β†’ PRIME Simple Fusion (rule-based for 2 specialists) β†’ solidity-vuln-auditor-7b (final audit report) ``` ## Usage ```python from safetensors.numpy import load_file import numpy as np # Load weights d = load_file("kraken_v2.2.safetensors") # Reconstruct classifier (example for reentrancy) w1, b1 = d["reentrancy.w1"], d["reentrancy.b1"] w2, b2 = d["reentrancy.w2"], d["reentrancy.b2"] # Inference features = extract_features(bytecode) # 32-dim vector h = np.maximum(features @ w1.T + b1, 0) # ReLU score = 1.0 / (1.0 + np.exp(-(h @ w2.T + b2)[0])) # sigmoid ``` ## Companion Files | File | Purpose | |------|---------| | `kraken_v2.2.safetensors` | Trained weights (safetensors) | | `kraken_v2.2.npz` | Trained weights (numpy) | | `kraken_v2.2_weights.h` | C header for bare-metal inference | ## Version History - **v1.0**: CNN on 16Γ—16 manifold, 265K params β†’ dead (all outputs 0.105) - **v1.1**: +MaxPool, 19K params β†’ still dead (sparse manifold) - **v2.0**: Feature-based + 8 binary MLPs β†’ 7/8 F1=1.0, reentrancy FPs - **v2.1**: Strict reentrancy features β†’ 8/8 F1=1.0, but FHN Laplacian leaked - **v2.2**: Simple fusion rules for 2 specialists β†’ clean, no false positives βœ“ ## Author **ZKAEDI** β€” Offensive Healer