Hayate Engine (はやて)
An encrypted, compressed, blazing-fast completion-based asynchronous file and directory transfer engine built on QUIC and compio.
This crate is the core transport library of the Hayate CLI. It is designed to saturate high-speed local networks (Wi-Fi, Ethernet) while keeping CPU usage minimal through a completion-based (proactor) Thread-Per-Core architecture.
✦ Features
- Proactor Thread-Per-Core Asynchronous Engine: Built on
compio(io_uringon Linux/Android,IOCPon Windows, andkqueueon macOS) for zero-copy completion-based I/O. - Authenticated Encryption: Ephemeral
X25519key exchange (DH) andChaCha20-Poly1305orAES-256-GCMpayload encryption (with hardware acceleration). - Smart Compression: Concurrent
zstdlevel 1 compression that automatically skips pre-compressed file extensions (e.g.,.zip,.mp4,.png). - Safe Extraction: Automatic directory streaming using tar archives with robust path-traversal protection.
- Zero-Config Pairing: Easy peer discovery over local subnets using random code phrase broadcasters.
✦ Quick Start
Add hayate and compio to your Cargo.toml:
[]
= "2.0"
= { = "0.19", = ["macros", "runtime"] }
1. Sending a File or Directory
use SocketAddr;
use HayateSender;
async
2. Receiving a File or Directory
use SocketAddr;
use HayateReceiver;
async
3. Pairing via Shared Code Phrase
You can establish connections without exchanging IP addresses manually:
Sender:
let sender = new
.code;
sender.send.await?;
Receiver:
let receiver = new
.code;
receiver.receive.await?;
✦ System Architecture & Design
Completion-Based I/O (Proactor)
Unlike readiness-based models (such as epoll or tokio), compio utilizes a completion-based model. When an I/O operation (like reading a file or socket) is requested, the buffer's ownership is passed directly to the OS kernel. The kernel writes to or reads from it, and returns the buffer back via completion queues.
Therefore, any custom implementation using hayate's low-level APIs must respect this ownership flow, using compio::BufResult return types.
Thread-Per-Core Concurrency
To avoid mutex contention and thread synchronization overhead:
- Every processor core runs its own single-threaded executor.
- Sockets and files bound to an executor thread are touched only by that thread.
- Heavy CPU work (such as Zstd compression and AEAD seal/open operations) is offloaded to a dedicated worker pool, leaving the reactor/proactor thread free to poll I/O completion queues.
✦ Security & Threat Model
- MITM Defense: Ephemeral self-signed X.509 certificates are exchanged over QUIC TLS 1.3. To prevent Man-In-The-Middle attacks in unauthenticated LAN environments, Hayate salts the Diffie-Hellman key derivation with the user's code-phrase/passphrase.
- Payload Isolation: Payloads and filenames are encrypted using an application-level key, ensuring that even if the TLS layer is intercepted, raw file data remains unreadable.
✦ License
This project is licensed under the MIT License. See LICENSE for details.