SNIP-05: Relay-to-Relays Control
draft optional
This SNIP defines kind:21105: an ephemeral command event used to trigger physical hardware relays (switches, solenoids, mag-locks) via software relays (Nostr).
Motivation
The term "relay" is overloaded.
- Software Relay: A WebSocket server that stores and forwards Nostr events.
- Hardware Relay: An electromechanical switch used to control high power circuits with low power signals.
SNIP-05 creates a bridge between the two, allowing a Nostr event to physically "click" a switch in the real world. This enables decentralized, cryptographically secure access control (e.g., opening a door) without relying on centralized IoT clouds.
Event Kind
- 21105 — Ephemeral Command. These events are not stored long-term by the software relay; they are "fire and forget" instructions intended for immediate processing by the hardware client.
Tags
p— Target Device Pubkey. The public key of the hardware controller (e.g., the Raspberry Pi or ESP32 controlling the door).d— Hardware ID. The specific pin, channel, or physical relay identifier on the device (e.g., "front_door", "relay_1", "garage").cmd— Instruction. The action to perform. MUST be one of: "on", "off", "toggle", "pulse".expiration— Security Timeout. Unix timestamp after which this command is invalid. CRITICAL for preventing replay attacks.
Content
The .content field is optional and may contain a human-readable message, e.g., "Open sesame".
Security & Replay Prevention
Hardware clients listening for kind:21105 MUST enforce the following rules:
- Allowlist: The event author (
.pubkey) MUST be in the device's authorized user list. - Freshness: The event
created_attimestamp MUST be within a strict window (e.g., +/- 5 seconds) of the device's current time. - Expiration: If the
"expiration"tag is present, the current time MUST be less than the expiration. - Idempotency: The device SHOULD cache the event
.idof processed commands for a short duration to prevent processing the same "Unlock" command twice.
Example Workflow
- User stands in front of their office door.
- User taps "Unlock" in their Nostr client.
- Client publishes
kind:21105to the specified software relay. - Hardware Controller (listening to the same software relay) sees the event.
- Hardware Controller verifies the signature, checks the timestamp, and fires the physical solenoid.
- Click. Door opens.
Example Event
{
"kind": 21105,
"id": "5561bd0f8e0417c3edaf89e7099e86debc00467d0ce7f92b910f90df9228e27a",
"pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"created_at": 1765150322,
"tags": [
[
"d",
"gate_01"
],
[
"cmd",
"pulse"
]
],
"content": "",
"sig": "c8c6687cd8a9d127c309b7cb131f3fa42251bba5c2767a7faab8c45e80b9f7b86ed0fc92566d3d367b77f53237be41bcf88a004d3793a822671a468ad7ac0248"
}
Why "Pulse"?
For electromechanical locks (mag-locks or door strikes), you typically don't want "On" (unlock forever) or "Off" (lock). You want a Pulse (Unlock for 5 seconds, then auto-lock). This logic is handled by the hardware client when receiving the pulse command.
Discussion
Connect a key to comment.