β‘ ferogram
ferogram is a hand-written, bottom-up implementation of Telegram MTProto in pure Rust. Every component: from the .tl schema parser, to AES-IGE encryption, to the Diffie-Hellman key exchange, to the typed async update stream: is owned and understood by this project.
No black boxes. No magic. Just Rust, all the way down.
Why ferogram?
Most Telegram libraries are thin wrappers around generated code or ports from Python/JavaScript. ferogram is different: it was built from scratch to understand MTProto at the lowest level, then exposed through a straightforward high-level API.
client.invoke() with full type safety.Crate overview
| Crate | Description | Typical user |
|---|---|---|
ferogram | High-level async client: auth, send, receive, bots | β You |
ferogram-tl-types | All Layer 224 constructors, functions, enums | Raw API calls |
ferogram-mtproto | MTProto session, DH, framing, transport | Library authors |
ferogram-crypto | AES-IGE, RSA, SHA, auth key derivation | Internal |
ferogram-tl-gen | Build-time Rust code generator | Build tool |
ferogram-tl-parser | .tl schema β AST parser | Build tool |
TIP: Most users only ever import
ferogram. The other crates are either used internally or for advanced raw API calls.
Quick install
[dependencies]
ferogram = "0.1.1"
tokio = { version = "1", features = ["full"] }
Then head to Installation for credentials setup, or jump straight to:
- Quick Start: User Account: login, send a message, receive updates
- Quick Start: Bot: bot token login, commands, callbacks
Initial Release v0.1.0
Proxy & Transport
- MTProxy support: connect via
t.me/proxy/tg://proxylinks or manual host/port/secret config - PaddedIntermediate transport (
0xDDsecrets): randomized padding to mimic official Telegram traffic - FakeTLS transport (
0xEEsecrets): TLS-like framing to make MTProto traffic resemble HTTPS - SOCKS5 proxy support in
Configwith optional username/password authentication - IPv6 connectivity for Telegram DCs and proxy connections
Session & Client
- Multiple session backend support with new
Confighelpers and builder methods for MTProxy
Protocol Fixes
- Auth key generation fixed: now uses correct
PQInnerDataDcconstructor including the DC id: resolves auth failures on many DCs - Incoming message validation: rolling buffer of last 500 server
msg_ids + Β±300 s timestamp window to prevent replay attacks dh_gen_retryhandling: step 3 now retries with cached params, up to 5 attempts (matching Telegram Desktop)- MTProxy routing bug fixed: connections now correctly route through the proxy host instead of going directly to Telegram DCs
- Channel difference sync: initial
getChannelDifferencestarts at limit 100, subsequent calls increase to 1000
See the full CHANGELOG.
Author
Developed by Ankit Chaubey out of curiosity to explore.
ferogram is developed as part of exploration, learning, and experimentation with the Telegram MTProto protocol. Use it at your own risk. Its future and stability are not yet guaranteed.
Terms of Service
Ensure your usage complies with Telegramβs Terms of Service and API Terms of Service. Misuse of the Telegram API, including spam, mass scraping, or automation of normal user accounts, may result in account limitations or permanent bans.