The pieces / weirdnet-push

weirdnet-push

Push wake-up: 96-byte sealed wake payloads, rotating wake handles, and a self-hostable server for APNs, FCM and relays.

v0.1.1 GitHub crates.io docs.rs weirdnet-push = "0.1.1"

What it brings

Wake a suspended phone when a peer or its home relay has sealed messages for it, without Apple, Google or the push service learning anything about the message, the sender or the network. It is the payload format, the client, a self-hostable server, and the relay wake path for phones without Google services.

What it is

A suspended phone can’t keep a connection, so a peer or its home relay asks a push service to wake it. This crate is that service, its client and the payload format, built so that Apple, Google and the push service see only ciphertext.

How it works

  • Wake payloads (wake): exactly 96 bytes, sealed to the device's PushKey (X25519, HKDF-SHA256, ChaCha20-Poly1305, a fresh key per payload) and bound to its handle. Inside are only a reason code (MessageWaiting, ConnectionRequested), a random value and a time. ReplayGuard refuses repeats and stale wakes.
  • Wake handles (handle): 32 random bytes. The device shares a WakeCard (handle and push public key) only with its home relay and trusted peers, sealed. Its ControlSecret rotates the handle (the old one stops at once) or revokes it.
  • Client (PushClient): register, rotate, unregister, wake, and follow relay announcements.
  • Server (the weirdnet-push binary): APNs with token auth (an alert with mutable-content and a fixed placeholder text the device replaces after decrypting), FCM HTTP v1 high-priority data messages, and the relay path. A token the provider rejects revokes its handle. It stores only SHA-256 hashes of handles and control secrets and logs no handles or tokens. Put TLS in front.
  • Relay wake path (relaywake, /weirdnet/wake/1): a device that opted in keeps a stream to its home relay and subscribes its handles; trusted peers deliver payloads to the relay, which also passes on the push service's announcements. weirdnet-relay serves it.
PartySees
Apple / Googlethe device token, the time and 96 bytes of ciphertext
The push servicethe handle's hash and the device token (stored); the handle and time (per wake)
Relaysthe handle, the time and the ciphertext (the home relay also sees which peer subscribed)
Sendersthe handle and push public key they were given

Nobody but the device sees the reason. Abuse control in this phase is handle revocation and rotation; there are no rate limits yet, and UnifiedPush is a later phase.

Key types and modules

  • wake: PushKey, Payload96, Reason, seal, ReplayGuard.
  • handle: WakeHandle, WakeCard, ControlSecret (rotate and revoke).
  • PushClient: register, rotate, unregister, wake, follow announcements.
  • relaywake: the /weirdnet/wake/1 relay wake path.
  • server and the weirdnet-push binary: APNs, FCM HTTP v1 and relay delivery.

Feature flags

  • client (default): the HTTP client for devices and senders.
  • relay-wake (default): the relay wake path’s wire protocol.
  • server: the push server library and the weirdnet-push binary.

Usage

Install:

cargo install weirdnet-push --features server
weirdnet-push relay-token                      # for each relay that follows
weirdnet-push check -c /etc/weirdnet-push/config.toml
weirdnet-push serve -c /etc/weirdnet-push/config.toml

In Cargo.toml:

[dependencies]
weirdnet-push = "0.1.1"

Then (built and run against the published crate when this page was made):

// A sender seals a 96-byte wake for a device; only the device can open it, once.
use std::time::Duration;
use weirdnet_push::{PushKey, Reason, ReplayGuard, WakeHandle, wake};

fn main() -> weirdnet_push::Result<()> {
    let key = PushKey::generate(); // stays on the device
    let handle = WakeHandle::generate(); // shared, sealed, with the home relay and trusted peers

    let payload = wake::seal(&key.public(), &handle, Reason::MessageWaiting)?; // a sender
    let w = key.open(&handle, &payload)?; // the device
    let mut guard = ReplayGuard::new(Duration::from_secs(300), 1024);
    guard.check_now(&w)?;
    assert!(guard.check_now(&w).is_err()); // the same wake again is refused
    Ok(())
}

Where it fits

  • Builds on weirdnet-keys.
  • Used by weirdnet-relay.
  • License: BSD-3-Clause.