Protocol walkthrough
This is a narrative companion to the specification. If you want the normative rules, read the spec. If you want to understand why and how, read this.
The problemLink to this section
"I want to send Alice an encrypted message, and I want to prove to her it's from me, and I want to know that only she — specifically, the holder of her Bitcoin address — can open it."
That is the user story OC Lock serves. Every Bitcoin-native attempt at solving it has failed on UX:
- PGP — works, but requires key management mastery.
- LOCK v1 (adaptor signatures) — elegant on paper; no browser-compatible WASM library ever shipped.
- LOCK v1.1 (Proof-of-Access) — dropped adaptor signatures but kept every vault creation and unlock as a Bitcoin transaction.
v2 makes the boring choice: treat Bitcoin as an identity system, not an access-control oracle. The chain proves who owns what address; the encryption is plain old authenticated public-key crypto.
The mental modelLink to this section
Every user does exactly one "hard" thing, only once: sign a BIP-322 message that binds a browser-generated X25519 key to their Bitcoin address. After that, sending and receiving are one click.
Flow 1 — Alice sends Bob a message (identity mode)Link to this section
Bob's one-time setup:
-
Bob visits the app.
-
He enters his Bitcoin address.
-
The browser generates an X25519 keypair and derives the device's Nostr key from it. The secret stays in IndexedDB.
-
The browser builds the binding statement:
Code oc-lock:device-bind:v3 address: bc1qbob… device_pk: 7d2f… nostr_pk: 3c9a… device_id: a8b4… created_at: 2026-04-22T14:03:11Z -
Bob's wallet signs it with BIP-322 (one prompt, one click).
-
The browser publishes a Nostr kind-30078 event, signed with that Nostr key, containing the statement, pubkey, and signature. A reader refuses a record whose Nostr author is not the
nostr_pkit signed. Thedtag isoc-lock:device:bc1qbob…— anyone can find it by Bitcoin address.
Bob is now addressable.
Alice sends:
- Alice types Bob's address.
- The app fetches Bob's device record from Nostr and verifies the binding
BIP-322 signature against
bc1qbob…. - Alice writes her message.
- The app generates a random
content_key, encrypts the payload with AES-256-GCM, then for each recipient device: generates an ephemeral X25519 keypair, derivesshared = ECDH(eph_sk, device_pk), wraps the content key underHKDF(shared, salt=nonce_ct). - Alice signs the envelope with her wallet (BIP-322 over the envelope id).
- The envelope is a JSON object. Alice copies the share link.
Bob receives:
- Bob opens the link.
- The app recomputes the envelope id and verifies Alice's signature.
- Finds Bob's
device_idinrecipients[]. shared = X25519(device_sk, eph_pk)→ unwrap content key → decrypt payload.- Plaintext shown. < 3 seconds.
No Bitcoin transaction was made. The chain proved only that Bob controls his address and Alice controls hers.
Flow 2 — Alice sells Bob a file (payment mode)Link to this section
Sometimes you want Bitcoin to do more than identity: you want "10k sats gets you this." Payment mode is how.
Payment mode is part of the protocol, and @orangecheck/lock-core reads and
writes the payment block. No public payment relay runs today, and lock.ochk.io
does not create payment-gated vaults; its playground only displays a payment
block when an envelope carries one.
Alice runs (or trusts) a relay: a minimal web service that holds content keys on behalf of vaults and releases them upon observing confirmed payments. The relay has a long-lived X25519 device key. Its URL and pubkey are public.
Alice creates a payment-gated vault:
- Chooses payment-gated. Sets amount = 10,000 sats, payment address = her
bc1qalice…, relay URL, confirmations = 1. - The app wraps the content key for the relay's device key.
- Alice signs the envelope with her wallet and shares the link.
Bob unlocks:
- Opens the link. The app shows price + relay URL.
- Bob pays 10k sats to
bc1qalice…. - Bob authenticates to the relay via orangecheck sign-in.
- App requests release:
POST /release { envelope_id, unlock_address, tx_proof }, wheretx_proofnames the confirmed payment. - Relay verifies the tx (amount, confirmations, recipient), unwraps the content key with its own device secret, re-wraps it for Bob's device key fetched from Nostr, returns the new recipient entry.
- Bob's app decrypts normally.
The relay is a trust anchor. Its URL is always visible, anyone can run one, and future versions may replace it with DLC oracles or BIP-118 covenants.
Flow 3 — Multi-device and rotationLink to this section
Bob has a laptop and a phone. Each browser has its own device key. On first
sign-in, each publishes a separate Nostr record with its own device_id.
Senders fetching Bob's records get a list; they encrypt once per live device.
To rotate: Bob generates a new device secret under a new device_id, signs
a new binding statement and publishes it, then revokes the old device_id. Old
envelopes addressed to the old device_pk are unreadable from the new device.
To revoke (laptop stolen): Bob's wallet signs a revocation of the laptop's
device_id, and he publishes it from his phone or any client, under a fresh
Nostr key. He does not need the laptop. A sender that sees the revocation on any
relay stops sealing to the laptop, even while another relay still serves its
record. What the laptop already received stays readable to whoever holds it.
Flow 4 — Self-vault (password manager pattern)Link to this section
Alice can seal a vault to herself. Sender and recipient are both her Bitcoin
address. The envelope's only recipients[] entry is her own device record. She
can decrypt from any of her devices. The "password" is her Bitcoin wallet.
Layered with orangecheckLink to this section
OC Lock depends on orangecheck in two explicit places:
- Sybil-gated inbox (optional). Call
@orangecheck/sdk#checkon the recipient's address before encrypting. Require minimum sats / minimum days. - Shared sign-in. A payment-mode relay (Flow 2) uses orangecheck's sign-in-with-bitcoin flow verbatim: BIP-322 challenge, signed response, JWT session. Same wallet signs binding statements and OC challenges.
Every OC Lock device record is structurally similar to an orangecheck attestation: a canonical UTF-8 message committing to a Bitcoin address, BIP-322-signed. Attestation ids (SHA-256 of canonical message) are computable over the binding statement for stable, content-addressable discovery.
Anti-patterns we rejectedLink to this section
- Browser-wallet ECDH. Bitcoin wallets don't expose ECDH. Nostr wallets do (NIP-04/44), but we don't want to require a Nostr-native wallet. The device-key pattern sidesteps this.
- Deriving decryption keys from BIP-322 signatures. Schnorr BIP-340 and RFC-6979 ECDSA are deterministic, so a fixed-message signature could seed a KDF. But wallet implementations vary. We don't rely on it.
- Full Signal-protocol double ratchet. Overkill for one-shot message drops; the state-sync cost conflicts with "no server" default.
- Server-mandatory storage. Every envelope is self-contained. Export to a QR code, paper, USB, or IPFS.
Where to go nextLink to this section
- Specification — byte-level rules.
- Why v2 — the v1 postmortem.
- FAQ — common questions.