π± Leviathan v2 β EVM Exploit Topology Classifier
Bare-metal CNN that classifies EVM execution traces as THREAT or CLEAN using two-field Hamiltonian manifolds.
Leviathan ingests raw Ethereum Virtual Machine traces, encodes them as 2-channel 256Γ256 spatial manifolds via Hilbert curve mapping, downsamples to the CNN's 20Γ20 receptive field, and outputs a binary exploit score. A ZKAEDI PRIME bistable attractor refinement layer then commits the score to BENIGN or THREAT.
Architecture
EVM Trace (opcodes + stack depth)
β
Hilbert-Curve Encoder β 256Γ256 Manifold
Channel 0: Opcode energy density (H activator field)
Channel 1: Stack depth / state mutation intensity (V inhibitor field)
β
Downsample β 20Γ20
β
Conv2d(2, 16, 3Γ3) β ReLU
Conv2d(16, 16, 3Γ3) β ReLU
β
Flatten β 4096
β
Linear(4096, 64) β ReLU
Linear(64, 1) β Raw Score
β
PRIME Bistable Attractor Refinement
Ξ·=3.50, Ξ³=0.30, Ξ²=0.10, Ο=0.05, T=256 iterations
Negative fixed point H*=β3.054 β BENIGN committed
Positive attractor β THREAT committed
β
Output: 0.0 (CLEAN) ... 1.0 (THREAT)
| Component | Shape | Parameters |
|---|---|---|
| conv_net.0 | (16, 2, 3, 3) + bias | 304 |
| conv_net.2 | (16, 16, 3, 3) + bias | 2,320 |
| fc.1 | (64, 4096) + bias | 262,208 |
| fc.3 | (1, 64) + bias | 65 |
| Total | 264,897 |
Validation Results
Trained and validated end-to-end with EVM execution manifolds:
| Contract / Pattern | Score | Verdict |
|---|---|---|
| Gnosis Multisig (safe baseline) | 0.0000 | CLEAN |
| SWC-107 Reentrancy | 1.0000 | THREAT |
| SWC-112 Delegatecall | 1.0000 | THREAT |
| SWC-101 Integer Overflow | 1.0000 | THREAT |
| Cross-function Reentrancy | 1.0000 | THREAT |
| Flash Loan Manipulation | 1.0000 | THREAT |
PRIME refinement thresholds: P < 0.10 = BENIGN committed, P > 0.90 = THREAT committed.
Usage
from huggingface_hub import hf_hub_download
from leviathan import Leviathan
weights_path = hf_hub_download("zkaedi/leviathan-v2", "leviathan_v2_session_trained.safetensors")
model = Leviathan.from_safetensors(weights_path)
# Score a 256x256 EVM manifold (auto-downsamples to 20x20)
score = model.predict_manifold(H_256, V_256)
# Full audit with PRIME bistable attractor refinement
result = model.audit(H_256, V_256)
print(result["verdict"]) # "THREAT" or "BENIGN"
print(result["confidence"]) # 0.0 - 1.0
ZKAEDI Security Pipeline
Solidity Code
β gemma-2-9b-solidity-merged (vulnerability signatures)
β prime-swarm-hunter (12-agent temporal compound detection)
β evm_trace_ingester.py (EVM trace β 256Γ256 manifold)
β LEVIATHAN v2 (CNN: THREAT/CLEAN classification)
β PRIME refinement (bistable attractor commitment)
β solidity-vuln-auditor-7b (final audit report)
Companion Files
| File | Purpose |
|---|---|
leviathan.c |
622-line bare-metal C inference engine |
manifold_forge.py |
Exploit manifold generator (5 classes, Hilbert encoding) |
weights_to_bin.py |
safetensors to raw float32 binary for C engine |
evm_trace_ingester.py |
3 modes: RPC trace, Foundry, static bytecode |
PRIME Refinement Mathematics
H_t = H_0 + Ξ·Β·H_{t-1}Β·Ο(Ξ³Β·H_{t-1}) + Ρ·N(0, 1+Ξ²|H_{t-1}|)
With Ξ·=3.50 the system has two stable fixed points: H* = -3.054 (BENIGN, Jacobian J=0.346 < 1) and positive attractor (THREAT). Scores near 0.5 converge to one attractor over T=256 iterations.
Author
ZKAEDI β Offensive Healer