From b2be135a6f5ddbf9e7594f44c7a17f0a25c1791e Mon Sep 17 00:00:00 2001
From: Luke Curley
Date: Mon, 2 Nov 2026 23:51:42 -0800
Subject: [PATCH 01/11] chore(quest): claim quest/m1/moq-crypto.md
Quest-Claim: ec626ee42f3fe8f7
From 9273cc2e50b72ae265b6731ba5a8931441615e6b Mon Sep 17 00:00:00 2001
From: Luke Curley
Date: Tue, 3 Nov 2026 00:05:13 -0800
Subject: [PATCH 02/11] refactor!: merge moq-sign and moq-e2ee into moq-crypto
One Rust crate, moq-crypto, and one JS package, @moq/crypto, hold content
signing (`sign`) and end-to-end encryption (`e2ee`). Both halves check
timestamps with moq_net::group::on_track (an internal mirror in JS), so
neither accepts a frame its net track would refuse. rs/moq-e2ee becomes a
code-free stub pointing at moq-crypto, for its final crates.io release at
the cut.
Co-Authored-By: Claude Opus 5.5
---
.oss-scanner/Dockerfile | 2 +-
.oss-scanner/threat_model.md | 4 +-
Cargo.lock | 31 ++----
Cargo.toml | 3 +-
bun.lock | 20 +---
doc/concept/hang.md | 2 +-
doc/lib/js/index.md | 3 +-
doc/lib/rs/index.md | 3 +-
doc/setup/repository.md | 4 +-
doc/setup/upgrade.md | 2 +-
js/{e2ee => crypto}/README.md | 68 +++++++++++-
js/{e2ee => crypto}/bench/pump.ts | 2 +-
js/{e2ee => crypto}/bench/tsconfig.json | 0
js/{e2ee => crypto}/package.json | 6 +-
js/{e2ee/src => crypto/src/e2ee}/broadcast.ts | 0
.../src => crypto/src/e2ee}/credential.ts | 0
js/{e2ee/src => crypto/src/e2ee}/datagram.ts | 0
js/{e2ee/src => crypto/src/e2ee}/derive.ts | 0
js/{e2ee/src => crypto/src/e2ee}/e2ee.test.ts | 2 +-
.../src => crypto/src/e2ee}/epoch.test.ts | 4 +-
js/{e2ee/src => crypto/src/e2ee}/epoch.ts | 2 +-
js/{e2ee/src => crypto/src/e2ee}/failure.ts | 0
.../src/e2ee}/generation-internal.ts | 0
.../src => crypto/src/e2ee}/generation.ts | 0
js/{e2ee/src => crypto/src/e2ee}/group.ts | 7 +-
js/{e2ee/src => crypto/src/e2ee}/index.ts | 2 +-
js/{e2ee/src => crypto/src/e2ee}/internal.ts | 13 +--
js/{e2ee/src => crypto/src/e2ee}/key.ts | 0
js/{e2ee/src => crypto/src/e2ee}/limits.ts | 0
js/{e2ee/src => crypto/src/e2ee}/name.ts | 0
js/{e2ee/src => crypto/src/e2ee}/secret.ts | 0
js/{e2ee/src => crypto/src/e2ee}/terminal.ts | 0
js/{e2ee/src => crypto/src/e2ee}/track.ts | 9 +-
.../src => crypto/src/e2ee}/transport.test.ts | 2 +-
.../src => crypto/src/e2ee}/vectors.test.ts | 2 +-
js/{e2ee/src => crypto/src/e2ee}/window.ts | 0
js/crypto/src/index.ts | 14 +++
js/{e2ee => crypto}/src/pump.ts | 0
js/{sign/src => crypto/src/sign}/broadcast.ts | 0
js/{sign/src => crypto/src/sign}/failure.ts | 0
js/{sign/src => crypto/src/sign}/group.ts | 13 +--
js/{sign/src => crypto/src/sign}/index.ts | 2 +-
js/{sign/src => crypto/src/sign}/key.ts | 0
js/{sign/src => crypto/src/sign}/scope.ts | 0
js/{sign/src => crypto/src/sign}/sign.test.ts | 8 +-
js/{sign/src => crypto/src/sign}/track.ts | 2 +-
.../src => crypto/src/sign}/vectors.test.ts | 2 +-
js/{sign/src => crypto/src/sign}/zbase32.ts | 0
js/crypto/src/timestamp.ts | 19 ++++
js/{e2ee => crypto}/test-dts/constructors.ts | 12 +--
js/{e2ee => crypto}/test-dts/tsconfig.json | 0
js/{e2ee => crypto}/tsconfig.build.json | 0
js/{e2ee => crypto}/tsconfig.json | 0
js/sign/README.md | 50 ---------
js/sign/package.json | 30 ------
js/sign/src/pump.ts | 16 ---
js/sign/tsconfig.build.json | 10 --
js/sign/tsconfig.json | 11 --
package.json | 3 +-
quest/m1/README.md | 1 -
quest/m1/moq-crypto.md | 38 -------
quest/m1/poll-first/async-feature.md | 2 +-
quest/m1/time-addressing/e2ee.md | 4 +-
quest/m2/audit-perf.md | 2 +-
quest/m2/e2ee/README.md | 6 +-
quest/m2/e2ee/cli.md | 2 +-
quest/m2/e2ee/consumer.md | 4 +-
quest/m2/e2ee/js-undeclared-names.md | 12 +--
quest/m2/e2ee/rust-publish.md | 8 +-
quest/m2/mesh/README.md | 2 +-
quest/m2/mesh/endpoint.md | 4 +-
quest/m2/net-wrap/README.md | 6 +-
quest/m2/net-wrap/e2ee.md | 24 ++---
quest/m2/net-wrap/js.md | 14 +--
quest/m2/net-wrap/json.md | 4 +-
quest/m2/net-wrap/mux.md | 2 +-
quest/m2/net-wrap/traits.md | 2 +-
quest/m2/release/cut.md | 8 ++
quest/m2/stream/README.md | 2 +-
quest/m3/ffi-e2ee.md | 6 +-
quest/m3/mesh-keys.md | 2 +-
rs/justfile | 2 +-
rs/{moq-e2ee => moq-crypto}/CHANGELOG.md | 0
rs/{moq-sign => moq-crypto}/Cargo.toml | 18 +++-
rs/{moq-e2ee => moq-crypto}/MIGRATE.md | 15 ++-
rs/moq-crypto/README.md | 102 ++++++++++++++++++
.../benches/protect.rs | 10 +-
rs/{moq-sign => moq-crypto}/benches/sign.rs | 10 +-
.../src => moq-crypto/src/e2ee}/broadcast.rs | 10 +-
.../src => moq-crypto/src/e2ee}/credential.rs | 8 +-
.../src => moq-crypto/src/e2ee}/datagram.rs | 0
.../src => moq-crypto/src/e2ee}/epoch.json | 0
.../src => moq-crypto/src/e2ee}/epoch.rs | 2 +-
.../src => moq-crypto/src/e2ee}/error.rs | 2 +-
.../src => moq-crypto/src/e2ee}/generation.rs | 30 +++---
.../src => moq-crypto/src/e2ee}/group.rs | 21 ++--
.../src => moq-crypto/src/e2ee}/key.rs | 6 +-
.../src => moq-crypto/src/e2ee}/limits.rs | 8 +-
rs/moq-crypto/src/e2ee/mod.rs | 52 +++++++++
.../src => moq-crypto/src/e2ee}/name.rs | 4 +-
.../src => moq-crypto/src/e2ee}/protect.rs | 4 +-
.../src => moq-crypto/src/e2ee}/terminal.rs | 2 +-
.../src => moq-crypto/src/e2ee}/tests.rs | 51 +++++----
.../src => moq-crypto/src/e2ee}/track.rs | 32 +++---
.../src => moq-crypto/src/e2ee}/window.rs | 2 +-
rs/moq-crypto/src/lib.rs | 11 ++
.../src => moq-crypto/src/sign}/broadcast.rs | 8 +-
.../src => moq-crypto/src/sign}/error.rs | 2 +-
.../src => moq-crypto/src/sign}/group.rs | 12 +--
.../src => moq-crypto/src/sign}/key.rs | 2 +-
.../src/lib.rs => moq-crypto/src/sign/mod.rs} | 0
.../src => moq-crypto/src/sign}/scope.rs | 4 +-
.../src => moq-crypto/src/sign}/tests.rs | 6 +-
.../src => moq-crypto/src/sign}/track.rs | 10 +-
.../tests/support/harness.rs | 0
.../tests/support/mod.rs | 0
.../tests/transport.rs | 20 ++--
rs/moq-e2ee/Cargo.toml | 24 +----
rs/moq-e2ee/README.md | 57 ++--------
rs/moq-e2ee/src/lib.rs | 53 +--------
rs/moq-net/src/model/origin.rs | 2 +-
rs/moq-sign/README.md | 45 --------
sh/gh/nightly.sh | 2 +-
test/interop/sign.ts | 10 +-
test/justfile | 2 +-
125 files changed, 570 insertions(+), 631 deletions(-)
rename js/{e2ee => crypto}/README.md (59%)
rename js/{e2ee => crypto}/bench/pump.ts (97%)
rename js/{e2ee => crypto}/bench/tsconfig.json (100%)
rename js/{e2ee => crypto}/package.json (83%)
rename js/{e2ee/src => crypto/src/e2ee}/broadcast.ts (100%)
rename js/{e2ee/src => crypto/src/e2ee}/credential.ts (100%)
rename js/{e2ee/src => crypto/src/e2ee}/datagram.ts (100%)
rename js/{e2ee/src => crypto/src/e2ee}/derive.ts (100%)
rename js/{e2ee/src => crypto/src/e2ee}/e2ee.test.ts (99%)
rename js/{e2ee/src => crypto/src/e2ee}/epoch.test.ts (78%)
rename js/{e2ee/src => crypto/src/e2ee}/epoch.ts (95%)
rename js/{e2ee/src => crypto/src/e2ee}/failure.ts (100%)
rename js/{e2ee/src => crypto/src/e2ee}/generation-internal.ts (100%)
rename js/{e2ee/src => crypto/src/e2ee}/generation.ts (100%)
rename js/{e2ee/src => crypto/src/e2ee}/group.ts (96%)
rename js/{e2ee/src => crypto/src/e2ee}/index.ts (98%)
rename js/{e2ee/src => crypto/src/e2ee}/internal.ts (57%)
rename js/{e2ee/src => crypto/src/e2ee}/key.ts (100%)
rename js/{e2ee/src => crypto/src/e2ee}/limits.ts (100%)
rename js/{e2ee/src => crypto/src/e2ee}/name.ts (100%)
rename js/{e2ee/src => crypto/src/e2ee}/secret.ts (100%)
rename js/{e2ee/src => crypto/src/e2ee}/terminal.ts (100%)
rename js/{e2ee/src => crypto/src/e2ee}/track.ts (97%)
rename js/{e2ee/src => crypto/src/e2ee}/transport.test.ts (98%)
rename js/{e2ee/src => crypto/src/e2ee}/vectors.test.ts (98%)
rename js/{e2ee/src => crypto/src/e2ee}/window.ts (100%)
create mode 100644 js/crypto/src/index.ts
rename js/{e2ee => crypto}/src/pump.ts (100%)
rename js/{sign/src => crypto/src/sign}/broadcast.ts (100%)
rename js/{sign/src => crypto/src/sign}/failure.ts (100%)
rename js/{sign/src => crypto/src/sign}/group.ts (91%)
rename js/{sign/src => crypto/src/sign}/index.ts (97%)
rename js/{sign/src => crypto/src/sign}/key.ts (100%)
rename js/{sign/src => crypto/src/sign}/scope.ts (100%)
rename js/{sign/src => crypto/src/sign}/sign.test.ts (95%)
rename js/{sign/src => crypto/src/sign}/track.ts (99%)
rename js/{sign/src => crypto/src/sign}/vectors.test.ts (96%)
rename js/{sign/src => crypto/src/sign}/zbase32.ts (100%)
create mode 100644 js/crypto/src/timestamp.ts
rename js/{e2ee => crypto}/test-dts/constructors.ts (55%)
rename js/{e2ee => crypto}/test-dts/tsconfig.json (100%)
rename js/{e2ee => crypto}/tsconfig.build.json (100%)
rename js/{e2ee => crypto}/tsconfig.json (100%)
delete mode 100644 js/sign/README.md
delete mode 100644 js/sign/package.json
delete mode 100644 js/sign/src/pump.ts
delete mode 100644 js/sign/tsconfig.build.json
delete mode 100644 js/sign/tsconfig.json
delete mode 100644 quest/m1/moq-crypto.md
rename rs/{moq-e2ee => moq-crypto}/CHANGELOG.md (100%)
rename rs/{moq-sign => moq-crypto}/Cargo.toml (63%)
rename rs/{moq-e2ee => moq-crypto}/MIGRATE.md (78%)
create mode 100644 rs/moq-crypto/README.md
rename rs/{moq-e2ee => moq-crypto}/benches/protect.rs (83%)
rename rs/{moq-sign => moq-crypto}/benches/sign.rs (91%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/broadcast.rs (97%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/credential.rs (96%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/datagram.rs (100%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/epoch.json (100%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/epoch.rs (97%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/error.rs (94%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/generation.rs (87%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/group.rs (91%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/key.rs (94%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/limits.rs (92%)
create mode 100644 rs/moq-crypto/src/e2ee/mod.rs
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/name.rs (97%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/protect.rs (95%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/terminal.rs (98%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/tests.rs (96%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/track.rs (93%)
rename rs/{moq-e2ee/src => moq-crypto/src/e2ee}/window.rs (98%)
create mode 100644 rs/moq-crypto/src/lib.rs
rename rs/{moq-sign/src => moq-crypto/src/sign}/broadcast.rs (96%)
rename rs/{moq-sign/src => moq-crypto/src/sign}/error.rs (89%)
rename rs/{moq-sign/src => moq-crypto/src/sign}/group.rs (91%)
rename rs/{moq-sign/src => moq-crypto/src/sign}/key.rs (99%)
rename rs/{moq-sign/src/lib.rs => moq-crypto/src/sign/mod.rs} (100%)
rename rs/{moq-sign/src => moq-crypto/src/sign}/scope.rs (97%)
rename rs/{moq-sign/src => moq-crypto/src/sign}/tests.rs (99%)
rename rs/{moq-sign/src => moq-crypto/src/sign}/track.rs (96%)
rename rs/{moq-e2ee => moq-crypto}/tests/support/harness.rs (100%)
rename rs/{moq-e2ee => moq-crypto}/tests/support/mod.rs (100%)
rename rs/{moq-e2ee => moq-crypto}/tests/transport.rs (86%)
delete mode 100644 rs/moq-sign/README.md
diff --git a/.oss-scanner/Dockerfile b/.oss-scanner/Dockerfile
index b16764819e2..87281d83048 100644
--- a/.oss-scanner/Dockerfile
+++ b/.oss-scanner/Dockerfile
@@ -22,7 +22,7 @@ RUN rustup show active-toolchain || rustup toolchain install \
&& curl -LsSf "https://get.nexte.st/$NEXTEST_VERSION/$nextest" | tar zxf - -C "$CARGO_HOME/bin" \
&& cargo nextest --version
-ARG CRATES="kio hang moq-auth moq-e2ee moq-hls moq-ice moq-json moq-loc moq-msf moq-mux moq-net moq-pattern moq-quic moq-relay moq-rtc moq-rtmp moq-rtsp moq-sock moq-srt moq-stats moq-tokio moq-uring moq-cli"
+ARG CRATES="kio hang moq-auth moq-crypto moq-hls moq-ice moq-json moq-loc moq-msf moq-mux moq-net moq-pattern moq-quic moq-relay moq-rtc moq-rtmp moq-rtsp moq-sock moq-srt moq-stats moq-tokio moq-uring moq-cli"
# Path specs, because the lockfile also has published copies of some workspace crates.
# io-uring compiles the relay's io_uring QUIC workers (`--runtime-io-uring`), which the default features leave out.
diff --git a/.oss-scanner/threat_model.md b/.oss-scanner/threat_model.md
index 3e5c46bcceb..033fd571837 100644
--- a/.oss-scanner/threat_model.md
+++ b/.oss-scanner/threat_model.md
@@ -25,7 +25,7 @@ The relay is deployed on the public internet as shared infrastructure: one proce
- **Cache integrity.** The relay caches and forwards groups by broadcast, track, and group. A publisher must not be able to overwrite or inject into a broadcast it was not granted, and a subscriber must never receive one tenant's data under another tenant's name.
- **Cluster trust.** Peer relays authenticate with tokens or mTLS and get broader rights than clients. A relay dials only configured or discovered peers, never a URL learned from an announcement. LAN discovery over mDNS (`[cluster.lan]`) is open to anyone on the network unless `secret` is set, which is documented; with `secret` set, an unkeyed host must not be able to join.
- **Amplification and reflection.** QUIC's anti-amplification limit and address validation, the opt-in public STUN responder (`rs/moq-relay/src/stun.rs`), and ICE in the WebRTC gateway all answer unauthenticated UDP. A response larger than the request toward a spoofed source is a finding.
-- **End-to-end encryption.** `moq-e2ee` encrypts groups, datagrams, and track names so a relay cannot read them. A flaw in its construction (nonce reuse, a key or name leaking to the relay, a forgeable group) is in scope.
+- **End-to-end encryption and signing.** `moq-crypto` encrypts groups, datagrams, and track names so a relay cannot read them, and signs frames so a relay cannot forge them. A flaw in either construction (nonce reuse, a key or name leaking to the relay, a forgeable group or signature) is in scope.
## Components that matter most / least
@@ -35,7 +35,7 @@ Most important, in this order:
2. Authorization: a session publishing, subscribing, or seeing announcements outside its grant, or reaching another root (tenant) through path tricks, revalidation, mounts, or cluster links.
3. `rs/moq-mux` and `rs/hang`: container, codec, and catalog parsing of publisher-controlled bytes.
4. The ingest gateways: `rs/moq-rtmp`, `rs/moq-rtsp`, `rs/moq-srt`, `rs/moq-rtc`, `rs/moq-ice`, `rs/moq-hls`.
-5. `rs/moq-e2ee`, `rs/moq-cli`, `rs/moq-json`, `rs/moq-stats`, `rs/kio`.
+5. `rs/moq-crypto`, `rs/moq-cli`, `rs/moq-json`, `rs/moq-stats`, `rs/kio`.
`unsafe` is rare and worth reading closely where it appears: `rs/moq-quic`, `rs/moq-net/src/model`, `rs/moq-net/src/util/cell.rs`, `rs/moq-net/src/transport.rs`, and `rs/moq-relay/src/uring.rs`.
diff --git a/Cargo.lock b/Cargo.lock
index 884ded34ab1..3e0aa7c2da0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5153,17 +5153,20 @@ dependencies = [
]
[[package]]
-name = "moq-e2ee"
+name = "moq-crypto"
version = "0.0.11"
dependencies = [
+ "aws-lc-rs",
"base64 0.23.1",
"bench-harness",
"bytes",
+ "data-encoding",
"hex",
"kio 0.6.2",
"moq-net",
"rind",
"serde_json",
+ "tempfile",
"thiserror 2.0.21",
"tokio",
"uuid",
@@ -5171,6 +5174,13 @@ dependencies = [
"zeroize",
]
+[[package]]
+name = "moq-e2ee"
+version = "0.0.11"
+dependencies = [
+ "workspace-hack",
+]
+
[[package]]
name = "moq-ffi"
version = "0.4.12"
@@ -5659,25 +5669,6 @@ dependencies = [
"workspace-hack",
]
-[[package]]
-name = "moq-sign"
-version = "0.0.1"
-dependencies = [
- "aws-lc-rs",
- "bench-harness",
- "bytes",
- "data-encoding",
- "hex",
- "kio 0.6.2",
- "moq-net",
- "serde_json",
- "tempfile",
- "thiserror 2.0.21",
- "tokio",
- "workspace-hack",
- "zeroize",
-]
-
[[package]]
name = "moq-sock"
version = "0.2.0"
diff --git a/Cargo.toml b/Cargo.toml
index fd42fd2a7ff..d7dcfbac1ae 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,7 +15,7 @@ default-members = [
"rs/moq-audio",
"rs/moq-bench",
"rs/moq-cli",
- "rs/moq-e2ee",
+ "rs/moq-crypto",
# "rs/moq-ffi", # requires Python/maturin
# "rs/moq-gst", # requires GStreamer
"rs/moq-hls",
@@ -36,7 +36,6 @@ default-members = [
"rs/moq-rtmp",
"rs/moq-rtsp",
"rs/moq-shaper",
- "rs/moq-sign",
"rs/moq-sock",
"rs/moq-srt",
"rs/moq-stats",
diff --git a/bun.lock b/bun.lock
index 8a34739da90..8a0c09c4067 100644
--- a/bun.lock
+++ b/bun.lock
@@ -160,8 +160,8 @@
"typescript": "7.0.2",
},
},
- "js/e2ee": {
- "name": "@moq/e2ee",
+ "js/crypto": {
+ "name": "@moq/crypto",
"version": "0.0.0",
"dependencies": {
"@moq/net": "workspace:^",
@@ -361,18 +361,6 @@
"vite": "^8.3.5",
},
},
- "js/sign": {
- "name": "@moq/sign",
- "version": "0.0.0",
- "dependencies": {
- "@moq/net": "workspace:^",
- },
- "devDependencies": {
- "@moq/clock": "workspace:^",
- "@types/bun": "^1.4.4",
- "typescript": "7.0.2",
- },
- },
"js/signals": {
"name": "@moq/signals",
"version": "0.2.5",
@@ -860,7 +848,7 @@
"@moq/drain-test": ["@moq/drain-test@workspace:test/drain"],
- "@moq/e2ee": ["@moq/e2ee@workspace:js/e2ee"],
+ "@moq/crypto": ["@moq/crypto@workspace:js/crypto"],
"@moq/hang": ["@moq/hang@workspace:js/hang"],
@@ -894,8 +882,6 @@
"@moq/room": ["@moq/room@workspace:js/room"],
- "@moq/sign": ["@moq/sign@workspace:js/sign"],
-
"@moq/signals": ["@moq/signals@workspace:js/signals"],
"@moq/ui": ["@moq/ui@workspace:js/ui"],
diff --git a/doc/concept/hang.md b/doc/concept/hang.md
index 547dc5d9b54..c60c0366b59 100644
--- a/doc/concept/hang.md
+++ b/doc/concept/hang.md
@@ -237,7 +237,7 @@ under one credential, whether for a replica or a later run: two instances on
one epoch derive the same keys from the same group sequences and repeat
AES-GCM nonces. The broadcast path is an opaque name
derived from the credential and a semantic name such as `foo.hang`; it carries
-no format marker. `moq-e2ee` is the Rust implementation. Relays need no
+no format marker. `moq-crypto` is the Rust implementation. Relays need no
configuration to carry it.
## Your own format
diff --git a/doc/lib/js/index.md b/doc/lib/js/index.md
index 79b7f0aa322..5134987f200 100644
--- a/doc/lib/js/index.md
+++ b/doc/lib/js/index.md
@@ -31,8 +31,7 @@ small examples. The [API reference](/lib/js/api/) covers every package; source l
| [@moq/clock](/lib/js/clock) | Logical monotonic time, wall time, and deterministic timers. |
| [@moq/signals](/lib/js/signals) | The reactive primitives every package exposes its state through. |
| [@moq/json](/lib/js/json) | JSON over tracks: snapshots with merge-patch deltas, or append logs. |
-| [@moq/e2ee](https://github.com/moq-dev/moq/tree/main/js/e2ee) | End-to-end encryption of groups, datagrams, and track names, scoped to a publisher run's epoch. Workspace-only until the browser components use it. |
-| [@moq/sign](https://github.com/moq-dev/moq/tree/main/js/sign) | Per-frame Ed25519 signatures, so relays forward content they cannot forge, retime, or relocate. Workspace-only until the mesh uses it. |
+| [@moq/crypto](https://github.com/moq-dev/moq/tree/main/js/crypto) | End-to-end encryption of groups, datagrams, and track names, scoped to a publisher run's epoch, and per-frame Ed25519 signatures, so relays forward content they cannot read, forge, retime, or relocate. Workspace-only until the browser components or the mesh use it. |
| [@moq/loc](/lib/js/api/loc), [@moq/msf](/lib/js/api/msf) | The IETF LOC container and MSF catalog. |
| [@moq/boy](/lib/js/api/boy) | The [MoQ Boy](/bin/demo) player element. |
diff --git a/doc/lib/rs/index.md b/doc/lib/rs/index.md
index ddf1e7bf83b..7072bf6e852 100644
--- a/doc/lib/rs/index.md
+++ b/doc/lib/rs/index.md
@@ -35,8 +35,7 @@ see [Applications](/bin/). [Examples](/setup/examples) links runnable consumers;
| [moq-auth](/lib/rs/moq-auth) | Relay authorization: JWT signing and verification, and the auth server contract. |
| [moq-room](/lib/rs/moq-room) | Workspace-only native rooms; use the published JS room API for applications. |
| [moq-json](/lib/rs/moq-json) | JSON over tracks: snapshots with merge-patch deltas, or append logs. |
-| [moq-e2ee](https://github.com/moq-dev/moq/tree/main/rs/moq-e2ee) | Workspace-only end-to-end encryption of groups, datagrams, and track names, scoped to a publisher run's epoch. |
-| [moq-sign](https://github.com/moq-dev/moq/tree/main/rs/moq-sign) | Workspace-only per-frame Ed25519 signatures, so relays forward content they cannot forge, retime, or relocate. |
+| [moq-crypto](https://github.com/moq-dev/moq/tree/main/rs/moq-crypto) | Workspace-only end-to-end encryption of groups, datagrams, and track names, scoped to a publisher run's epoch, and per-frame Ed25519 signatures, so relays forward content they cannot read, forge, retime, or relocate. |
| [moq-loc](https://docs.rs/moq-loc), [moq-msf](https://docs.rs/moq-msf) | The IETF LOC container and MSF catalog. |
| [moq-stats](https://docs.rs/moq-stats) | Publish and consume relay traffic counters as tracks. |
| [kio](/lib/rs/kio) | The async primitives everything polls through, and one clock for time and timers on tokio and a deterministic test simulator. |
diff --git a/doc/setup/repository.md b/doc/setup/repository.md
index 25484f05a86..63294c31374 100644
--- a/doc/setup/repository.md
+++ b/doc/setup/repository.md
@@ -31,8 +31,8 @@ wrap the Rust core. [Layers](/lib/layers) maps the binding namespaces.
| CLI commands and protocol gateways | [`rs/moq-cli`](https://github.com/moq-dev/moq/tree/main/rs/moq-cli), then the corresponding `rs/moq-{rtmp,srt,rtc,rtsp,hls}` crate | [Applications](/bin/) |
| Language bindings | [`rs/moq-ffi`](https://github.com/moq-dev/moq/tree/main/rs/moq-ffi), [`rs/moq-c`](https://github.com/moq-dev/moq/tree/main/rs/moq-c), then `py/`, `swift/`, `kt/`, `go/`, `dart/`, or `cpp/moq/` | [Binding layers](/lib/layers) |
| Rooms, chat, and application data | [`rs/moq-room`](https://github.com/moq-dev/moq/tree/main/rs/moq-room), [`js/room`](https://github.com/moq-dev/moq/tree/main/js/room), `rs/moq-json`, `js/json` | [Rooms](/lib/js/room), [JSON tracks](/lib/js/json) |
-| End-to-end encryption | [`rs/moq-e2ee`](https://github.com/moq-dev/moq/tree/main/rs/moq-e2ee), [`js/e2ee`](https://github.com/moq-dev/moq/tree/main/js/e2ee) | [Media encryption](/concept/hang), [E2EE draft](/draft/moq-e2ee) |
-| Signed content | [`rs/moq-sign`](https://github.com/moq-dev/moq/tree/main/rs/moq-sign), [`js/sign`](https://github.com/moq-dev/moq/tree/main/js/sign) | [Signing draft](/draft/moq-sign) |
+| End-to-end encryption | [`rs/moq-crypto`](https://github.com/moq-dev/moq/tree/main/rs/moq-crypto), [`js/crypto`](https://github.com/moq-dev/moq/tree/main/js/crypto) | [Media encryption](/concept/hang), [E2EE draft](/draft/moq-e2ee) |
+| Signed content | [`rs/moq-crypto`](https://github.com/moq-dev/moq/tree/main/rs/moq-crypto), [`js/crypto`](https://github.com/moq-dev/moq/tree/main/js/crypto) | [Signing draft](/draft/moq-sign) |
| Async primitives and deterministic time | [`rs/kio`](https://github.com/moq-dev/moq/tree/main/rs/kio), [`js/clock`](https://github.com/moq-dev/moq/tree/main/js/clock) | [Rust conventions](/lib/rs/#conventions), [clock](/lib/js/clock) |
## Find the surrounding work
diff --git a/doc/setup/upgrade.md b/doc/setup/upgrade.md
index bcaae6ad55c..db6ff59d68b 100644
--- a/doc/setup/upgrade.md
+++ b/doc/setup/upgrade.md
@@ -27,7 +27,7 @@ replaces it.
- **Binaries:** [moq-relay](https://github.com/moq-dev/moq/blob/main/rs/moq-relay/MIGRATE.md), [moq-cli (`moq`)](https://github.com/moq-dev/moq/blob/main/rs/moq-cli/MIGRATE.md), [moq-gst](https://github.com/moq-dev/moq/blob/main/rs/moq-gst/MIGRATE.md), [obs-moq](https://github.com/moq-dev/moq/blob/main/cpp/obs/MIGRATE.md)
- **Bindings:** [moq-ffi (UniFFI)](https://github.com/moq-dev/moq/blob/main/rs/moq-ffi/MIGRATE.md), [moq-c (C)](https://github.com/moq-dev/moq/blob/main/rs/moq-c/MIGRATE.md), [Python](https://github.com/moq-dev/moq/blob/main/py/moq-rs/MIGRATE.md), [Go](https://github.com/moq-dev/moq/blob/main/go/wrapper/MIGRATE.md), [Swift](https://github.com/moq-dev/moq/blob/main/swift/MIGRATE.md), [Kotlin](https://github.com/moq-dev/moq/blob/main/kt/moq/MIGRATE.md), [Dart](https://github.com/moq-dev/moq/blob/main/dart/moq/MIGRATE.md), [C++](https://github.com/moq-dev/moq/blob/main/cpp/moq/MIGRATE.md)
-- **Rust:** [hang](https://github.com/moq-dev/moq/blob/main/rs/hang/MIGRATE.md), [kio](https://github.com/moq-dev/moq/blob/main/rs/kio/MIGRATE.md), [kio-macros](https://github.com/moq-dev/moq/blob/main/rs/kio/macros/MIGRATE.md), [moq-archive](https://github.com/moq-dev/moq/blob/main/rs/moq-archive/MIGRATE.md), [moq-audio](https://github.com/moq-dev/moq/blob/main/rs/moq-audio/MIGRATE.md), [moq-auth](https://github.com/moq-dev/moq/blob/main/rs/moq-auth/MIGRATE.md), [moq-boy](https://github.com/moq-dev/moq/blob/main/rs/moq-boy/MIGRATE.md), [moq-e2ee](https://github.com/moq-dev/moq/blob/main/rs/moq-e2ee/MIGRATE.md), [moq-hls](https://github.com/moq-dev/moq/blob/main/rs/moq-hls/MIGRATE.md), [moq-ice](https://github.com/moq-dev/moq/blob/main/rs/moq-ice/MIGRATE.md), [moq-json](https://github.com/moq-dev/moq/blob/main/rs/moq-json/MIGRATE.md), [moq-loc](https://github.com/moq-dev/moq/blob/main/rs/moq-loc/MIGRATE.md), [moq-msf](https://github.com/moq-dev/moq/blob/main/rs/moq-msf/MIGRATE.md), [moq-mux](https://github.com/moq-dev/moq/blob/main/rs/moq-mux/MIGRATE.md), [moq-net](https://github.com/moq-dev/moq/blob/main/rs/moq-net/MIGRATE.md), [moq-nvenc](https://github.com/moq-dev/moq/blob/main/rs/moq-nvenc/MIGRATE.md), [moq-pattern](https://github.com/moq-dev/moq/blob/main/rs/moq-pattern/MIGRATE.md), [moq-quic](https://github.com/moq-dev/moq/blob/main/rs/moq-quic/MIGRATE.md), [moq-room](https://github.com/moq-dev/moq/blob/main/rs/moq-room/MIGRATE.md), [moq-rtc](https://github.com/moq-dev/moq/blob/main/rs/moq-rtc/MIGRATE.md), [moq-rtmp](https://github.com/moq-dev/moq/blob/main/rs/moq-rtmp/MIGRATE.md), [moq-sock](https://github.com/moq-dev/moq/blob/main/rs/moq-sock/MIGRATE.md), [moq-srt](https://github.com/moq-dev/moq/blob/main/rs/moq-srt/MIGRATE.md), [moq-stats](https://github.com/moq-dev/moq/blob/main/rs/moq-stats/MIGRATE.md), [moq-tokio](https://github.com/moq-dev/moq/blob/main/rs/moq-tokio/MIGRATE.md), [moq-transcode](https://github.com/moq-dev/moq/blob/main/rs/moq-transcode/MIGRATE.md), [moq-uring](https://github.com/moq-dev/moq/blob/main/rs/moq-uring/MIGRATE.md), [moq-v4l](https://github.com/moq-dev/moq/blob/main/rs/moq-v4l/MIGRATE.md), [moq-video](https://github.com/moq-dev/moq/blob/main/rs/moq-video/MIGRATE.md), [qmux](https://github.com/moq-dev/moq/blob/main/rs/qmux/MIGRATE.md)
+- **Rust:** [hang](https://github.com/moq-dev/moq/blob/main/rs/hang/MIGRATE.md), [kio](https://github.com/moq-dev/moq/blob/main/rs/kio/MIGRATE.md), [kio-macros](https://github.com/moq-dev/moq/blob/main/rs/kio/macros/MIGRATE.md), [moq-archive](https://github.com/moq-dev/moq/blob/main/rs/moq-archive/MIGRATE.md), [moq-audio](https://github.com/moq-dev/moq/blob/main/rs/moq-audio/MIGRATE.md), [moq-auth](https://github.com/moq-dev/moq/blob/main/rs/moq-auth/MIGRATE.md), [moq-boy](https://github.com/moq-dev/moq/blob/main/rs/moq-boy/MIGRATE.md), [moq-crypto](https://github.com/moq-dev/moq/blob/main/rs/moq-crypto/MIGRATE.md), [moq-hls](https://github.com/moq-dev/moq/blob/main/rs/moq-hls/MIGRATE.md), [moq-ice](https://github.com/moq-dev/moq/blob/main/rs/moq-ice/MIGRATE.md), [moq-json](https://github.com/moq-dev/moq/blob/main/rs/moq-json/MIGRATE.md), [moq-loc](https://github.com/moq-dev/moq/blob/main/rs/moq-loc/MIGRATE.md), [moq-msf](https://github.com/moq-dev/moq/blob/main/rs/moq-msf/MIGRATE.md), [moq-mux](https://github.com/moq-dev/moq/blob/main/rs/moq-mux/MIGRATE.md), [moq-net](https://github.com/moq-dev/moq/blob/main/rs/moq-net/MIGRATE.md), [moq-nvenc](https://github.com/moq-dev/moq/blob/main/rs/moq-nvenc/MIGRATE.md), [moq-pattern](https://github.com/moq-dev/moq/blob/main/rs/moq-pattern/MIGRATE.md), [moq-quic](https://github.com/moq-dev/moq/blob/main/rs/moq-quic/MIGRATE.md), [moq-room](https://github.com/moq-dev/moq/blob/main/rs/moq-room/MIGRATE.md), [moq-rtc](https://github.com/moq-dev/moq/blob/main/rs/moq-rtc/MIGRATE.md), [moq-rtmp](https://github.com/moq-dev/moq/blob/main/rs/moq-rtmp/MIGRATE.md), [moq-sock](https://github.com/moq-dev/moq/blob/main/rs/moq-sock/MIGRATE.md), [moq-srt](https://github.com/moq-dev/moq/blob/main/rs/moq-srt/MIGRATE.md), [moq-stats](https://github.com/moq-dev/moq/blob/main/rs/moq-stats/MIGRATE.md), [moq-tokio](https://github.com/moq-dev/moq/blob/main/rs/moq-tokio/MIGRATE.md), [moq-transcode](https://github.com/moq-dev/moq/blob/main/rs/moq-transcode/MIGRATE.md), [moq-uring](https://github.com/moq-dev/moq/blob/main/rs/moq-uring/MIGRATE.md), [moq-v4l](https://github.com/moq-dev/moq/blob/main/rs/moq-v4l/MIGRATE.md), [moq-video](https://github.com/moq-dev/moq/blob/main/rs/moq-video/MIGRATE.md), [qmux](https://github.com/moq-dev/moq/blob/main/rs/qmux/MIGRATE.md)
- **JavaScript:** [`@moq/auth`](https://github.com/moq-dev/moq/blob/main/js/auth/MIGRATE.md), [`@moq/boy`](https://github.com/moq-dev/moq/blob/main/js/moq-boy/MIGRATE.md), [`@moq/clock`](https://github.com/moq-dev/moq/blob/main/js/clock/MIGRATE.md), [`@moq/hang`](https://github.com/moq-dev/moq/blob/main/js/hang/MIGRATE.md), [`@moq/json`](https://github.com/moq-dev/moq/blob/main/js/json/MIGRATE.md), [`@moq/loc`](https://github.com/moq-dev/moq/blob/main/js/loc/MIGRATE.md), [`@moq/msf`](https://github.com/moq-dev/moq/blob/main/js/msf/MIGRATE.md), [`@moq/net`](https://github.com/moq-dev/moq/blob/main/js/net/MIGRATE.md), [`@moq/p2p`](https://github.com/moq-dev/moq/blob/main/js/p2p/MIGRATE.md), [`@moq/pattern`](https://github.com/moq-dev/moq/blob/main/js/pattern/MIGRATE.md), [`@moq/publish`](https://github.com/moq-dev/moq/blob/main/js/publish/MIGRATE.md), [`@moq/qmux`](https://github.com/moq-dev/moq/blob/main/js/qmux/MIGRATE.md), [`@moq/room`](https://github.com/moq-dev/moq/blob/main/js/room/MIGRATE.md), [`@moq/signals`](https://github.com/moq-dev/moq/blob/main/js/signals/MIGRATE.md), [`@moq/ui`](https://github.com/moq-dev/moq/blob/main/js/ui/MIGRATE.md), [`@moq/video`](https://github.com/moq-dev/moq/blob/main/js/video/MIGRATE.md), [`@moq/watch`](https://github.com/moq-dev/moq/blob/main/js/watch/MIGRATE.md)
## Unreleased
diff --git a/js/e2ee/README.md b/js/crypto/README.md
similarity index 59%
rename from js/e2ee/README.md
rename to js/crypto/README.md
index a66dcd143c6..c13915d51fb 100644
--- a/js/e2ee/README.md
+++ b/js/crypto/README.md
@@ -2,16 +2,72 @@
-# @moq/e2ee
+# @moq/crypto
+
+Content signing and end-to-end encryption for [Media over QUIC](https://moq.dev), mirroring the
+Rust `moq-crypto` crate. `Sign` signs every frame so relays cannot forge it, and `E2ee` encrypts
+groups, datagrams, and track names so relays cannot read them. Both wrap `@moq/net` and refuse a
+timestamp its track would refuse before signing or encrypting.
+
+## Signing
+
+Per-frame Ed25519 signatures for [Media over QUIC](https://moq.dev) broadcasts. Profile
+`moq-sign-00` from [draft-lcurley-moq-sign](https://datatracker.ietf.org/doc/draft-lcurley-moq-sign/),
+interoperable with Rust's `moq_crypto::sign`.
+
+Relays forward and cache signed frames; they cannot forge, retime, or relocate them. Signatures
+authenticate content, not liveness: a relay that recorded an instance can replay it whole.
+
+### Shape
+
+An endpoint's `SecretKey` signs; its `PublicKey` is the endpoint ID, displayed as 52 z-base-32
+characters (a DNS label). `SecretKey.generate()` keeps the private half a nonextractable `CryptoKey`.
+
+`Broadcast.Producer` wraps the `@moq/net` broadcast, mints a fresh instance, and signs each frame
+over the application path, instance, track, group, frame index, and timestamp (rounded to the
+track's timescale, as the wire carries it). Announce the broadcast with that instance on its route:
+
+```ts
+import { Sign } from "@moq/crypto";
+import { Path } from "@moq/net";
+
+const { Broadcast, SecretKey } = Sign;
+
+const key = await SecretKey.generate();
+const path = Path.from(`mesh/${key.public}/agent`);
+const publication = origin.createBroadcast(path);
+const signed = new Broadcast.Producer(publication.broadcast, key, path);
+const messages = signed.createTrack("messages");
+publication.announce({ instance: signed.instance });
+
+const group = messages.appendGroup();
+await group.writeFrame(undefined, payload);
+group.finish();
+```
+
+A subscriber wraps the broadcast an origin resolved in a `Broadcast.Consumer` with the key it
+expects and the same application path; it takes the instance from the route. A frame reaches the
+application only after it verifies. A forged or relocated frame ends its group with `Failure`
+code `signature`, and the track keeps delivering other groups. Every hop must carry the instance and
+timestamps unchanged, which means moq-lite-07. A group's end is not signed: a relay may drop a
+group's tail, as MoQ already allows.
+
+### Processing
+
+WebCrypto Ed25519 is asynchronous, so writes return promises. Each track producer runs one serial
+pump: one signature in flight, net writes in call order, so a frame's index always matches its
+transport position. Await each write for backpressure.
+
+## Encryption
End-to-end encryption for [Media over QUIC](https://moq.dev) groups, datagrams,
and track names. Profile `moq-e2ee-00` from
[draft-lcurley-moq-e2ee](https://datatracker.ietf.org/doc/draft-lcurley-moq-e2ee/),
-interoperable with the Rust [`moq-e2ee`](https://crates.io/crates/moq-e2ee) crate.
+interoperable with Rust's `moq_crypto::e2ee`.
Relays forward ciphertext. Content keys never enter `@moq/net`.
-## Shape
+### Shape
The application distributes a `Credential { context, kid, secret }` over its own
authenticated channel. `credential.produce()` mints a fresh epoch and returns a
@@ -27,9 +83,11 @@ learns only its length rounded up to 16 bytes. `createTrack` resolves once the n
every write is checked against it. `close()` ends the wrapped broadcast.
```ts
-import { Broadcast, Credential } from "@moq/e2ee";
+import { E2ee } from "@moq/crypto";
import { Time } from "@moq/net";
+const { Broadcast, Credential } = E2ee;
+
const credential = new Credential({ context, kid, secret });
const generation = credential.produce();
const publication = origin.createBroadcast(await credential.path("meeting.hang"));
@@ -57,7 +115,7 @@ A cloned process image (a `fork` without `exec`, a restored VM snapshot or check
producing generation copied to another process) is a new instance too: each copy must call
`produce()` itself, since copies of one generation reuse its nonces.
-## Processing
+### Processing
WebCrypto AES-GCM is asynchronous, so writes return promises. Each track producer and
consumer runs one serial pump: one AEAD call in flight. Producer net writes land in call
diff --git a/js/e2ee/bench/pump.ts b/js/crypto/bench/pump.ts
similarity index 97%
rename from js/e2ee/bench/pump.ts
rename to js/crypto/bench/pump.ts
index 02d5974af98..63f65ebef74 100644
--- a/js/e2ee/bench/pump.ts
+++ b/js/crypto/bench/pump.ts
@@ -2,7 +2,7 @@
// Bun's WebCrypto stands in for the browser's, so compare runs on the same runtime.
import { Milli } from "@moq/clock";
import { Broadcast, Time } from "@moq/net";
-import { Credential } from "../src/index.ts";
+import { Credential } from "../src/e2ee/index.ts";
const GROUP_FRAMES = 64;
const BUDGET = 32 * 1024 * 1024;
diff --git a/js/e2ee/bench/tsconfig.json b/js/crypto/bench/tsconfig.json
similarity index 100%
rename from js/e2ee/bench/tsconfig.json
rename to js/crypto/bench/tsconfig.json
diff --git a/js/e2ee/package.json b/js/crypto/package.json
similarity index 83%
rename from js/e2ee/package.json
rename to js/crypto/package.json
index e01a4ca6f46..7b226921fca 100644
--- a/js/e2ee/package.json
+++ b/js/crypto/package.json
@@ -1,13 +1,13 @@
{
- "name": "@moq/e2ee",
+ "name": "@moq/crypto",
"type": "module",
"version": "0.0.0",
- "description": "End-to-end encryption for MoQ groups, datagrams, and track names.",
+ "description": "Content signing and end-to-end encryption for MoQ broadcasts.",
"license": "(MIT OR Apache-2.0)",
"repository": {
"type": "git",
"url": "git+https://github.com/moq-dev/moq.git",
- "directory": "js/e2ee"
+ "directory": "js/crypto"
},
"private": true,
"sideEffects": false,
diff --git a/js/e2ee/src/broadcast.ts b/js/crypto/src/e2ee/broadcast.ts
similarity index 100%
rename from js/e2ee/src/broadcast.ts
rename to js/crypto/src/e2ee/broadcast.ts
diff --git a/js/e2ee/src/credential.ts b/js/crypto/src/e2ee/credential.ts
similarity index 100%
rename from js/e2ee/src/credential.ts
rename to js/crypto/src/e2ee/credential.ts
diff --git a/js/e2ee/src/datagram.ts b/js/crypto/src/e2ee/datagram.ts
similarity index 100%
rename from js/e2ee/src/datagram.ts
rename to js/crypto/src/e2ee/datagram.ts
diff --git a/js/e2ee/src/derive.ts b/js/crypto/src/e2ee/derive.ts
similarity index 100%
rename from js/e2ee/src/derive.ts
rename to js/crypto/src/e2ee/derive.ts
diff --git a/js/e2ee/src/e2ee.test.ts b/js/crypto/src/e2ee/e2ee.test.ts
similarity index 99%
rename from js/e2ee/src/e2ee.test.ts
rename to js/crypto/src/e2ee/e2ee.test.ts
index 5235431636a..5675c75c114 100644
--- a/js/e2ee/src/e2ee.test.ts
+++ b/js/crypto/src/e2ee/e2ee.test.ts
@@ -1,6 +1,7 @@
import { expect, spyOn, test } from "bun:test";
import { Milli } from "@moq/clock";
import { Broadcast, Error as NetError, Group as NetGroup, Track as NetTrack, StreamCode, Time } from "@moq/net";
+import { Pump } from "../pump.ts";
import * as Protected from "./broadcast.ts";
import { Credential } from "./credential.ts";
import type * as Datagram from "./datagram.ts";
@@ -20,7 +21,6 @@ import {
MAX_PLAINTEXT_BYTES,
MAX_U53,
} from "./limits.ts";
-import { Pump } from "./pump.ts";
import { Terminal } from "./terminal.ts";
import type * as Track from "./track.ts";
diff --git a/js/e2ee/src/epoch.test.ts b/js/crypto/src/e2ee/epoch.test.ts
similarity index 78%
rename from js/e2ee/src/epoch.test.ts
rename to js/crypto/src/e2ee/epoch.test.ts
index af1119e64d8..f70c75df017 100644
--- a/js/e2ee/src/epoch.test.ts
+++ b/js/crypto/src/e2ee/epoch.test.ts
@@ -7,8 +7,8 @@ test("mint parses as canonical and orders successive epochs", () => {
expect(Epoch.mint() > epoch).toBe(true);
});
-// Shared with rs/moq-e2ee's `epoch_vectors`, so both parse and order alike.
-const vectors = (await Bun.file(new URL("../../../rs/moq-e2ee/src/epoch.json", import.meta.url)).json()) as {
+// Shared with moq-crypto's `epoch_vectors`, so both parse and order alike.
+const vectors = (await Bun.file(new URL("../../../../rs/moq-crypto/src/e2ee/epoch.json", import.meta.url)).json()) as {
valid: string[];
invalid: string[];
ordered: string[];
diff --git a/js/e2ee/src/epoch.ts b/js/crypto/src/e2ee/epoch.ts
similarity index 95%
rename from js/e2ee/src/epoch.ts
rename to js/crypto/src/e2ee/epoch.ts
index 642cfadaa2e..cffee22f9dd 100644
--- a/js/e2ee/src/epoch.ts
+++ b/js/crypto/src/e2ee/epoch.ts
@@ -3,7 +3,7 @@
* instance announces it as its route's instance, so a subscriber reads it back from the
* broadcast it resolved ({@link of}). A wire that carries no instance hands the subscriber one
* its relay minted, which is no epoch: the application supplies the epoch over its own
- * authenticated channel then. Mirrors `Epoch` in rs/moq-e2ee.
+ * authenticated channel then. Mirrors `moq_crypto::e2ee::Epoch`.
*
* @module
*/
diff --git a/js/e2ee/src/failure.ts b/js/crypto/src/e2ee/failure.ts
similarity index 100%
rename from js/e2ee/src/failure.ts
rename to js/crypto/src/e2ee/failure.ts
diff --git a/js/e2ee/src/generation-internal.ts b/js/crypto/src/e2ee/generation-internal.ts
similarity index 100%
rename from js/e2ee/src/generation-internal.ts
rename to js/crypto/src/e2ee/generation-internal.ts
diff --git a/js/e2ee/src/generation.ts b/js/crypto/src/e2ee/generation.ts
similarity index 100%
rename from js/e2ee/src/generation.ts
rename to js/crypto/src/e2ee/generation.ts
diff --git a/js/e2ee/src/group.ts b/js/crypto/src/e2ee/group.ts
similarity index 96%
rename from js/e2ee/src/group.ts
rename to js/crypto/src/e2ee/group.ts
index d48ef73feca..9317458bd85 100644
--- a/js/e2ee/src/group.ts
+++ b/js/crypto/src/e2ee/group.ts
@@ -4,8 +4,9 @@
* @module
*/
import type { Group as NetGroup, Time } from "@moq/net";
+import { onTrack } from "../timestamp.ts";
import { Failure } from "./failure.ts";
-import { checkTimestamp, type Reader, type Writer } from "./internal.ts";
+import type { Reader, Writer } from "./internal.ts";
import { MAX_GROUPED_PAYLOAD, TAG_LEN } from "./limits.ts";
/** A decrypted grouped frame. */
@@ -61,9 +62,9 @@ export class Producer {
if (this.#closed || this.#writer.closed)
throw this.#aborted ?? this.#writer.aborted ?? new Error("group is closed");
if (plaintext.byteLength + TAG_LEN > MAX_GROUPED_PAYLOAD) throw new Failure("oversize");
- checkTimestamp(this.#writer, timestamp);
+ const at = onTrack(timestamp, this.#writer.timescale);
const owned = plaintext.slice();
- return this.#writer.pump.run(() => this.#write(timestamp, owned));
+ return this.#writer.pump.run(() => this.#write(at, owned));
}
async #write(timestamp: Time.Timestamp | undefined, plaintext: Uint8Array): Promise {
diff --git a/js/e2ee/src/index.ts b/js/crypto/src/e2ee/index.ts
similarity index 98%
rename from js/e2ee/src/index.ts
rename to js/crypto/src/e2ee/index.ts
index de4c4b29293..d58d299accc 100644
--- a/js/e2ee/src/index.ts
+++ b/js/crypto/src/e2ee/index.ts
@@ -3,7 +3,7 @@
*
* Implements profile `moq-e2ee-00` from
* [draft-lcurley-moq-e2ee](https://datatracker.ietf.org/doc/draft-lcurley-moq-e2ee/). Relays
- * forward ciphertext; content keys never enter `@moq/net`. Mirrors the Rust `moq-e2ee` crate.
+ * forward ciphertext; content keys never enter `@moq/net`. Mirrors `moq_crypto::e2ee` in Rust.
*
* A {@link Credential} is what the application distributes out of band. Each publisher instance
* calls {@link Credential.produce} to mint a {@link Generation.Producer} and wraps its `@moq/net`
diff --git a/js/e2ee/src/internal.ts b/js/crypto/src/e2ee/internal.ts
similarity index 57%
rename from js/e2ee/src/internal.ts
rename to js/crypto/src/e2ee/internal.ts
index 732940b2e60..c75bb473fc5 100644
--- a/js/e2ee/src/internal.ts
+++ b/js/crypto/src/e2ee/internal.ts
@@ -1,7 +1,7 @@
// Package-private state the public modules share without exporting it.
-import { Error as NetError, type Time } from "@moq/net";
+import type { Time } from "@moq/net";
+import type { Pump } from "../pump.ts";
import type { TrackKey } from "./key.ts";
-import type { Pump } from "./pump.ts";
import type { Terminal } from "./terminal.ts";
/** A track's grouped-frame and datagram keys. */
@@ -28,12 +28,3 @@ export interface Reader {
key: TrackKey;
terminal: Terminal;
}
-
-/** Refuse a timestamp the track could not encode: wrong presence, or out of range at its timescale. */
-export function checkTimestamp(writer: Writer, timestamp: Time.Timestamp | undefined): void {
- if ((writer.timescale !== undefined) !== (timestamp !== undefined)) {
- throw new NetError.TimestampMismatch();
- }
- // Throws a RangeError for a conversion that would only fail at encode, after the identity is spent.
- if (timestamp && writer.timescale !== undefined) timestamp.as(writer.timescale);
-}
diff --git a/js/e2ee/src/key.ts b/js/crypto/src/e2ee/key.ts
similarity index 100%
rename from js/e2ee/src/key.ts
rename to js/crypto/src/e2ee/key.ts
diff --git a/js/e2ee/src/limits.ts b/js/crypto/src/e2ee/limits.ts
similarity index 100%
rename from js/e2ee/src/limits.ts
rename to js/crypto/src/e2ee/limits.ts
diff --git a/js/e2ee/src/name.ts b/js/crypto/src/e2ee/name.ts
similarity index 100%
rename from js/e2ee/src/name.ts
rename to js/crypto/src/e2ee/name.ts
diff --git a/js/e2ee/src/secret.ts b/js/crypto/src/e2ee/secret.ts
similarity index 100%
rename from js/e2ee/src/secret.ts
rename to js/crypto/src/e2ee/secret.ts
diff --git a/js/e2ee/src/terminal.ts b/js/crypto/src/e2ee/terminal.ts
similarity index 100%
rename from js/e2ee/src/terminal.ts
rename to js/crypto/src/e2ee/terminal.ts
diff --git a/js/e2ee/src/track.ts b/js/crypto/src/e2ee/track.ts
similarity index 97%
rename from js/e2ee/src/track.ts
rename to js/crypto/src/e2ee/track.ts
index b5472ce2c3b..6c61984557c 100644
--- a/js/e2ee/src/track.ts
+++ b/js/crypto/src/e2ee/track.ts
@@ -4,14 +4,15 @@
* @module
*/
import type { Group as NetGroup, Track as NetTrack, Time } from "@moq/net";
+import { Pump } from "../pump.ts";
+import { onTrack } from "../timestamp.ts";
import type { Event } from "./datagram.ts";
import { checkU53 } from "./derive.ts";
import { Failure } from "./failure.ts";
import * as Group from "./group.ts";
-import { checkTimestamp, type Keys, type Reader, type Writer } from "./internal.ts";
+import type { Keys, Reader, Writer } from "./internal.ts";
import type { TrackKey } from "./key.ts";
import { MAX_DATAGRAM_PAYLOAD } from "./limits.ts";
-import { Pump } from "./pump.ts";
import { Terminal } from "./terminal.ts";
import { DatagramWindow } from "./window.ts";
@@ -90,7 +91,7 @@ export class Producer {
): Promise {
this.#writable();
this.#reserve(sequence);
- checkTimestamp(this.#writer, timestamp);
+ const at = onTrack(timestamp, this.#writer.timescale);
const iv = this.#datagramKey.admitSeal(sequence, 0, plaintext.byteLength, MAX_DATAGRAM_PAYLOAD);
this.#next = sequence + 1;
const owned = plaintext.slice();
@@ -98,7 +99,7 @@ export class Producer {
if (this.#writer.aborted) throw this.#writer.aborted;
const payload = await this.#datagramKey.encrypt(iv, owned);
if (this.#writer.aborted) throw this.#writer.aborted;
- this.#inner.insertDatagram(sequence, timestamp, payload);
+ this.#inner.insertDatagram(sequence, at, payload);
});
}
diff --git a/js/e2ee/src/transport.test.ts b/js/crypto/src/e2ee/transport.test.ts
similarity index 98%
rename from js/e2ee/src/transport.test.ts
rename to js/crypto/src/e2ee/transport.test.ts
index 99569ecaf04..28140017ca9 100644
--- a/js/e2ee/src/transport.test.ts
+++ b/js/crypto/src/e2ee/transport.test.ts
@@ -3,7 +3,7 @@ import { expect, test } from "bun:test";
import { Milli } from "@moq/clock";
import { type Broadcast, Connection, Origin, type Path, Time } from "@moq/net";
// The in-memory WebTransport pair @moq/net tests with; not part of its published surface.
-import { createMockTransportPair } from "../../net/src/mock.ts";
+import { createMockTransportPair } from "../../../net/src/mock.ts";
import * as Protected from "./broadcast.ts";
import { Credential } from "./credential.ts";
import * as Epoch from "./epoch.ts";
diff --git a/js/e2ee/src/vectors.test.ts b/js/crypto/src/e2ee/vectors.test.ts
similarity index 98%
rename from js/e2ee/src/vectors.test.ts
rename to js/crypto/src/e2ee/vectors.test.ts
index 5dafbf052de..7c314c06883 100644
--- a/js/e2ee/src/vectors.test.ts
+++ b/js/crypto/src/e2ee/vectors.test.ts
@@ -11,7 +11,7 @@ import { expand } from "./secret.ts";
type Row = Record;
-const vectors = (await Bun.file(new URL("../../../drafts/moq-e2ee-00.json", import.meta.url)).json()) as {
+const vectors = (await Bun.file(new URL("../../../../drafts/moq-e2ee-00.json", import.meta.url)).json()) as {
profile: string;
constants: Row;
generation: Row;
diff --git a/js/e2ee/src/window.ts b/js/crypto/src/e2ee/window.ts
similarity index 100%
rename from js/e2ee/src/window.ts
rename to js/crypto/src/e2ee/window.ts
diff --git a/js/crypto/src/index.ts b/js/crypto/src/index.ts
new file mode 100644
index 00000000000..fd455ace1b8
--- /dev/null
+++ b/js/crypto/src/index.ts
@@ -0,0 +1,14 @@
+/**
+ * Content signing and end-to-end encryption for MoQ.
+ *
+ * {@link Sign} signs every grouped frame so a relay can proxy and cache a broadcast without
+ * forging it. {@link E2ee} encrypts groups, datagrams, and track names so a relay forwards
+ * ciphertext it cannot read. Mirrors the Rust `moq-crypto` crate's `sign` and `e2ee` modules.
+ *
+ * @module
+ */
+
+/** End-to-end encryption of groups, datagrams, and track names. */
+export * as E2ee from "./e2ee/index.ts";
+/** Per-frame Ed25519 signatures. */
+export * as Sign from "./sign/index.ts";
diff --git a/js/e2ee/src/pump.ts b/js/crypto/src/pump.ts
similarity index 100%
rename from js/e2ee/src/pump.ts
rename to js/crypto/src/pump.ts
diff --git a/js/sign/src/broadcast.ts b/js/crypto/src/sign/broadcast.ts
similarity index 100%
rename from js/sign/src/broadcast.ts
rename to js/crypto/src/sign/broadcast.ts
diff --git a/js/sign/src/failure.ts b/js/crypto/src/sign/failure.ts
similarity index 100%
rename from js/sign/src/failure.ts
rename to js/crypto/src/sign/failure.ts
diff --git a/js/sign/src/group.ts b/js/crypto/src/sign/group.ts
similarity index 91%
rename from js/sign/src/group.ts
rename to js/crypto/src/sign/group.ts
index a1263e2222b..014a0a86e08 100644
--- a/js/sign/src/group.ts
+++ b/js/crypto/src/sign/group.ts
@@ -3,10 +3,11 @@
*
* @module
*/
-import { type Group as NetGroup, Time } from "@moq/net";
+import type { Group as NetGroup, Time } from "@moq/net";
+import type { Pump } from "../pump.ts";
+import { onTrack } from "../timestamp.ts";
import { Failure } from "./failure.ts";
import type { PublicKey, SecretKey } from "./key.ts";
-import type { Pump } from "./pump.ts";
import type { Scope } from "./scope.ts";
/** A grouped frame whose signature verified. */
@@ -70,12 +71,8 @@ export class Producer {
async writeFrame(timestamp: Time.Timestamp | undefined, payload: Uint8Array): Promise {
if (this.#closed || this.#writer.closed) throw this.#writer.aborted ?? new Error("group is closed");
const owned = payload.slice();
- // Signed at the track's timescale, rounded as the wire rounds it, and written that way so a
- // local reader sees the signed value too. A frame whose timedness disagrees with the track
- // is left for the net write to refuse.
- const scale = this.#writer.timescale;
- const at =
- timestamp && scale !== undefined ? new Time.Timestamp(Math.round(timestamp.as(scale)), scale) : timestamp;
+ // Signed at the track's timescale, and written that way so a local reader sees the signed value too.
+ const at = onTrack(timestamp, this.#writer.timescale);
return this.#writer.pump.run(async () => {
this.#check();
const body = await this.#writer.scope.sign(this.#writer.key, this.sequence, this.#next, at, owned);
diff --git a/js/sign/src/index.ts b/js/crypto/src/sign/index.ts
similarity index 97%
rename from js/sign/src/index.ts
rename to js/crypto/src/sign/index.ts
index af0700c6bea..b840f107158 100644
--- a/js/sign/src/index.ts
+++ b/js/crypto/src/sign/index.ts
@@ -8,7 +8,7 @@
* frame to the application only after it verifies against the {@link PublicKey} it expects, so a
* relay can proxy and cache without forging, retiming, relocating, or splicing content. Signatures
* authenticate content, not liveness: a relay that recorded an instance can replay it whole under
- * its instance. Mirrors the Rust `moq-sign` crate.
+ * its instance. Mirrors `moq_crypto::sign` in Rust.
*
* ```ts
* const key = await SecretKey.generate();
diff --git a/js/sign/src/key.ts b/js/crypto/src/sign/key.ts
similarity index 100%
rename from js/sign/src/key.ts
rename to js/crypto/src/sign/key.ts
diff --git a/js/sign/src/scope.ts b/js/crypto/src/sign/scope.ts
similarity index 100%
rename from js/sign/src/scope.ts
rename to js/crypto/src/sign/scope.ts
diff --git a/js/sign/src/sign.test.ts b/js/crypto/src/sign/sign.test.ts
similarity index 95%
rename from js/sign/src/sign.test.ts
rename to js/crypto/src/sign/sign.test.ts
index bc5ecae0522..594a5282526 100644
--- a/js/sign/src/sign.test.ts
+++ b/js/crypto/src/sign/sign.test.ts
@@ -1,9 +1,9 @@
// Signed tracks over a real moq-lite session: the subscriber delivers only what verifies.
import { expect, test } from "bun:test";
import { Milli } from "@moq/clock";
-import { type Broadcast, Connection, Origin, Path, Time } from "@moq/net";
+import { type Broadcast, Connection, Error as NetError, Origin, Path, Time } from "@moq/net";
// The in-memory WebTransport pair @moq/net tests with; not part of its published surface.
-import { createMockTransportPair } from "../../net/src/mock.ts";
+import { createMockTransportPair } from "../../../net/src/mock.ts";
import * as Signed from "./broadcast.ts";
import { Failure } from "./failure.ts";
import type * as Group from "./group.ts";
@@ -91,6 +91,10 @@ test("frames roundtrip signed, timestamps included", async () => {
expect(second?.timestamp?.value).toBe(2);
expect(second?.timestamp?.scale).toBe(Time.Timescale.MILLI);
+ // An untimed frame on a timed track is refused before it is signed, so it spends no index.
+ await expect(group.writeFrame(undefined, encoder.encode("untimed"))).rejects.toBeInstanceOf(
+ NetError.TimestampMismatch,
+ );
await group.writeFrame(Time.Timestamp.fromMillis(3), encoder.encode("late"));
group.finish();
expect(await payload(received)).toBe("late");
diff --git a/js/sign/src/track.ts b/js/crypto/src/sign/track.ts
similarity index 99%
rename from js/sign/src/track.ts
rename to js/crypto/src/sign/track.ts
index 359cc80d8b3..e43d670f8a5 100644
--- a/js/sign/src/track.ts
+++ b/js/crypto/src/sign/track.ts
@@ -4,9 +4,9 @@
* @module
*/
import type { Track as NetTrack, Time } from "@moq/net";
+import { Pump } from "../pump.ts";
import * as Group from "./group.ts";
import type { PublicKey, SecretKey } from "./key.ts";
-import { Pump } from "./pump.ts";
import type { Scope } from "./scope.ts";
/** The lowest group sequence an instance has not signed on a track, shared with the track's replacements. @internal */
diff --git a/js/sign/src/vectors.test.ts b/js/crypto/src/sign/vectors.test.ts
similarity index 96%
rename from js/sign/src/vectors.test.ts
rename to js/crypto/src/sign/vectors.test.ts
index 380443140e9..627e1ae1efb 100644
--- a/js/sign/src/vectors.test.ts
+++ b/js/crypto/src/sign/vectors.test.ts
@@ -7,7 +7,7 @@ import { Scope } from "./scope.ts";
type Row = Record;
-const vectors = (await Bun.file(new URL("../../../drafts/moq-sign-00.json", import.meta.url)).json()) as {
+const vectors = (await Bun.file(new URL("../../../../drafts/moq-sign-00.json", import.meta.url)).json()) as {
keys: Row[];
frames: Row[];
negative: Row[];
diff --git a/js/sign/src/zbase32.ts b/js/crypto/src/sign/zbase32.ts
similarity index 100%
rename from js/sign/src/zbase32.ts
rename to js/crypto/src/sign/zbase32.ts
diff --git a/js/crypto/src/timestamp.ts b/js/crypto/src/timestamp.ts
new file mode 100644
index 00000000000..5e0d4907981
--- /dev/null
+++ b/js/crypto/src/timestamp.ts
@@ -0,0 +1,19 @@
+// The timestamp check both halves share, so a frame either accepts is one `@moq/net` accepts.
+import { Error as NetError, Time } from "@moq/net";
+
+/**
+ * `timestamp` at the track's `timescale`, rounded as the wire rounds it. Mirrors Rust's
+ * `moq_net::group::on_track`, checked before a frame is signed or encrypted so a refused
+ * timestamp spends nothing.
+ *
+ * Throws `TimestampMismatch` when the frame's timedness disagrees with the track's, or a
+ * `RangeError` when the converted value leaves the safe range.
+ */
+export function onTrack(
+ timestamp: Time.Timestamp | undefined,
+ timescale: Time.Timescale | undefined,
+): Time.Timestamp | undefined {
+ if ((timescale !== undefined) !== (timestamp !== undefined)) throw new NetError.TimestampMismatch();
+ if (timestamp === undefined || timescale === undefined) return undefined;
+ return new Time.Timestamp(Math.round(timestamp.as(timescale)), timescale);
+}
diff --git a/js/e2ee/test-dts/constructors.ts b/js/crypto/test-dts/constructors.ts
similarity index 55%
rename from js/e2ee/test-dts/constructors.ts
rename to js/crypto/test-dts/constructors.ts
index 6e3d0f5952c..ce6d3acc119 100644
--- a/js/e2ee/test-dts/constructors.ts
+++ b/js/crypto/test-dts/constructors.ts
@@ -1,16 +1,16 @@
-import { Consumer, Producer } from "../dist/generation-internal.js";
-import { Credential, type Generation } from "../dist/index.js";
+import { Consumer, Producer } from "../dist/e2ee/generation-internal.js";
+import { E2ee } from "../dist/index.js";
// @ts-expect-error A credential binds a consuming generation to an epoch.
new Consumer();
// @ts-expect-error A credential mints a producing generation and its epoch.
new Producer();
// @ts-expect-error The internal factory is not a package export, including type-only namespaces.
-export type Factory = typeof Generation.makeProducer;
+export type Factory = typeof E2ee.Generation.makeProducer;
-const credential = new Credential({ context: new Uint8Array(), kid: 1, secret: new Uint8Array(32) });
-const producer: Generation.Producer = credential.produce();
-const consumer: Generation.Consumer = credential.consume(producer.epoch);
+const credential = new E2ee.Credential({ context: new Uint8Array(), kid: 1, secret: new Uint8Array(32) });
+const producer: E2ee.Generation.Producer = credential.produce();
+const consumer: E2ee.Generation.Consumer = credential.consume(producer.epoch);
void consumer.name("test");
// @ts-expect-error Construction stays private even with valid arguments.
new Consumer(credential, producer.epoch);
diff --git a/js/e2ee/test-dts/tsconfig.json b/js/crypto/test-dts/tsconfig.json
similarity index 100%
rename from js/e2ee/test-dts/tsconfig.json
rename to js/crypto/test-dts/tsconfig.json
diff --git a/js/e2ee/tsconfig.build.json b/js/crypto/tsconfig.build.json
similarity index 100%
rename from js/e2ee/tsconfig.build.json
rename to js/crypto/tsconfig.build.json
diff --git a/js/e2ee/tsconfig.json b/js/crypto/tsconfig.json
similarity index 100%
rename from js/e2ee/tsconfig.json
rename to js/crypto/tsconfig.json
diff --git a/js/sign/README.md b/js/sign/README.md
deleted file mode 100644
index 518de64c645..00000000000
--- a/js/sign/README.md
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-# @moq/sign
-
-Per-frame Ed25519 signatures for [Media over QUIC](https://moq.dev) broadcasts. Profile
-`moq-sign-00` from [draft-lcurley-moq-sign](https://datatracker.ietf.org/doc/draft-lcurley-moq-sign/),
-interoperable with the Rust `moq-sign` crate.
-
-Relays forward and cache signed frames; they cannot forge, retime, or relocate them. Signatures
-authenticate content, not liveness: a relay that recorded an instance can replay it whole.
-
-## Shape
-
-An endpoint's `SecretKey` signs; its `PublicKey` is the endpoint ID, displayed as 52 z-base-32
-characters (a DNS label). `SecretKey.generate()` keeps the private half a nonextractable `CryptoKey`.
-
-`Broadcast.Producer` wraps the `@moq/net` broadcast, mints a fresh instance, and signs each frame
-over the application path, instance, track, group, frame index, and timestamp (rounded to the
-track's timescale, as the wire carries it). Announce the broadcast with that instance on its route:
-
-```ts
-import { Broadcast, SecretKey } from "@moq/sign";
-import { Path } from "@moq/net";
-
-const key = await SecretKey.generate();
-const path = Path.from(`mesh/${key.public}/agent`);
-const publication = origin.createBroadcast(path);
-const signed = new Broadcast.Producer(publication.broadcast, key, path);
-const messages = signed.createTrack("messages");
-publication.announce({ instance: signed.instance });
-
-const group = messages.appendGroup();
-await group.writeFrame(undefined, payload);
-group.finish();
-```
-
-A subscriber wraps the broadcast an origin resolved in a `Broadcast.Consumer` with the key it
-expects and the same application path; it takes the instance from the route. A frame reaches the
-application only after it verifies. A forged or relocated frame ends its group with `Failure`
-code `signature`, and the track keeps delivering other groups. Every hop must carry the instance and
-timestamps unchanged, which means moq-lite-07. A group's end is not signed: a relay may drop a
-group's tail, as MoQ already allows.
-
-## Processing
-
-WebCrypto Ed25519 is asynchronous, so writes return promises. Each track producer runs one serial
-pump: one signature in flight, net writes in call order, so a frame's index always matches its
-transport position. Await each write for backpressure.
diff --git a/js/sign/package.json b/js/sign/package.json
deleted file mode 100644
index 4fa00d26eff..00000000000
--- a/js/sign/package.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "name": "@moq/sign",
- "type": "module",
- "version": "0.0.0",
- "description": "Per-frame Ed25519 signatures for MoQ broadcasts, so relays proxy without forging content.",
- "license": "(MIT OR Apache-2.0)",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/moq-dev/moq.git",
- "directory": "js/sign"
- },
- "private": true,
- "sideEffects": false,
- "exports": {
- ".": "./src/index.ts"
- },
- "scripts": {
- "build": "rm -rf dist && tsc -b tsconfig.build.json && bun ../common/package.ts",
- "check": "tsc --noEmit",
- "test": "bun test --only-failures"
- },
- "dependencies": {
- "@moq/net": "workspace:^"
- },
- "devDependencies": {
- "@moq/clock": "workspace:^",
- "@types/bun": "^1.4.4",
- "typescript": "7.0.2"
- }
-}
diff --git a/js/sign/src/pump.ts b/js/sign/src/pump.ts
deleted file mode 100644
index c2689acbcd2..00000000000
--- a/js/sign/src/pump.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * Runs tasks one at a time in submit order: one AEAD call in flight, completions in order.
- *
- * A producer's depth one keeps a frame's ordinal equal to its `@moq/net` write order without
- * reservations; the queue is the callers' own pending promises, so awaiting each write is the
- * backpressure. A consumer runs only opens through it, never net waits.
- */
-export class Pump {
- #tail: Promise = Promise.resolve();
-
- run(task: () => Promise | T): Promise {
- const result = this.#tail.then(task);
- this.#tail = result.catch(() => {});
- return result;
- }
-}
diff --git a/js/sign/tsconfig.build.json b/js/sign/tsconfig.build.json
deleted file mode 100644
index b58733f6162..00000000000
--- a/js/sign/tsconfig.build.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- // Build-only variant of tsconfig.json that keeps tests out of dist/, so they
- // are neither published nor discovered by `bun test` at the package root.
- // `tsc --noEmit` still uses tsconfig.json, so tests stay type-checked.
- "extends": "./tsconfig.json",
- "compilerOptions": {
- "rootDir": "./src"
- },
- "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"]
-}
diff --git a/js/sign/tsconfig.json b/js/sign/tsconfig.json
deleted file mode 100644
index bfbf10ed73c..00000000000
--- a/js/sign/tsconfig.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "extends": "../tsconfig.json",
- "compilerOptions": {
- "outDir": "dist",
- // The transport test borrows `@moq/net`'s mock transport by relative path, so the
- // type-check spans the workspace. The build pins `rootDir` to src and skips tests.
- "rootDir": "..",
- "types": ["bun"]
- },
- "include": ["src"]
-}
diff --git a/package.json b/package.json
index db5e5f3fdef..f6f034cebea 100644
--- a/package.json
+++ b/package.json
@@ -43,8 +43,7 @@
"js/clock",
"js/pattern",
"js/auth",
- "js/e2ee",
- "js/sign",
+ "js/crypto",
"js/json",
"js/libav",
"js/hang",
diff --git a/quest/m1/README.md b/quest/m1/README.md
index 3891b7870c4..3eb6a949000 100644
--- a/quest/m1/README.md
+++ b/quest/m1/README.md
@@ -162,7 +162,6 @@ per-frame CPU growth since #5926.
- [Sockets](/quest/m1/socket/README.md) - a generic dial/accept `Socket` in moq-net, Rust, JS, and Python, with tracks as streams; moq-boy and CARLA move onto it
- [Moxygen pin bump](/quest/m1/moxygen-pin-bump.md) - waiting on moxygen#264, then the TRACK_STATUS patch is dropped
- [A smaller, safer API than release](/quest/m1/api-audit/README.md) - every surface added since release has a consumer or is gone, overlapping operations are collapsed, names mirror across Rust, JS, and the bindings, and every break says how to migrate
-- [moq-crypto replaces moq-sign and moq-e2ee](/quest/m1/moq-crypto.md) - one Rust crate and one JS package hold signing and end-to-end encryption, sharing moq-net's timestamp check
- [moq-transport 18, 20, and 22 only](/quest/m1/ietf-drop/README.md) - drafts 14-17, 19, and 21 are deleted from Rust, JS, tests, interop lanes, and docs, removing the legacy control-stream adapter and its request limit
- [A lapsed request token resets with EXPIRED_AUTH_TOKEN](/quest/m1/auth-expiry-reset.md) - group streams of a lapsed grant reset with the expiry code, so a client knows to renew
- [moq-quic's API improves on quinn's](/quest/m1/quic-api/README.md) - moq-quic and both QUIC drivers ship one mirrored API: `send::`/`recv::` namespaces, one error per direction, consuming terminal operations, plain configs, no quinn baggage
diff --git a/quest/m1/moq-crypto.md b/quest/m1/moq-crypto.md
deleted file mode 100644
index a36fc566047..00000000000
--- a/quest/m1/moq-crypto.md
+++ /dev/null
@@ -1,38 +0,0 @@
-# [M] moq-crypto replaces moq-sign and moq-e2ee
-
-## Goal
-
-One crate, `moq-crypto`, and one JS package, `@moq/crypto`, hold MoQ's
-content signing and end-to-end encryption, replacing `moq-sign`/`@moq/sign`
-and `moq-e2ee`/`@moq/e2ee` before `main` is next cut into `release`. Both
-halves share one timestamp check with moq-net, so they cannot drift from it.
-
-## Plan
-
-Planned 2026-11-02 (maintainer, follow-up planning after the 2026-11-02 /quest-complete run). The follow-up started from
-[moq-dev/moq#7614](https://github.com/moq-dev/moq/pull/7614), which made
-`moq_net::group::on_track` public; the maintainer asked to combine the two
-packages instead of only deduplicating the check.
-
-Decisions:
-
-- ✅ Name it `moq-crypto` (Rust) and `@moq/crypto` (JS). Not chosen:
- `moq-secure`; keeping `moq-e2ee` and absorbing signing into it.
-- ✅ Merge JS too, for parity. `@moq/sign` and `@moq/e2ee` are private and
- unpublished, so the rename costs nothing outside the repository. Not chosen:
- Rust only.
-- ✅ Plain `sign` and `e2ee` modules, always built. Not chosen: Cargo features
- per half.
-- ✅ `moq-e2ee` 0.0.19 is already on crates.io: at the cut, publish a final
- `moq-e2ee` whose README points at `moq-crypto`. No yank. Not chosen:
- leaving it as is; yanking it. Version levels stay with the maintainer.
-- Both halves call `moq_net::group::on_track` instead of their own copies
- (for example `rs/moq-sign/src/group.rs:48`).
-
-Keep the crate independent of hang and codec-specific publisher policy, as the
-[E2EE epic](/quest/m2/e2ee/README.md) requires. Update every crate, package,
-doc, binding, and quest that names the old packages, including the m2 E2EE
-quests.
-
-Public API: the crate and package names and their import paths change.
-Wire: none.
diff --git a/quest/m1/poll-first/async-feature.md b/quest/m1/poll-first/async-feature.md
index 8d7b31b3c20..fd71c7603ad 100644
--- a/quest/m1/poll-first/async-feature.md
+++ b/quest/m1/poll-first/async-feature.md
@@ -51,7 +51,7 @@ What remains:
converted by hand, since the macro stays straight-line only (decided
2026-10-28).
- **Sibling libraries:** the poll-based libraries with hand-written wrappers
- (moq-mux, moq-hls, moq-auth, moq-stats, moq-room, moq-json, moq-sign, moq-e2ee,
+ (moq-mux, moq-hls, moq-auth, moq-stats, moq-room, moq-json, moq-crypto,
qmux, and others) gain an `async` feature, generate their wrappers, and join
`just rs coroutines`.
- **Default off:** moq-net's `async` feature is still on by default. Turn it off,
diff --git a/quest/m1/time-addressing/e2ee.md b/quest/m1/time-addressing/e2ee.md
index d8a6040c30c..9a2337a2259 100644
--- a/quest/m1/time-addressing/e2ee.md
+++ b/quest/m1/time-addressing/e2ee.md
@@ -8,8 +8,8 @@ the cut.
## Plan
-Update `drafts/draft-lcurley-moq-e2ee.md`, `rs/moq-e2ee`, and the JS side,
-which has landed: `js/e2ee/src/derive.ts` builds `nonce(group, frame)` (about
+Update `drafts/draft-lcurley-moq-e2ee.md`, `rs/moq-crypto`, and the JS side,
+which has landed: `js/crypto/src/e2ee/derive.ts` builds `nonce(group, frame)` (about
line 156). The start is unique per track because starts strictly increase.
Run `just drafts check`.
diff --git a/quest/m2/audit-perf.md b/quest/m2/audit-perf.md
index 54c1da9da72..c64f5c99a12 100644
--- a/quest/m2/audit-perf.md
+++ b/quest/m2/audit-perf.md
@@ -117,7 +117,7 @@ did not move.
(`moq-mux/src/container/ts/schedule.rs`) scan and sort every queued unit
per PCR slot.
- e2ee expands the AES-GCM key on every frame (`aead` in
- `moq-e2ee/src/protect.rs`), about a quarter of `protect`; release does too.
+ `moq-crypto/src/e2ee/protect.rs`), about a quarter of `protect`; release does too.
### Method: attribute with instruction counts, not wall time
diff --git a/quest/m2/e2ee/README.md b/quest/m2/e2ee/README.md
index 08ff5de6f01..52e6f009f46 100644
--- a/quest/m2/e2ee/README.md
+++ b/quest/m2/e2ee/README.md
@@ -19,7 +19,7 @@ The contract is [draft-lcurley-moq-e2ee](/drafts/draft-lcurley-moq-e2ee.md), pro
### Epoch and identity
-- Every publisher instance mints an epoch, a UUIDv7 in lowercase text, and publishes at `` with the epoch on its route, where `` derives from the credential and the semantic broadcast name without the epoch. The epoch is an input to every HKDF derivation, so a restart, takeover, or explicit group sequence cannot repeat a nonce under a key: nothing is persisted across instances and no generation counter is redistributed. The epoch is moq-e2ee's own `Epoch`, announced as the route's [instance](/doc/concept/moq-lite.md#publisher-instances). Subscribers resolve `` and take the epoch from its route's instance; on a wire that carries no instance the session mints one, so the application supplies the epoch.
+- Every publisher instance mints an epoch, a UUIDv7 in lowercase text, and publishes at `` with the epoch on its route, where `` derives from the credential and the semantic broadcast name without the epoch. The epoch is an input to every HKDF derivation, so a restart, takeover, or explicit group sequence cannot repeat a nonce under a key: nothing is persisted across instances and no generation counter is redistributed. The epoch is `moq_crypto::e2ee::Epoch`, announced as the route's [instance](/doc/concept/moq-lite.md#publisher-instances). Subscribers resolve `` and take the epoch from its route's instance; on a wire that carries no instance the session mints one, so the application supplies the epoch.
- An encrypting publisher refuses a shared or explicit epoch (maintainer, 2026-10-08). Two producers handed one epoch would derive the same keys and repeat every nonce. Both cores produce only under an epoch they minted themselves; consuming still binds a discovered one. Rejected: a per-instance salt. State the rule in the draft's epoch section.
- The epoch is untrusted and unauthenticated. A wrong epoch fails authentication and a withheld one denies service; neither can make a nonce repeat, because only the publisher instance chooses what it encrypts under. This is the same trust a cache needs to serve the right instance. First-party plaintext publishers already mint the same route epoch.
- Nothing in the path says the bytes are encrypted. The format after decryption (`meeting.hang`) is inside the opaque name; a plaintext player, exporter, or matcher that opens a protected broadcast finds no catalog it can read and fails with its usual typed refusal, the same as for any format it does not support.
@@ -57,14 +57,14 @@ Rejected:
The broadcast wrappers merged in [#5876](https://github.com/moq-dev/moq/pull/5876) with `reserve_track`, which still serves declared names; [rust-publish](/quest/m2/e2ee/rust-publish.md) needs nothing more (maintainer, 2026-10-19).
-Before `@moq/e2ee` is first published, add its entrypoints to the API
+Before `@moq/crypto` is first published, add its entrypoints to the API
Extractor declaration checks, which analyze only published packages since
[moq-dev/moq#6794](https://github.com/moq-dev/moq/pull/6794).
## Required
- [JS undeclared track names](/quest/m2/e2ee/js-undeclared-names.md) -
- `@moq/net` exposes a broadcast request handler and `@moq/e2ee` serves
+ `@moq/net` exposes a broadcast request handler and `@moq/crypto` serves
undeclared names through it
- [Rust protected publisher seams](/quest/m2/e2ee/rust-publish.md) - Rust
publishers emit encrypted catalogs and no plaintext semantic catalog in
diff --git a/quest/m2/e2ee/cli.md b/quest/m2/e2ee/cli.md
index d7b0866f1a9..6a1c8050512 100644
--- a/quest/m2/e2ee/cli.md
+++ b/quest/m2/e2ee/cli.md
@@ -8,7 +8,7 @@ Existing plaintext commands remain the default; an explicit application credenti
## Plan
-Make `moq-e2ee` publishable with this CLI consumer; the crate currently sets
+Make `moq-crypto` publishable with this CLI consumer; the crate currently sets
`publish = false` while it is workspace-only.
- Hand the [trait-generic CLI paths](/quest/m2/net-wrap/cli.md) an encrypted broadcast for publication and playback. Keep codec, capture, playback, and synchronization logic outside the crypto layer.
diff --git a/quest/m2/e2ee/consumer.md b/quest/m2/e2ee/consumer.md
index 1e86ea2ae92..11a2164bee0 100644
--- a/quest/m2/e2ee/consumer.md
+++ b/quest/m2/e2ee/consumer.md
@@ -9,7 +9,7 @@ reinvent decryption and physical-name mapping.
## Plan
Decided 2026-10-20 (maintainer): the shape is the moq-net consumer traits.
-`moq_e2ee::broadcast::Consumer` and its track and group consumers implement
+`moq_crypto::e2ee::broadcast::Consumer` and its track and group consumers implement
them ([net-wrap](/quest/m2/net-wrap/README.md)), so a Rust player, the CLI,
and `@moq/watch` open an encrypted broadcast as they open any other,
because every reader already takes the traits. Kept in m2 (decided
@@ -29,7 +29,7 @@ What remains here:
- Rust and JS only (decided 2026-10-20, maintainer): the e2ee publisher has
no moq-ffi half either, so an FFI consumer waits for a quest that adds both.
-Public API: an e2ee consumer entry point in `moq-e2ee` and `@moq/e2ee`.
+Public API: an e2ee consumer entry point in `moq-crypto` and `@moq/crypto`.
Wire: none.
## Required
diff --git a/quest/m2/e2ee/js-undeclared-names.md b/quest/m2/e2ee/js-undeclared-names.md
index 0218c6f0413..8dcb8c66946 100644
--- a/quest/m2/e2ee/js-undeclared-names.md
+++ b/quest/m2/e2ee/js-undeclared-names.md
@@ -2,9 +2,9 @@
## Goal
-`@moq/net` exposes a public broadcast request handler, and `@moq/e2ee`'s
+`@moq/net` exposes a public broadcast request handler, and `@moq/crypto`'s
broadcast producer answers requests for track names it never created
-through it, under semantic names, as `moq_e2ee::broadcast::Requests` does in
+through it, under semantic names, as `moq_crypto::e2ee::broadcast::Requests` does in
Rust. A JS
application then serves on-demand tracks from a plaintext or encrypted
broadcast the same way.
@@ -18,7 +18,7 @@ Decided with the maintainer on 2026-10-24:
layers, and only the origin has a public `requests()`. Expose the
broadcast's handler under Rust's name and shape (`requests()` returning
`Requests`), and keep the internal wire path on it.
-- `@moq/e2ee` mirrors the Rust handler exactly: it opens each request's
+- `@moq/crypto` mirrors the Rust handler exactly: it opens each request's
physical name, claims it, and yields a request whose `name` is semantic.
A name that does not open is answered as missing and keeps no state. A
re-requested or re-created name resumes above its high-water marks, as in
@@ -26,7 +26,7 @@ Decided with the maintainer on 2026-10-24:
2026-10-17 refusal, so every identity stays unique and a handler can serve
a dropped name again).
- The handler offers the lister, taking semantic names and listing their
- physical names, as Rust's `moq_e2ee::broadcast::Lister` does. `@moq/net`'s broadcast lister is
+ physical names, as Rust's `moq_crypto::e2ee::broadcast::Lister` does. `@moq/net`'s broadcast lister is
internal today (tests reach it through `wireOf`), so export it with the
handler.
- Port Rust's `requests_refuse_names_the_generation_did_not_issue` and
@@ -34,8 +34,8 @@ Decided with the maintainer on 2026-10-24:
and a burst of forged names that leaves no state behind.
Public API: a public broadcast `requests()` in `@moq/net`, and a request
-handler on `@moq/e2ee`'s broadcast producer. Wire: none.
+handler on `@moq/crypto`'s broadcast producer. Wire: none.
## Required
-- [JS mirror](/quest/m2/net-wrap/js.md) - the `@moq/net` interfaces the `@moq/e2ee` wrappers implement
+- [JS mirror](/quest/m2/net-wrap/js.md) - the `@moq/net` interfaces the `@moq/crypto` wrappers implement
diff --git a/quest/m2/e2ee/rust-publish.md b/quest/m2/e2ee/rust-publish.md
index e1e4c7b2949..f6191bc983c 100644
--- a/quest/m2/e2ee/rust-publish.md
+++ b/quest/m2/e2ee/rust-publish.md
@@ -20,7 +20,7 @@ timeline publishers already publish into an encrypted
broadcast under semantic names with no change here. This quest keeps only
what the traits do not cover. Every track these publishers serve is declared
in advance, so it never needed the undeclared-name handler (maintainer,
-2026-10-19), which `moq_e2ee::broadcast::Producer::requests` now provides.
+2026-10-19), which `moq_crypto::e2ee::broadcast::Producer::requests` now provides.
- Catalog naming: derive the protected catalog name from its well-known
logical role, then put media roles, codecs, quality, timelines, and
@@ -33,13 +33,13 @@ in advance, so it never needed the undeclared-name handler (maintainer,
- Cover every current Rust importer and capture path so a convenience API
cannot emit a plaintext semantic catalog.
- A re-created track resumes (decided 2026-10-25, maintainer, replacing the
- 2026-10-17 refusal): moq-e2ee never releases a name's claim, and a track
+ 2026-10-17 refusal): moq-crypto never releases a name's claim, and a track
created again under a claimed name continues above its high-water marks,
- so nonces never repeat. moq-e2ee's `create_track` already does this.
+ so nonces never repeat. moq-crypto's `create_track` already does this.
Public API: none. Wire: none.
## Required
-- [moq-e2ee implements the traits](/quest/m2/net-wrap/e2ee.md) - the encrypted broadcast moq-mux publishes into
+- [moq-crypto's e2ee implements the traits](/quest/m2/net-wrap/e2ee.md) - the encrypted broadcast moq-mux publishes into
- [moq-mux takes the traits](/quest/m2/net-wrap/mux.md) - the mux and capture publishers this relies on to stay unchanged
diff --git a/quest/m2/mesh/README.md b/quest/m2/mesh/README.md
index 604ba6da015..8b0a645ef54 100644
--- a/quest/m2/mesh/README.md
+++ b/quest/m2/mesh/README.md
@@ -58,7 +58,7 @@ Decided 2026-10-25 with the maintainer (planning interview), still in force:
token only; a Tailnet-Lock analog was declined.
- Protection is per broadcast, with levels that nest: identity (the token
only), authentication (per-frame Ed25519 signatures, the default), and
- later encryption (signed plus moq-e2ee, waiting on
+ later encryption (signed plus moq-crypto's e2ee, waiting on
[mesh keys](/quest/m3/mesh-keys.md)).
- Enrollment is automated, with no human in the loop (decided 2026-10-30): a
device presents an enrollment key the owner created and then refreshes by
diff --git a/quest/m2/mesh/endpoint.md b/quest/m2/mesh/endpoint.md
index 82f6ebc79a4..fbb6adbbc37 100644
--- a/quest/m2/mesh/endpoint.md
+++ b/quest/m2/mesh/endpoint.md
@@ -23,10 +23,10 @@ Decided 2026-10-25 (maintainer): iroh-shaped, not drop-in compatible; tickets,
`mesh/*/*/.dial/`, and update `doc/bin/relay/auth.md`.
- Streams are [byte streams](/quest/m2/stream/rust.md) at the protection
level the service declares: identity reads `moq-net` directly, and
- authentication, the mesh default, reads through `moq-sign` against the
+ authentication, the mesh default, reads through `moq_crypto::sign` against the
`PublicKey` parsed from the path it subscribes to: the listener's
`mesh//` for a dialer, and the `.dial/` segment for a listener.
-- The secret key comes from `moq_sign::SecretKey::load_or_generate`.
+- The secret key comes from `moq_crypto::sign::SecretKey::load_or_generate`.
- A mesh daemon (Kixel's, outside this repository, decided 2026-11-02) is
built on this API, so a process either embeds an `Endpoint` or talks to a
local [mesh relay node](/quest/m2/mesh/node.md).
diff --git a/quest/m2/net-wrap/README.md b/quest/m2/net-wrap/README.md
index ad910010b86..85ac12834f5 100644
--- a/quest/m2/net-wrap/README.md
+++ b/quest/m2/net-wrap/README.md
@@ -39,7 +39,7 @@ and its trait-versus-bridge comparison:
`recv_group`, `recv_datagram`, `read_frame`, `next_frame`, `read_chunk`,
the broadcast consumer's `tracks` listing (maintainer, 2026-10-24), and
their `poll_*` forms. A wrapper adapts
- to moq-net, not the other way around: moq-e2ee's error converts into
+ to moq-net, not the other way around: `moq_crypto::e2ee::Error` converts into
`moq_net::Error`.
- **Datagrams follow the datagram types.** [Datagram tracks](/quest/m1/datagram-tracks/README.md) (m1) replaces
`append_datagram`, `insert_datagram`, and `recv_datagram` on stream tracks
@@ -72,11 +72,11 @@ above.
## Required
- [moq-net traits](/quest/m2/net-wrap/traits.md) - moq-net exports producer and consumer traits at every level, implemented by its own types
-- [moq-e2ee implements the traits](/quest/m2/net-wrap/e2ee.md) - the e2ee broadcast, track, and group wrappers implement the traits, proving them before the adopters land
+- [moq-crypto's e2ee implements the traits](/quest/m2/net-wrap/e2ee.md) - the e2ee broadcast, track, and group wrappers implement the traits, proving them before the adopters land
- [moq-json, moq-stats, and hang take the traits](/quest/m2/net-wrap/json.md) - json snapshots, streams, windows, the stats producer, and hang's tracks write and read through the traits
- [moq-mux takes the traits](/quest/m2/net-wrap/mux.md) - importers, catalog, container, timeline, json tracks, `Source`, TS export, and the moq-video and moq-audio encoders are generic over the traits
- [CLI paths take the traits](/quest/m2/net-wrap/cli.md) - the CLI's publish and play paths hand moq-mux any broadcast that implements them
-- [JS mirror](/quest/m2/net-wrap/js.md) - `@moq/net` exports the same interfaces, taken by `@moq/hang`, `@moq/publish`, and `@moq/watch`, and implemented by `@moq/e2ee`
+- [JS mirror](/quest/m2/net-wrap/js.md) - `@moq/net` exports the same interfaces, taken by `@moq/hang`, `@moq/publish`, and `@moq/watch`, and implemented by `@moq/crypto`
## Related
diff --git a/quest/m2/net-wrap/e2ee.md b/quest/m2/net-wrap/e2ee.md
index 6aa6af87b2c..12c9cc3684c 100644
--- a/quest/m2/net-wrap/e2ee.md
+++ b/quest/m2/net-wrap/e2ee.md
@@ -1,8 +1,8 @@
-# [M] moq-e2ee implements the moq-net traits
+# [M] moq-crypto's e2ee implements the moq-net traits
## Goal
-moq-e2ee's broadcast, track, and group wrappers implement the
+moq-crypto's e2ee broadcast, track, and group wrappers implement the
[moq-net traits](/quest/m2/net-wrap/traits.md), so anything generic over them
publishes or consumes an encrypted broadcast unchanged, under semantic track
names.
@@ -17,7 +17,7 @@ the reverse (decided 2026-10-20, maintainer):
- `track::Producer::create_group(u64)` takes `group::Info`.
- `broadcast::Consumer::subscribe(semantic, ..)`, which returns a
`kio::Pending`, becomes `track(semantic)` then `.subscribe(..)`.
-- `moq_e2ee::Error` converts into `moq_net::Error`, keeping the draft's
+- `moq_crypto::e2ee::Error` converts into `moq_net::Error`, keeping the draft's
typed codes (such as an authentication failure) distinguishable rather
than collapsing into `Error::Dropped`.
- Datagrams: the wrapper's datagram producer and consumer match the
@@ -25,7 +25,7 @@ the reverse (decided 2026-10-20, maintainer):
[Datagram tracks](/quest/m1/datagram-tracks/README.md), so the trait read
yields only authenticated datagrams. A datagram that fails authentication, or a duplicate, is
dropped there and the track continues. The draft's `authentication`
- event stays on moq-e2ee's own consumer, outside the trait, for callers
+ event stays on moq-crypto's own consumer, outside the trait, for callers
that hold the concrete type. A trait read can't carry it without
breaking the exact mirror.
- `track::Info.compress` is logical. Ciphertext doesn't compress, so the
@@ -44,7 +44,7 @@ the reverse (decided 2026-10-20, maintainer):
This keeps
[rust-publish](/quest/m2/e2ee/rust-publish.md)'s rule that protected
catalogs compress before encryption, and needs moq-net to expose its group
- codec to the wrapper. `@moq/e2ee` does the same in
+ codec to the wrapper. `@moq/crypto` does the same in
[JS](/quest/m2/net-wrap/js.md).
- The subscriber's wrapper learns the logical flag from authenticated E2EE
metadata, never from the physical track (decided 2026-10-20, maintainer):
@@ -54,15 +54,15 @@ the reverse (decided 2026-10-20, maintainer):
catalog track is itself compressed, so a subscriber would need the flag
before it could inflate the catalog that carries it. The
[E2EE epic](/quest/m2/e2ee/README.md) also keeps catalog formats out of
- moq-e2ee, and the [compression migration](https://github.com/moq-dev/moq/pull/7046) dropped hang's
+ moq-crypto, and the [compression migration](https://github.com/moq-dev/moq/pull/7046) dropped hang's
`compression` field. The subscriber needs the flag before inflating,
without changing moq-net's `track(name)`; propose the encoding in the PR.
Record it in `draft-lcurley-moq-e2ee.md`, replacing the Catalogs section's
`.z` sibling rule.
- Datagram header allowance (decided 2026-10-31, maintainer, a follow-up
of [moq-dev/moq#7435](https://github.com/moq-dev/moq/pull/7435)):
- `MAX_DATAGRAM_HEADER` (`rs/moq-e2ee/src/limits.rs`,
- `js/e2ee/src/limits.ts`; 28 after #7435, lite-07's Type plus three 9-byte
+ `MAX_DATAGRAM_HEADER` (`rs/moq-crypto/src/e2ee/limits.rs`,
+ `js/crypto/src/e2ee/limits.ts`; 28 after #7435, lite-07's Type plus three 9-byte
varints) also counts the optional lite datagram fields: the relayed fields
the lite `ietf` extension adds, and moq-net's Inflated Size header field,
which a compressed physical track's datagram carries outside the AEAD
@@ -84,8 +84,8 @@ the reverse (decided 2026-10-20, maintainer):
counting that cap) or documenting that relay properties are outside the
allowance, so such a datagram may be dropped, and record the choice in the
PR. Sealing and opening share
- `MAX_DATAGRAM_PAYLOAD` today (`rs/moq-e2ee/src/track.rs`,
- `js/e2ee/src/track.ts`), so a wider allowance would also make `open`
+ `MAX_DATAGRAM_PAYLOAD` today (`rs/moq-crypto/src/e2ee/track.rs`,
+ `js/crypto/src/e2ee/track.ts`), so a wider allowance would also make `open`
refuse a datagram an older sender sealed under the narrower one. Split
the seal and open limits, or pick the limit by wire version, so a
receiver still opens anything that fits the body. Update the e2ee
@@ -112,12 +112,12 @@ the reverse (decided 2026-10-20, maintainer):
- Keep the nonce rules the epic specifies: a group producer still owns its
frame numbering, and a re-created or re-served track name resumes above
its high-water marks (decided 2026-10-25, maintainer, replacing the
- refusal; moq-e2ee's claims already resume).
+ refusal; moq-crypto's claims already resume).
- Test the wrappers against the questline's pass-through test cases. The
moq-json round trip through an encrypted track waits for
[moq-json to take the traits](/quest/m2/net-wrap/json.md).
-Public API: the moq-e2ee wrapper signatures change to moq-net's. Wire:
+Public API: the moq-crypto wrapper signatures change to moq-net's. Wire:
`draft-lcurley-moq-e2ee.md` gains the authenticated logical `compress` flag
and each compressed object's authenticated inflated size.
diff --git a/quest/m2/net-wrap/js.md b/quest/m2/net-wrap/js.md
index f256a2d09d3..86bdb461508 100644
--- a/quest/m2/net-wrap/js.md
+++ b/quest/m2/net-wrap/js.md
@@ -4,7 +4,7 @@
`@moq/net` exports interfaces with the Rust traits' names and methods, and
`@moq/hang`, `@moq/publish`, and `@moq/watch` accept them where they take a
-concrete broadcast, track, or group today. `@moq/e2ee`'s wrappers implement
+concrete broadcast, track, or group today. `@moq/crypto`'s wrappers implement
them, so a browser publisher or player handles an encrypted broadcast without
its own decryption path.
@@ -16,18 +16,18 @@ its own decryption path.
- Take the interfaces only where a wrapper must pass through, as needed:
`@moq/hang`'s catalog and container code, `@moq/publish`'s broadcast,
and `@moq/watch`'s subscriptions.
-- `@moq/e2ee`'s broadcast, track, and group wrappers adapt to `@moq/net`'s
- method shapes, as moq-e2ee does in Rust, with its errors mapped to
- `@moq/net`'s. Like moq-e2ee, it compresses a `compress` track before
+- `@moq/crypto`'s broadcast, track, and group wrappers adapt to `@moq/net`'s
+ method shapes, as moq-crypto does in Rust, with its errors mapped to
+ `@moq/net`'s. Like moq-crypto, it compresses a `compress` track before
encryption, publishes the physical track uncompressed, and carries the
logical flag in the same authenticated E2EE metadata
([e2ee](/quest/m2/net-wrap/e2ee.md)).
- Demand and preference cross the wrapper: a publisher with no viewer
through an encrypted track stays idle.
- Test publish and watch round trips through a pass-through wrapper and
- through `@moq/e2ee`.
+ through `@moq/crypto`.
-Public API: new `@moq/net` interfaces; `@moq/e2ee` wrapper signatures change.
+Public API: new `@moq/net` interfaces; `@moq/crypto` wrapper signatures change.
Wire: the `draft-lcurley-moq-e2ee.md` compress flag from
[e2ee](/quest/m2/net-wrap/e2ee.md).
@@ -35,4 +35,4 @@ Wire: the `draft-lcurley-moq-e2ee.md` compress flag from
- [moq-net traits](/quest/m2/net-wrap/traits.md) - the names and methods this mirrors
-- [moq-e2ee implements the traits](/quest/m2/net-wrap/e2ee.md) - owns the authenticated logical compression encoding this mirrors
+- [moq-crypto's e2ee implements the traits](/quest/m2/net-wrap/e2ee.md) - owns the authenticated logical compression encoding this mirrors
diff --git a/quest/m2/net-wrap/json.md b/quest/m2/net-wrap/json.md
index a35c764e618..b0190226c9b 100644
--- a/quest/m2/net-wrap/json.md
+++ b/quest/m2/net-wrap/json.md
@@ -23,7 +23,7 @@ types, so each publishes into and reads from a wrapped track unchanged.
wrapper, as do demand-gated encoders.
- Existing tests keep passing with the defaults. Add one round trip per crate
through moq-net's shared pass-through test wrapper, and a moq-json snapshot
- round trip through an encrypted track in moq-e2ee's tests.
+ round trip through an encrypted track in moq-crypto's tests.
Public API: generic type parameters with moq-net defaults on moq-json,
moq-stats, and hang. Wire: none.
@@ -31,4 +31,4 @@ moq-stats, and hang. Wire: none.
## Required
- [moq-net traits](/quest/m2/net-wrap/traits.md) - the traits these take
-- [moq-e2ee implements the traits](/quest/m2/net-wrap/e2ee.md) - the encrypted track the snapshot round trip runs through
+- [moq-crypto's e2ee implements the traits](/quest/m2/net-wrap/e2ee.md) - the encrypted track the snapshot round trip runs through
diff --git a/quest/m2/net-wrap/mux.md b/quest/m2/net-wrap/mux.md
index b2a950c381d..cb78d5d14d8 100644
--- a/quest/m2/net-wrap/mux.md
+++ b/quest/m2/net-wrap/mux.md
@@ -30,7 +30,7 @@ exporter reads one, without knowing.
- No behavior change with the defaults. Keep the `containers` Criterion
bench flat before and after.
- Test an import and export round trip (fMP4 and TS) through the moq-net
- pass-through test wrapper, plus one through moq-e2ee's wrappers once
+ pass-through test wrapper, plus one through moq-crypto's wrappers once
[they implement the traits](/quest/m2/net-wrap/e2ee.md).
Public API: generic type parameters with moq-net defaults across moq-mux.
diff --git a/quest/m2/net-wrap/traits.md b/quest/m2/net-wrap/traits.md
index d0a07879f6d..c1132c289ee 100644
--- a/quest/m2/net-wrap/traits.md
+++ b/quest/m2/net-wrap/traits.md
@@ -29,7 +29,7 @@ the methods exactly as moq-net has them today.
- Requests: a broadcast producer's `requests` returns its own
`broadcast::Requests`, whose `requested_track` yields its own
`track::Request`, so generic code serves undeclared names (as
- `moq_e2ee::broadcast::Requests` does). A
+ `moq_crypto::e2ee::broadcast::Requests` does). A
`track::Requests`'s `requested_fill` yields its own `track::Fill`, whose
`accept` returns its own group producer and whose `drop_groups` names
the rest dropped.
diff --git a/quest/m2/release/cut.md b/quest/m2/release/cut.md
index b1bb4f5bd0f..0633405d1ad 100644
--- a/quest/m2/release/cut.md
+++ b/quest/m2/release/cut.md
@@ -48,6 +48,14 @@ From the 2026-10-25 pre-cut run:
`MOQ_FFI_RANGE`) to the release that ships the `implementation` field from
[moq-dev/moq#6775](https://github.com/moq-dev/moq/pull/6775).
+From [moq-dev/moq#7702](https://github.com/moq-dev/moq/pull/7702), which
+merged moq-e2ee and moq-sign into moq-crypto (decided 2026-11-02, no yank):
+
+- Publish `main`'s code-free `rs/moq-e2ee` stub, whose README points at
+ moq-crypto, as moq-e2ee's final release. It must take a version above
+ crates.io's current `max_version` (0.0.20 on 2026-11-02); check with
+ `curl -s https://crates.io/api/v1/crates/moq-e2ee`.
+
The [2026-10-22 release audit](https://github.com/moq-dev/moq/pull/7176)
closed with its fixes rechecked together. At source candidate
[main 487759f62a](https://github.com/moq-dev/moq/commit/487759f62a9ef39d916fe5b92df06dcff83478ce),
diff --git a/quest/m2/stream/README.md b/quest/m2/stream/README.md
index 87cd7854dcb..e4862999940 100644
--- a/quest/m2/stream/README.md
+++ b/quest/m2/stream/README.md
@@ -25,7 +25,7 @@ Decided 2026-10-25 with the maintainer (mesh planning interview):
`TCP_NODELAY` still applies).
- The receiver flushes a frame's bytes to its TCP socket as they arrive, never
waiting for the whole frame, unless the mesh's authentication level
- (`moq-sign`) must verify it first; a frame that fails verification ends its
+ (`moq_crypto::sign`) must verify it first; a frame that fails verification ends its
group with a typed error, surfaced as a reset.
Group finish is a FIN (half-close); a group abort with a code is a reset.
The implementer measures and records a frame-size cap.
diff --git a/quest/m3/ffi-e2ee.md b/quest/m3/ffi-e2ee.md
index ee85239e6d5..8c2efecbbd7 100644
--- a/quest/m3/ffi-e2ee.md
+++ b/quest/m3/ffi-e2ee.md
@@ -2,9 +2,9 @@
## Goal
-The Swift and Kotlin bindings publish and consume moq-e2ee protected
+The Swift and Kotlin bindings publish and consume moq-crypto protected
broadcasts under an application-supplied `(context, kid, secret)` credential,
-interoperating with `@moq/e2ee` in both directions, with the same epoch rules
+interoperating with `@moq/crypto` in both directions, with the same epoch rules
and typed authentication failures as Rust and JS.
## Plan
@@ -15,7 +15,7 @@ to, adding both halves. The named consumer is moq.pro's
[T3 Code over MoQ](https://github.com/moq-dev/moq.pro/blob/main/quest/m3/t3/README.md)
mobile app, which receives its credential in a pairing link.
-Wrap `moq-e2ee`'s producer and consumer entry points without new crypto in
+Wrap `moq-crypto`'s producer and consumer entry points without new crypto in
the binding layer, and keep the encrypting publisher's refusal of a shared or
explicit epoch. Add a binding test that decrypts a JS-published broadcast and
the reverse to the interop suite.
diff --git a/quest/m3/mesh-keys.md b/quest/m3/mesh-keys.md
index 12712e5ef6a..1f39d52bc5f 100644
--- a/quest/m3/mesh-keys.md
+++ b/quest/m3/mesh-keys.md
@@ -14,7 +14,7 @@ Parked 2026-10-25 (maintainer): encryption is out of the first mesh; identity
and authentication ship first. Research recorded in the planning PR: SFrame
and IETF secure objects leave key distribution open and give no sender
authenticity; MLS per broadcast is heavy for churning viewers; a sender-keys
-style wrapped key track fans out like media. The AEAD stays moq-e2ee.
+style wrapped key track fans out like media. The AEAD stays moq-crypto's e2ee.
Revisit when a mesh user needs confidentiality from relays.
## Related
diff --git a/rs/justfile b/rs/justfile
index 5c6740d5aeb..ad4d06d7ecf 100644
--- a/rs/justfile
+++ b/rs/justfile
@@ -493,7 +493,7 @@ gst-smoke *args:
# rind is built to skip that one startup check, or it refuses the simulated CPU.
codspeed:
VALGRIND_BUG_494162=1 cargo codspeed build --locked -m simulation \
- -p kio -p moq-audio -p moq-e2ee -p moq-json -p moq-mux -p moq-net -p moq-pattern -p moq-quic -p moq-rtmp \
+ -p kio -p moq-audio -p moq-crypto -p moq-json -p moq-mux -p moq-net -p moq-pattern -p moq-quic -p moq-rtmp \
--features moq-audio/bus,moq-net/fuzz,moq-quic/fuzz \
--bench tasks --bench waiter --bench bus --bench protect --bench codec --bench table \
--bench catalog --bench containers --bench decode_clock --bench export --bench jitter \
diff --git a/rs/moq-e2ee/CHANGELOG.md b/rs/moq-crypto/CHANGELOG.md
similarity index 100%
rename from rs/moq-e2ee/CHANGELOG.md
rename to rs/moq-crypto/CHANGELOG.md
diff --git a/rs/moq-sign/Cargo.toml b/rs/moq-crypto/Cargo.toml
similarity index 63%
rename from rs/moq-sign/Cargo.toml
rename to rs/moq-crypto/Cargo.toml
index bcad6ad0373..9950ffd9c45 100644
--- a/rs/moq-sign/Cargo.toml
+++ b/rs/moq-crypto/Cargo.toml
@@ -1,35 +1,43 @@
[package]
publish = false
-name = "moq-sign"
-description = "Per-frame Ed25519 signatures for MoQ broadcasts, so relays proxy without forging content."
+name = "moq-crypto"
+description = "Content signing and end-to-end encryption for MoQ broadcasts."
authors = ["Luke Curley "]
repository = "https://github.com/moq-dev/moq"
license = "MIT OR Apache-2.0"
-version = "0.0.1"
+version = "0.0.11"
edition = "2024"
rust-version.workspace = true
-keywords = ["quic", "http3", "webtransport", "signature", "live"]
+keywords = ["quic", "webtransport", "encryption", "signature", "live"]
categories = ["cryptography", "multimedia", "network-programming"]
[dependencies]
aws-lc-rs = { workspace = true }
+base64 = { workspace = true }
bytes = { workspace = true }
data-encoding = { workspace = true }
kio = { workspace = true }
moq-net = { workspace = true }
+rind = { workspace = true }
thiserror = { workspace = true }
+uuid = { workspace = true }
zeroize = { workspace = true }
[dev-dependencies]
criterion = { package = "bench-harness", path = "../bench-harness" }
hex = { workspace = true }
+kio = { workspace = true, features = ["runtime"] }
serde_json = { workspace = true }
tempfile = { workspace = true }
-tokio = { workspace = true, features = ["macros", "rt", "test-util"] }
+tokio = { workspace = true, features = ["macros", "rt", "sync", "test-util", "time"] }
workspace-hack = { path = "../workspace-hack" }
+[[bench]]
+name = "protect"
+harness = false
+
[[bench]]
name = "sign"
harness = false
diff --git a/rs/moq-e2ee/MIGRATE.md b/rs/moq-crypto/MIGRATE.md
similarity index 78%
rename from rs/moq-e2ee/MIGRATE.md
rename to rs/moq-crypto/MIGRATE.md
index 56e235fc672..706229d793e 100644
--- a/rs/moq-e2ee/MIGRATE.md
+++ b/rs/moq-crypto/MIGRATE.md
@@ -1,9 +1,22 @@
-# Migrating moq-e2ee
+# Migrating moq-crypto
How to update your code for each breaking change, newest first.
## Unreleased
+### moq-e2ee and moq-sign are moq-crypto (#7702)
+
+`moq-e2ee` and the workspace-only `moq-sign` merged into `moq-crypto`, as its `e2ee` and `sign` modules.
+The profiles and wire are unchanged; each module keeps its own `Error` and `Result`.
+Depend on `moq-crypto` and rename the imports:
+
+| Before | After |
+| --- | --- |
+| `moq_e2ee::…` | `moq_crypto::e2ee::…` |
+| `moq_sign::…` | `moq_crypto::sign::…` |
+
+`moq_e2ee`'s entries below predate the merge and apply to `moq_crypto::e2ee`.
+
### Tracks are named semantically through `broadcast` wrappers (#5876)
`generation::Producer::produce` and `generation::Consumer::consume` are private.
diff --git a/rs/moq-crypto/README.md b/rs/moq-crypto/README.md
new file mode 100644
index 00000000000..9fd4f540af5
--- /dev/null
+++ b/rs/moq-crypto/README.md
@@ -0,0 +1,102 @@
+[](https://github.com/moq-dev/moq/blob/main/LICENSE-MIT)
+
+# moq-crypto
+
+Workspace-only implementation; this crate is not published.
+
+Content signing and end-to-end encryption for [Media over QUIC](https://moq.dev): the `sign`
+module signs every frame so relays cannot forge it, and the `e2ee` module encrypts groups,
+datagrams, and track names so relays cannot read them. Both wrap `moq-net` and check timestamps
+with its `group::on_track`, so a frame either half accepts is one `moq-net` accepts.
+
+## Signing
+
+Per-frame Ed25519 signatures for [Media over QUIC](https://moq.dev) broadcasts. Profile
+`moq-sign-00` from [draft-lcurley-moq-sign](https://datatracker.ietf.org/doc/draft-lcurley-moq-sign/).
+
+Relays forward and cache signed frames; they cannot forge, retime, or relocate them. Signatures
+authenticate content, not liveness: a relay that recorded an instance can replay it whole.
+
+### Shape
+
+An endpoint's `SecretKey` signs; its `PublicKey` is the endpoint ID, displayed as 52 z-base-32
+characters (a DNS label). `SecretKey::load_or_generate(path)` keeps one key for the life of a host,
+as 52 z-base-32 characters in a `0600` file it never replaces implicitly.
+
+`broadcast::Producer` wraps the `moq-net` broadcast, mints a fresh instance, and signs each frame
+over the application path, instance, track, group, frame index, and timestamp (at the track's
+timescale). Announce the broadcast with that instance on its route:
+
+```rust
+let key = SecretKey::load_or_generate("/var/lib/moq/endpoint.key")?;
+let path = moq_net::Path::new(&format!("mesh/{}/agent", key.public()))?;
+let publication = origin.create_broadcast(&path)?;
+let signed = broadcast::Producer::new(publication.broadcast().clone(), key, path);
+let messages = signed.create_track("messages", None)?;
+publication.announce(Route::default().with_instance(signed.instance().clone(), 0))?;
+```
+
+A subscriber wraps the broadcast an origin resolved in a `broadcast::Consumer` with the key it
+expects and the same application path; it takes the instance from the route. A frame reaches the
+application only after it verifies. A forged or relocated frame ends its group with
+`Error::Signature`, and the track keeps delivering other groups. Every hop must carry the instance
+and timestamps unchanged, which means moq-lite-07. A group's end is not signed: a relay may drop
+a group's tail, as MoQ already allows.
+
+A broadcast at the identity level, which trusts the relay's token check alone, uses `moq-net`
+directly.
+
+### Processing
+
+Signing is inline and synchronous. `cargo bench -p moq-crypto --bench sign` measures it: a 1 KiB frame costs
+about 8 µs to sign and 32 µs to sign and verify through an origin on one core.
+
+## Encryption
+
+End-to-end encryption for [Media over QUIC](https://moq.dev) groups, datagrams,
+and track names. Profile `moq-e2ee-00` from
+[draft-lcurley-moq-e2ee](https://datatracker.ietf.org/doc/draft-lcurley-moq-e2ee/).
+
+Relays forward ciphertext. Content keys never enter `moq-net`.
+
+### Shape
+
+The application distributes a `Credential { context, kid, secret }` over its own
+authenticated channel. `credential.produce()` mints a fresh epoch and returns a
+`generation::Producer`, which derives opaque track names and keys for that instance alone.
+It accepts no explicit epoch; its clones share permanent track claims.
+
+The application names tracks by their semantic names. `broadcast::Producer` wraps the
+`moq-net` broadcast and creates each track under its physical name, so only physical names
+reach the relays. A physical name is the semantic name encrypted under the generation: a relay
+learns only its length rounded up to 16 bytes. A track served on demand is reserved with
+`reserve_track` and accepted once its demand shows a subscriber.
+
+```rust
+let credential = Credential::new(credential::Config { context, kid, secret })?;
+let generation = credential.produce();
+let broadcast = origin.create_broadcast(&credential.path("meeting.hang")?)?;
+let protected = broadcast::Producer::new(broadcast.clone(), generation.clone());
+let video = protected.create_track("video", None)?;
+broadcast.announce(Route::default().with_instance(generation.epoch().instance(), 0))?;
+```
+
+A subscriber follows `credential.path(semantic)` with `origin.follow(path, None)`. It takes
+each instance's epoch from the broadcast it resolved, `Epoch::of(&broadcast)` (or from the
+application's channel on a wire that carries no instance, older than lite-07), so the key always matches the instance
+it reads. It binds the epoch with `credential.consume(epoch)` and wraps the broadcast in a
+`broadcast::Consumer`. Its `subscribe(semantic, subscription)` opens the track a decrypted
+catalog names. A consuming generation cannot produce. Nothing survives a publisher instance: a restart mints a new epoch.
+A cloned process image (a `fork` without `exec`, a restored VM snapshot or checkpoint, or a
+producing generation copied to another process) is a new instance too: each copy must call
+`produce()` itself, since copies of one generation reuse its nonces.
+
+### Processing
+
+AES-128-GCM is inline and synchronous. `cargo bench -p moq-crypto --bench protect` measures the whole
+protected write path, including the `moq-net` group: a 1 KiB grouped frame and a
+160-byte Opus-sized datagram each cost a few microseconds on one core, so encryption
+is a tiny fraction of real time and there is no async pump.
+
+Memory is bounded: a producer retains no ciphertext, and a consumer keeps a 1024-bit
+datagram duplicate window below the greatest sequence it opened.
diff --git a/rs/moq-e2ee/benches/protect.rs b/rs/moq-crypto/benches/protect.rs
similarity index 83%
rename from rs/moq-e2ee/benches/protect.rs
rename to rs/moq-crypto/benches/protect.rs
index b2a567560d2..286c30cc30e 100644
--- a/rs/moq-e2ee/benches/protect.rs
+++ b/rs/moq-crypto/benches/protect.rs
@@ -1,13 +1,13 @@
//! AES-128-GCM throughput for grouped frames and datagrams through the public API.
//!
-//! Run with `cargo bench -p moq-e2ee`.
+//! Run with `cargo bench -p moq-crypto --bench protect`.
use std::hint::black_box;
use std::time::Duration;
use criterion::{Criterion, Throughput, criterion_group, criterion_main};
-use moq_e2ee::Credential;
-use moq_e2ee::credential::Config;
+use moq_crypto::e2ee::Credential;
+use moq_crypto::e2ee::credential::Config;
use moq_net::Timestamp;
fn credential() -> Credential {
@@ -20,12 +20,12 @@ fn credential() -> Credential {
}
/// Each producer is its own publisher instance, so it gets its own epoch.
-fn produce(credential: &Credential, semantic: &str) -> moq_e2ee::track::Producer {
+fn produce(credential: &Credential, semantic: &str) -> moq_crypto::e2ee::track::Producer {
// Advancing timestamps plus a zero max age keep only the newest group cached.
let info = moq_net::track::Info::default()
.with_timescale(moq_net::Timescale::MILLI)
.with_max_age(Duration::ZERO);
- moq_e2ee::broadcast::Producer::new(moq_net::broadcast::Info::new().produce(), credential.produce())
+ moq_crypto::e2ee::broadcast::Producer::new(moq_net::broadcast::Info::new().produce(), credential.produce())
.create_track(semantic, info)
.unwrap()
}
diff --git a/rs/moq-sign/benches/sign.rs b/rs/moq-crypto/benches/sign.rs
similarity index 91%
rename from rs/moq-sign/benches/sign.rs
rename to rs/moq-crypto/benches/sign.rs
index 22fcd30b525..fad191fd460 100644
--- a/rs/moq-sign/benches/sign.rs
+++ b/rs/moq-crypto/benches/sign.rs
@@ -1,15 +1,15 @@
//! Ed25519 cost per grouped frame through the public API: signing on write, verifying on read.
//!
-//! Run with `cargo bench -p moq-sign`.
+//! Run with `cargo bench -p moq-crypto --bench sign`.
use std::hint::black_box;
use std::task::Poll;
use std::time::Duration;
use criterion::{Criterion, Throughput, criterion_group, criterion_main};
-use moq_sign::{SecretKey, broadcast};
+use moq_crypto::sign::{SecretKey, broadcast};
-fn produce(key: &SecretKey) -> (moq_sign::track::Producer, moq_net::broadcast::Producer) {
+fn produce(key: &SecretKey) -> (moq_crypto::sign::track::Producer, moq_net::broadcast::Producer) {
// A zero max age keeps only the newest group cached.
let info = moq_net::track::Info::default().with_max_age(Duration::ZERO);
let inner = moq_net::broadcast::Info::new().produce();
@@ -24,8 +24,8 @@ fn produce(key: &SecretKey) -> (moq_sign::track::Producer, moq_net::broadcast::P
async fn roundtrip(
key: &SecretKey,
) -> (
- moq_sign::track::Producer,
- moq_sign::track::Consumer,
+ moq_crypto::sign::track::Producer,
+ moq_crypto::sign::track::Consumer,
moq_net::origin::Publication,
) {
let (origin, driver) = moq_net::origin::Producer::new(moq_net::origin::Config::default());
diff --git a/rs/moq-e2ee/src/broadcast.rs b/rs/moq-crypto/src/e2ee/broadcast.rs
similarity index 97%
rename from rs/moq-e2ee/src/broadcast.rs
rename to rs/moq-crypto/src/e2ee/broadcast.rs
index 72ddf0d0f18..42abf367a62 100644
--- a/rs/moq-e2ee/src/broadcast.rs
+++ b/rs/moq-crypto/src/e2ee/broadcast.rs
@@ -6,14 +6,14 @@
use std::task::{Poll, ready};
-use crate::error::{Error, Result};
-use crate::{Name, generation, track};
+use crate::e2ee::error::{Error, Result};
+use crate::e2ee::{Name, generation, track};
/// The publishing side of a protected broadcast.
///
-/// Wraps the `moq-net` broadcast at [`Credential::path`](crate::Credential::path). Announce that
+/// Wraps the `moq-net` broadcast at [`Credential::path`](crate::e2ee::Credential::path). Announce that
/// broadcast with [`generation().epoch()`](generation::Producer::epoch)'s
-/// [`instance`](crate::Epoch::instance) on its route once the tracks a subscriber needs first
+/// [`instance`](crate::e2ee::Epoch::instance) on its route once the tracks a subscriber needs first
/// exist.
#[derive(Clone)]
pub struct Producer {
@@ -256,7 +256,7 @@ impl Lister {
/// The subscribing side of a protected broadcast.
///
-/// Wraps the `moq-net` broadcast found at [`Credential::path`](crate::Credential::path), bound to
+/// Wraps the `moq-net` broadcast found at [`Credential::path`](crate::e2ee::Credential::path), bound to
/// the epoch on its route.
#[derive(Clone)]
pub struct Consumer {
diff --git a/rs/moq-e2ee/src/credential.rs b/rs/moq-crypto/src/e2ee/credential.rs
similarity index 96%
rename from rs/moq-e2ee/src/credential.rs
rename to rs/moq-crypto/src/e2ee/credential.rs
index 7a3003d294f..59d2303e851 100644
--- a/rs/moq-e2ee/src/credential.rs
+++ b/rs/moq-crypto/src/e2ee/credential.rs
@@ -9,10 +9,10 @@ use bytes::Bytes;
use rind::hkdf;
use zeroize::{Zeroize, ZeroizeOnDrop};
-use crate::Epoch;
-use crate::error::{Error, Result};
-use crate::generation;
-use crate::limits::{PATH_LABEL, PATH_LEN, PROFILE, SECRET_LEN, check_bytes, check_u53};
+use crate::e2ee::Epoch;
+use crate::e2ee::error::{Error, Result};
+use crate::e2ee::generation;
+use crate::e2ee::limits::{PATH_LABEL, PATH_LEN, PROFILE, SECRET_LEN, check_bytes, check_u53};
/// What the application distributes over its own authenticated channel.
pub struct Config {
diff --git a/rs/moq-e2ee/src/datagram.rs b/rs/moq-crypto/src/e2ee/datagram.rs
similarity index 100%
rename from rs/moq-e2ee/src/datagram.rs
rename to rs/moq-crypto/src/e2ee/datagram.rs
diff --git a/rs/moq-e2ee/src/epoch.json b/rs/moq-crypto/src/e2ee/epoch.json
similarity index 100%
rename from rs/moq-e2ee/src/epoch.json
rename to rs/moq-crypto/src/e2ee/epoch.json
diff --git a/rs/moq-e2ee/src/epoch.rs b/rs/moq-crypto/src/e2ee/epoch.rs
similarity index 97%
rename from rs/moq-e2ee/src/epoch.rs
rename to rs/moq-crypto/src/e2ee/epoch.rs
index 881eff38bea..f17812f0064 100644
--- a/rs/moq-e2ee/src/epoch.rs
+++ b/rs/moq-crypto/src/e2ee/epoch.rs
@@ -83,7 +83,7 @@ mod tests {
assert!(Epoch::mint() > epoch);
}
- /// Shared with `js/e2ee/src/epoch.test.ts`, so both parse and order alike.
+ /// Shared with `js/crypto/src/e2ee/epoch.test.ts`, so both parse and order alike.
#[test]
fn epoch_vectors() {
let vectors: serde_json::Value = serde_json::from_str(include_str!("epoch.json")).unwrap();
diff --git a/rs/moq-e2ee/src/error.rs b/rs/moq-crypto/src/e2ee/error.rs
similarity index 94%
rename from rs/moq-e2ee/src/error.rs
rename to rs/moq-crypto/src/e2ee/error.rs
index db51a762c86..81c87068898 100644
--- a/rs/moq-e2ee/src/error.rs
+++ b/rs/moq-crypto/src/e2ee/error.rs
@@ -33,5 +33,5 @@ pub enum Error {
Net(#[from] moq_net::Error),
}
-/// A [`Result`](std::result::Result) using this crate's [`Error`].
+/// A [`Result`](std::result::Result) using this module's [`Error`].
pub type Result = std::result::Result;
diff --git a/rs/moq-e2ee/src/generation.rs b/rs/moq-crypto/src/e2ee/generation.rs
similarity index 87%
rename from rs/moq-e2ee/src/generation.rs
rename to rs/moq-crypto/src/e2ee/generation.rs
index b16028b1719..fd6b57a90c8 100644
--- a/rs/moq-e2ee/src/generation.rs
+++ b/rs/moq-crypto/src/e2ee/generation.rs
@@ -4,13 +4,13 @@ use std::collections::HashMap;
use std::fmt;
use std::sync::{Arc, Mutex};
-use crate::Epoch;
-use crate::credential::{Credential, append_bytes};
-use crate::error::Result;
-use crate::key::TrackKey;
-use crate::limits::{KEY_LABEL, NAME_KEY_LABEL, NAME_MAC_LABEL};
-use crate::name::{self, Name};
-use crate::track;
+use crate::e2ee::Epoch;
+use crate::e2ee::credential::{Credential, append_bytes};
+use crate::e2ee::error::Result;
+use crate::e2ee::key::TrackKey;
+use crate::e2ee::limits::{KEY_LABEL, NAME_KEY_LABEL, NAME_MAC_LABEL};
+use crate::e2ee::name::{self, Name};
+use crate::e2ee::track;
use rind::{aead, hmac};
/// Grouped-frame versus datagram key domain.
@@ -39,8 +39,8 @@ struct Inner {
/// A discovered epoch cannot produce tracks:
///
/// ```compile_fail
-/// fn encrypt(generation: moq_e2ee::generation::Consumer, broadcast: moq_net::broadcast::Producer) {
-/// moq_e2ee::broadcast::Producer::new(broadcast, generation);
+/// fn encrypt(generation: moq_crypto::e2ee::generation::Consumer, broadcast: moq_net::broadcast::Producer) {
+/// moq_crypto::e2ee::broadcast::Producer::new(broadcast, generation);
/// }
/// ```
#[derive(Clone)]
@@ -83,7 +83,7 @@ impl Consumer {
///
/// # Errors
///
- /// [`Error::Identity`](crate::Error::Identity) if `semantic` exceeds 65535 bytes.
+ /// [`Error::Identity`](crate::e2ee::Error::Identity) if `semantic` exceeds 65535 bytes.
pub fn name(&self, semantic: &str) -> Result {
self.0.names.seal(semantic)
}
@@ -92,7 +92,7 @@ impl Consumer {
///
/// # Errors
///
- /// [`Error::Identity`](crate::Error::Identity) if `semantic` exceeds 65535 bytes.
+ /// [`Error::Identity`](crate::e2ee::Error::Identity) if `semantic` exceeds 65535 bytes.
pub(crate) fn consume(&self, track: moq_net::track::Subscriber, semantic: &str) -> Result {
Ok(track::Consumer::new(track, self.keys(semantic)?))
}
@@ -194,7 +194,7 @@ impl Producer {
///
/// # Errors
///
- /// [`Error::Authentication`](crate::Error::Authentication) if this generation did not issue `name`.
+ /// [`Error::Authentication`](crate::e2ee::Error::Authentication) if this generation did not issue `name`.
pub(crate) fn open(&self, name: &Name) -> Result {
self.consumer.0.names.open(name)
}
@@ -203,7 +203,7 @@ impl Producer {
///
/// # Errors
///
- /// [`Error::Identity`](crate::Error::Identity) if `semantic` exceeds 65535 bytes, and then `track` is aborted.
+ /// [`Error::Identity`](crate::e2ee::Error::Identity) if `semantic` exceeds 65535 bytes, and then `track` is aborted.
pub(crate) fn produce(&self, track: moq_net::track::Producer, semantic: &str) -> Result {
match self.claim(semantic) {
Ok(keys) => Ok(track::Producer::new(track, keys)),
@@ -220,7 +220,7 @@ impl Producer {
///
/// # Errors
///
- /// [`Error::Identity`](crate::Error::Identity) if `semantic` exceeds 65535 bytes.
+ /// [`Error::Identity`](crate::e2ee::Error::Identity) if `semantic` exceeds 65535 bytes.
pub(crate) fn claim(&self, semantic: &str) -> Result {
self.consumer.keys(semantic)
}
@@ -230,7 +230,7 @@ impl Producer {
///
/// # Errors
///
- /// [`Error::Identity`](crate::Error::Identity) if `semantic` exceeds 65535 bytes.
+ /// [`Error::Identity`](crate::e2ee::Error::Identity) if `semantic` exceeds 65535 bytes.
pub(crate) fn peek(&self, semantic: &str) -> Result {
if let Some(keys) = self.consumer.0.keys.lock().expect("generation keys").get(semantic) {
return Ok(keys.clone());
diff --git a/rs/moq-e2ee/src/group.rs b/rs/moq-crypto/src/e2ee/group.rs
similarity index 91%
rename from rs/moq-e2ee/src/group.rs
rename to rs/moq-crypto/src/e2ee/group.rs
index 012e2d32a5a..e95e89b1e50 100644
--- a/rs/moq-e2ee/src/group.rs
+++ b/rs/moq-crypto/src/e2ee/group.rs
@@ -6,10 +6,10 @@ use std::task::{Poll, ready};
use bytes::Bytes;
-use crate::error::{Error, Result};
-use crate::key::TrackKey;
-use crate::limits::MAX_GROUPED_PAYLOAD;
-use crate::terminal::Terminal;
+use crate::e2ee::error::{Error, Result};
+use crate::e2ee::key::TrackKey;
+use crate::e2ee::limits::MAX_GROUPED_PAYLOAD;
+use crate::e2ee::terminal::Terminal;
/// A decrypted grouped frame.
#[derive(Clone, Debug, PartialEq, Eq)]
@@ -64,22 +64,13 @@ impl Producer {
/// [`Error::Identity`] if the next frame exceeds 32 bits, [`Error::Exhausted`],
/// [`Error::Oversize`], or a net write error.
pub fn write_frame(&mut self, timestamp: impl Into