Docs/One-Time Pads
One-Time Pads
Random key material shared by exactly two of your devices, every byte used once: what a pad adds to a tunnel, how to share one, sealing small secrets, refills, how far pads scale, and what to do when a machine is restored from a backup.
What a Pad Is
A pad is random bytes that exactly two devices hold. It is made from the operating system's random source on one device and delivered to the other; nobody else ever has it.
Three rules make it a one-time pad rather than just a shared key:
- Two lanes. A pad is split in half, one half per direction. A device only spends from its own lane, so the two ends can never spend the same bytes, even when they are not talking.
- Every byte once. The position of the next unused byte is written to disk, and synced, before the bytes are handed out. A crash at any moment can waste pad; it cannot hand the same bytes out twice.
- Spent bytes are erased. After use the bytes are overwritten with zeros on disk. Zeros are never handed out as pad.
A pad is separate from your identity key and does not replace it. The key says who you are; the pad says this is one of the two devices that were paired.
See also: One-Time Pads: How It Got There Is How Strong It Is, Security Center: The Views
What It Protects Against
- Traffic recorded today, opened later. Tunnels between VIMS devices already agree their keys with ML-KEM-1024 as well as X25519, so a recording does not fall to a quantum computer that breaks X25519. A pad adds a secret that was never sent in the handshake at all: the tunnel stays closed if any one of X25519, ML-KEM or the pad holds.
- A copied or forged identity key. Once a pad has keyed a tunnel and is required, that device gets no tunnel without it. Someone holding your identity key — or able to forge its signature — still cannot finish the handshake.
- A secret that must not rest on any cipher. A password or recovery phrase can be sealed with pad bytes directly. With a hand-carried pad its secrecy and its integrity do not depend on any problem being hard to compute.
A pad does not protect a device that is already compromised: whatever that device can read, its intruder can read.
How It Got There Is How Strong It Is
A pad is exactly as secret as the way it reached the second device. VIMS records that for every byte and shows it on the pad, on the tunnel and on anything sealed with it.
| Grade | How the bytes arrived | What its secrecy rests on |
|---|---|---|
| carried by hand | Saved as a file and moved to the other device yourself. | Nothing computational. No network ever saw it. |
| sent over a tunnel | Sent inside a post-quantum tunnel between your own devices. | That tunnel's key agreement (X25519 + ML-KEM-1024). |
| refilled | New bytes sealed under a one-time key drawn from the pad. | AES-256 and the pad it was sealed under — never better than that pad. |
A pad that started hand-carried keeps that grade for its original bytes. Bytes added by refills are graded refilled, and a pad that was sent over a tunnel never rises above that.
What Happens in a Tunnel
When two devices that share a pad connect, each draws a fresh 32-byte slice from its own lane and tells the other which bytes it used — an offset, never the bytes. Both mix the two slices into the tunnel's keys:
X25519 + ML-KEM-1024 (both directions) + pad slice A + pad slice B
→ HKDF-SHA-384, salted with a hash of the whole handshake
→ AES-256-GCM, each direction re-keyed every 2^20 frames
The receiving side spends its copy of a slice only when the handshake proves the other side really held it, so someone naming slices they do not have costs you nothing. Slices may arrive out of order; a gap is given up only after 32 later ones.
A device that starts handshakes it never finishes could drain a pad, so a side stops offering after 4 unconfirmed offers in 10 minutes; the other side's offer still keys the tunnel meanwhile.
Requiring a Pad
Each pad has Require this pad. It is on by default and takes effect from the first tunnel the pad keys — a pad the other device has not imported yet must not lock the two apart.
From then on that device gets no tunnel to this computer without the pad. If the pad runs out, tunnels wait for a refill; they never fall back to going without.
Two settings under Tunnels to this computer apply to every device:
- Post-quantum key agreement — with every device that supports it (default), required, or off.
- Accept my identity only from devices that share a pad with this computer — your identity key alone then opens nothing here.
Both ask before tightening, and say how many tunnels they closed. They are changed only at the machine itself, never over a tunnel. A daemon started with VIMS_VIMSLINK_PQ (prefer, require, off) or VIMS_VIMSLINK_PAD_ONLY (1, 0) fixes the setting, and the page shows it as fixed.
Sealing a Secret
Seal a secret with a pad encrypts a password or recovery phrase for the other device. The sealed text can travel any way you like; only the device holding the pad can open it, and only once.
The secret is XORed with pad bytes — a true one-time pad — and authenticated with a Poly1305 key that is itself 32 bytes of pad used for that one envelope. Sealing costs 32 bytes plus one pad byte per byte of secret, so an envelope holds 1 byte to 64 KiB: pads are for secrets, not traffic.
Only hand-carried pad (on by default) refuses to spend bytes that ever crossed a network or arrived as a refill. With it on, neither the secrecy nor the integrity of the envelope rests on a cipher. The opened secret says which grade of pad sealed it.
Refills
A pad made with refills on has a peer-to-peer drive of its own. When either direction falls below a quarter of what it started with, the device that created the pad generates new bytes — as many as the pad started with — seals them under a one-time key drawn from the pad, and leaves them on that drive. The other device installs them when it is next online. The two never need to be online together.
The creator keeps 128 bytes of its lane in reserve that only refill keys may spend, so however dry a pad runs there is a key to seal the next refill under. A tunnel that spends from a low pad triggers the check at once; otherwise it runs every 5 minutes.
The key that sealed a refill is erased at both ends once used. The sealed blocks stay in the drive's history forever, and stay closed to someone who takes a device later.
How Far Pads Scale
Pads are pairwise. Devices that must all reach each other need a pad for every pair:
| Devices | Pads in all | Pads on each device |
|---|---|---|
| 5 | 10 | 4 |
| 10 | 45 | 9 |
| 20 | 190 | 19 |
| 50 | 1,225 | 49 |
| 100 | 4,950 | 99 |
| 500 | 124,750 | 499 |
| 1,000 | 499,500 | 999 |
The software is not what runs out. Measured on one computer holding 999 pads (a mesh of 1,000): the vault opens in about half a second, a session key takes about 10 ms, and publishing a refill for every pad takes about a minute. On a local test network, asking 300 refill drives for news takes about 13 seconds the first time and under a second after, whether or not the other device is online. A 1 MiB pad costs 1 MiB of disk on each device until its first refill.
Carrying is what runs out. Every hand-carried pad is one file moved and one import. Ten devices is 45 trips; twenty is 190. So:
- Up to about ten devices: carry every pad. Everything is hand-carried grade.
- More, with one trusted machine: give every device one hand-carried pad with a hub — 100 devices, 99 pads, one trip each. The hub holds every pad and is the machine to protect.
- More, all reaching each other: send pads over the tunnel with Provision all, once on each device. That is tunnel grade, and carried pads can be kept for the links that matter most.
Retiring a device means removing its pad on every device it shared one with: Revoke pads removes them here, and the other device keeps its copy until removed there.
Backups, Restores and Recovery
Pads live in ~/.vims/padvault, one folder per pad. Never back that folder up, sync it, or copy it to another machine. A copy that comes back later still holds bytes the live pad has since spent.
What a restore costs depends on what came back:
- The record is older than the bytes (a synced or restored state file): VIMS sees it. That pad is marked unusable — refused for tunnels, sealing and refills — and Security → Pads says so. It still counts as required, so its device stays locked out rather than quietly connecting without a pad. Your other pads are untouched. Remove it on both devices and share a new one.
- The whole machine came back (a disk image, a VM snapshot): the pad and its record agree, and that machine cannot tell. For tunnels the other device can — it has already spent the slice and refuses it, so no tunnel is keyed twice. A sealed secret is checked by nobody before it leaves: sealing on a restored machine reuses pad bytes.
After restoring any machine from an image or snapshot, remove every pad on it and on the devices it shared them with, and share new ones before using it.
Retiring or losing a device: on every other device, Revoke pads for it. Revoking lifts that device's pin, so if it was lost rather than retired also turn on Accept my identity only from devices that share a pad: the lost device then has neither a pad nor a way in with your identity key alone.
See also: One-Time Pads: Sealing a Secret
The Pad Activity Log
Activity on the Pads page lists everything done with pads across your devices, newest first: created, imported, first used, required or not, refilled, sealed, opened, removed, and every policy change. It records ids, sizes and grades — never pad bytes or secrets.
Each device keeps its own log in ~/.vims/padvault and publishes it, signed with your identity, to your other devices. An entry from another device names it. Records that are not signed by you, or that claim to come from a different device than the one publishing them, are refused.
See also: Security Center: The Audit Log
Limits
- Not bulk encryption. A true pad spends one key byte per byte of message. VIMS uses pads for session keys and small sealed secrets; tunnel traffic is AES-256-GCM.
- Not a shortcut for a mesh. Every pair of devices needs its own pad.
- Desktop devices only. Browsers and phones connect post-quantum and hold no pads, and pads cannot be made, sent, imported or removed from a browser: a web page is refused, and so is anything arriving over a tunnel. A tunnel is opened with your identity key, which is exactly what a pad must not depend on.
- Not for a compromised device. A pad protects the link between two devices, not either end.
- Managed by you, not by agents. No assistant, agent or MCP tool can create, import, seal, open, refill, change or remove a pad, in any approval mode. An agent at the machine can read which devices have pads and the activity log — never pad bytes.
- Not independently certified. The design uses standard parts — ML-KEM-1024 (FIPS 203), HKDF-SHA-384, AES-256-GCM, Poly1305 — but VIMS's implementation has not been through a formal validation.
API Reference
Every route is under /api/vimslink/pads on the local daemon and answers only to you at the machine.
| Method | Path | Does |
|---|---|---|
| GET | /api/vimslink/pads | Pads and the tunnel policy. |
| POST | /api/vimslink/pads | Create. delivery: "file" returns the bundle once; "link" sends it to one of your devices. |
| POST | /api/vimslink/pads/import | Import a carried bundle. |
| POST | /api/vimslink/pads/provision | Send a pad to every device of yours that can take one. |
| POST | /api/vimslink/pads/revoke | Remove every pad shared with one device. |
| PUT | /api/vimslink/pads/{id} | Require the pad, or stop requiring it. |
| DELETE | /api/vimslink/pads/{id} | Wipe and remove a pad. |
| POST | /api/vimslink/pads/{id}/refill | Publish a refill (creator) or pick up published ones. |
| POST | /api/vimslink/pads/{id}/seal | Seal up to 64 KiB. |
| POST | /api/vimslink/pads/open | Open a sealed envelope, once. |
| PUT | /api/vimslink/pads/policy | Post-quantum setting and pad-only. |
| GET | /api/vimslink/pads/audit | The activity log, local and from your other devices. |
A pad in a response carries send_remaining and recv_remaining (unspent bytes per direction), out_of_band_remaining, provenance, enforce, armed (it has keyed a tunnel), epoch (refills so far), low, and broken when it can no longer be used.
A sealed envelope is "VPS1", the 16-byte pad id, an 8-byte offset, a 4-byte length, the ciphertext and a 16-byte tag.
curl -s 127.0.0.1:8089/api/vimslink/pads | jq '.policy, (.pads[] | {peer: .peer.name, provenance, armed, low, broken})'curl -sX POST 127.0.0.1:8089/api/vimslink/pads \
-H 'Content-Type: application/json' \
-d '{"device": "<tunnel key>", "size": 1048576, "delivery": "file"}' \
| jq -r .bundle > laptop.vimspadThe response's bundle is the pad: it is returned once and not kept.
curl -sX POST 127.0.0.1:8089/api/vimslink/pads/$PAD/seal \
-H 'Content-Type: application/json' \
-d "{\"plaintext\": \"$(printf %s "$SECRET" | base64 -w0)\", \"out_of_band_only\": true}" | jq -r .envelopecurl -sX PUT 127.0.0.1:8089/api/vimslink/pads/policy \
-H 'Content-Type: application/json' -d '{"pq": "require"}'