Unlock Encrypted Data with a Fiber Payment
Run a Buyer and Seller as independent browser nodes, pay a real Testnet Invoice, and use the revealed payment preimage to decrypt the Seller's result.
Keep Buyer and Seller identities separate
Buyer Node A and Seller Node C run locally with separate keys and stores. Browser nodes cannot accept inbound connections, so both connect to Bottle for routing; Bottle is infrastructure, not a third application role.
Generate a fresh key inside the browser
Seller Node C creates a random 256-bit key and 96-bit IV, then encrypts the result with authenticated AES-GCM. The ciphertext can be delivered before payment because it is unreadable without the key.
lib/crypto.ts · lines 1–11Use the AES key as the payment preimage
Seller Node C creates a regular Invoice with payment_preimage: K and hash_algorithm: 'sha256'. Fiber places only sha256(K) in the Invoice and keeps K secret until settlement.
Copy ciphertext and Invoice, never the key
The portable JSON contains the ciphertext, IV, payment hash, encoded Invoice, and a public Bottle→Seller last-hop hint. Copying it between the two panes makes the application boundary explicit without adding a coordination server.
lib/offer.ts · lines 1–22Wait for Fiber to return the preimage
Buyer Node A combines its direct channel to Bottle with the offer's Bottle→Seller last-hop hint. This builds one ordinary A → Bottle → C payment without waiting for gossip or asking Bottle to start a separate trampoline payment. Only a successful result exposes payment_preimage; failure leaves the ciphertext locked.
Import the revealed preimage as the AES key
Before payment, a trial decryption fails AES-GCM authentication. After payment, the exact preimage returned by Fiber authenticates and decrypts the original result in Buyer Node A's browser.
lib/crypto.ts · lines 14–21Payment proves key release, not result quality
This construction binds settlement to disclosure of a particular key. AES-GCM proves that the key matches the ciphertext, but it cannot prove that the Seller's plaintext is useful or truthful. Production markets still need reputation, previews, or dispute rules.
Encryption, offer transfer, Invoice creation, payment polling, and decryption all run in the browser. The demo still uses public Fiber and CKB Testnet infrastructure.