Methanium Transport Protocol
  • Rust 77.2%
  • TypeScript 15.6%
  • JavaScript 6.6%
  • Nix 0.4%
  • HTML 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Alex Emmet cf52b22537
Some checks failed
CI / checks (push) Failing after 4m20s
General Upgrade, NEW: WebServers, Better Docs
2026-07-18 14:32:31 +02:00
.cargo Doc update 2026-06-28 04:17:42 +02:00
.forgejo/workflows General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
client General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
codec General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
common General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
crypto General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
docs General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
example General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
files General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
host General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
mtp-webserver General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
src General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
test General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
transport General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
type-map General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
wasm General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
.gitignore (feat): add max message size to wasm 2026-06-28 13:08:37 +02:00
Cargo.lock General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
Cargo.toml General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
clippy.toml (feat): rename example-usage to just example 2026-06-27 03:20:25 +02:00
deny.toml Merge 2026-06-25 22:08:44 +02:00
example-type-maps.yaml General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
flake.lock (fix): nix related stuff 2026-06-28 18:48:49 +02:00
flake.nix General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
package.json General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
pnpm-lock.yaml General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
pnpm-workspace.yaml (feat): redesign WASM module, add TypeScript SDK, migrate to pnpm 2026-06-27 23:44:27 +02:00
README.md General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00
rustfmt.toml Merge 2026-06-25 22:08:44 +02:00
tsconfig.json General Upgrade, NEW: WebServers, Better Docs 2026-07-18 14:32:31 +02:00

Methanium Transport Protocol

MTP is a modular transport protocol built on QUIC. It provides versioned type maps, a binary codec, native and browser clients, host and WebTransport server implementations, and optional cryptographic authentication and end-to-end encryption.

Security assumptions, certificate handling, authentication, cryptographic primitives, key storage, and known limitations: Security.

Area-specific guides:

MTPWebServer owns its UDP endpoint and must not bind to the same address and port as MTPHost.

Browser SDK

The JavaScript package is mtp.

  • mtp exports the SDK-first MTPClient API and codec helpers.
  • mtp/raw exports generated WASM bindings for lower-level integrations.
  • mtp/vite exports the Vite integration that builds app-specific bindings.
  • mtp/type-map exports generated TypeScript type-name unions.

Use the WASM client guide for installation, type-map configuration, credentials, certificate pins, requests, subscriptions, pipes, and protocol pings. Use the SDK methods before raw bindings because the raw API does not provide the wrapper's validation, persistence, timeout, logging, or lifecycle handling.

The SDK exposes crypto helpers and frame codec helpers from the main mtp export. The security guide describes the available algorithms and their limitations.

Getting Started

Add the umbrella crate with the features required by the application:

[dependencies]
mtp = { path = "..", features = ["client", "crypto"] }

Feature summary:

Feature Pulls in Enables
crypto mtp::crypto AEAD, signatures, KEM, KDF, hashing
host mtp::host, codec registry QUIC host and version negotiation
client mtp::client QUIC client connections

The core crates are always available: codec, transport, common, and type_map. See the native client and native host guides for configuration and usage. See Security for security boundaries.

Sub-crates

The mtp facade re-exports the following modules: mtp::codec, mtp::transport, mtp::common, mtp::type_map, mtp::crypto, mtp::host, and mtp::client.

Codec

The codec encodes and decodes MTP frames using Communication Types and Data Types resolved through a version-specific type map. It supports containers, integers, booleans, floats, strings, arrays, bytes, null values, and optional signed or encrypted containers. See Type Map for mapping configuration and Connector for negotiated codecs.

Transport

The transport crate wraps QUIC with wtransport. Sender and Receiver exchange framed messages over unidirectional streams. The transport supports a persistent stream and a single-stream-per-message mode, with configurable message limits, timeouts, queues, and stream concurrency.

Certificate verification is controlled by client configuration. Use system roots or explicit certificate and SPKI pinning for production. Development self-signed and insecure modes: Security.

Host

The host crate provides MTPHost, registry-backed version negotiation, optional authentication, and MTPConnection handles. Authentication policies and the challenge-response protocol: Native Host and Security.

Client

The native client provides unauthenticated connections, authenticated login, and registration when the crypto feature is enabled. See Native Client.

The browser client uses the mtp SDK over WebTransport. See WASM Client.

Common

Common defines shared errors such as CodecError and CommunicationError, as well as protocol-level types used by the other crates.

Type Map

The type-map build script reads YAML and generates CommunicationType and DataType enums at compile time. The runtime crate provides TypeMap, Version, ID types, and the multi-version Registry when the registry feature is enabled. See Type Map.

Crypto

mtp-crypto provides AEAD encryption, Ed25519 and ML-DSA-65 signatures, X25519 plus ML-KEM-768 hybrid KEM support, HKDF, SHA-256, keyrings, encrypted containers, and certificate generation for development. Feature flags and security boundaries: Security.

Examples

The example/ workspace contains native client, native server, key-generation, WebTransport server, and browser client examples. The example server stores its generated development certificate and host keys locally; use the certificate pin it prints when connecting the example client.