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
Rasensprenger 23a67a87d9
Some checks failed
renovate/stability-days Updates have met minimum release age requirement
CI / checks (pull_request) Failing after 2m20s
Update Rust crate chacha20poly1305 to 0.11
2026-08-19 13:00:54 +03:00
.cargo [Fix] Version Bump, Checks, tests CQ 2026-08-13 21:18:55 +02:00
.forgejo/workflows [Fix] Version Bump, Checks, tests CQ 2026-08-13 21:18:55 +02:00
client [Fix] Harden MTP codec, transport, and SDK security 2026-08-18 20:58:01 +02:00
codec [Fix] Clean 2026-08-18 21:53:02 +02:00
common [Fix] Harden MTP codec, transport, and SDK security 2026-08-18 20:58:01 +02:00
crypto Update Rust crate chacha20poly1305 to 0.11 2026-08-19 13:00:54 +03:00
docs [Fix] Harden MTP codec, transport, and SDK security 2026-08-18 20:58:01 +02:00
example [Fix] Clean 2026-08-19 11:46:40 +02:00
files [Fix] Harden MTP codec, transport, and SDK security 2026-08-18 20:58:01 +02:00
host [Fix] Clean 2026-08-18 21:53:02 +02:00
mtp-webserver [Fix] Harden MTP codec, transport, and SDK security 2026-08-18 20:58:01 +02:00
src [Fix] Harden MTP codec, transport, and SDK security 2026-08-18 20:58:01 +02:00
test [Fix] Harden MTP codec, transport, and SDK security 2026-08-18 20:58:01 +02:00
transport [Fix] Clean 2026-08-18 21:53:02 +02:00
type-map [Fix] Version Bump, Checks, tests CQ 2026-08-13 21:18:55 +02:00
wasm [Fix] Clean 2026-08-19 11:46:40 +02:00
.gitignore [WIP] Security work While on holiday 2026-08-12 22:45:28 +02:00
Cargo.lock [Fix] Clean 2026-08-19 11:46:40 +02:00
Cargo.toml [Fix] Version Bump, Checks, tests CQ 2026-08-13 21:18:55 +02:00
clippy.toml (feat): rename example-usage to just example 2026-06-27 03:20:25 +02:00
create-web-release.mjs [Fix] Clean 2026-08-18 21:53:02 +02:00
deny.toml [Fix] Clean 2026-08-19 11:46:40 +02:00
example-type-maps.yaml [WIP] Security work While on holiday 2026-08-12 22:45:28 +02:00
flake.lock (fix): nix related stuff 2026-06-28 18:48:49 +02:00
flake.nix [Fix] Clean 2026-08-18 21:53:02 +02:00
package.json [Fix] Clean 2026-08-19 11:46:40 +02:00
pnpm-lock.yaml [Fix] Clean 2026-08-19 11:46:40 +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 [WIP] Security work While on holiday 2026-08-12 22:45:28 +02:00
renovate.json Add renovate.json 2026-08-05 20:16:23 +02:00
rustfmt.toml Merge 2026-06-25 22:08:44 +02:00
tsconfig.json [Fix] Version Bump, Checks, tests CQ 2026-08-13 21:18:55 +02:00
tsconfig.type-tests.json [WIP] Security work While on holiday 2026-08-12 22:45:28 +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 TCP TLS (HTTP/1.1 and HTTP/2) plus UDP QUIC (HTTP/3 and WebTransport) on one numeric port. It must not bind its UDP address and port as MTPHost: their QUIC ALPN protocols remain incompatible (h3 for the web server, native MTP for the host).

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
webserver mtp::webserver HTTPS server with HTTP/1.1, HTTP/2, HTTP/3, and WebTransport MTP sessions

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 self-delimiting containers, integers, booleans, floats, strings, arrays, bytes, null values, and composable Signed<Value> and Encrypted<Value> protection wrappers. Wrap in either order to choose whether signer metadata is public or encrypted. 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, composable protection envelopes, 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.