Private Boxes
Advanced

Private Boxes

Keep your band and trailing stop off chain until the Box collapses, so nobody can push the price into them.

A Private Box works like any other Box, except that its band b and trailing stop t are not written on chain when it opens. The chain stores only a hash of them. The Box becomes a normal public position the moment it collapses.

What is hidden and what is not

Hidden until collapseNot hidden
Band b, so the collapse prices E·(1±b)Trader address
Trailing stop tSize N, leverage, market, open time
Direction (unknown by design until collapse anyway)Premium rate declared and budget
—Everything after collapse. It becomes a normal public position.

Why

Public stop levels get hunted. If everyone can read where a position collapses or stops out, someone with enough size can push the price into that level on purpose. A Private Box's trigger levels are not on chain, so there is nothing to aim at.

How it works

  1. Commit. You pick b and t in the app. Your browser makes a random 32-byte salt and computes a commitment to (you, market, b, t, salt). Only the commitment goes on chain.
  2. Encrypt to the keeper key. The browser encrypts (b, t, salt) to the keeper public key published on chain as privateKeeperKey, and sends the ciphertext with the open. It is emitted in an event, not stored.
  3. Lock the premium rate. The engine can't price the Box without b, so you declare the hourly premium rate yourself. The app computes it with the same formula as a public Box. The engine stores σ1h and utilisation at open, so the rate can be checked later against the same inputs. You pay the declared rate for as long as the Box is open.
  4. Void rule. When b is revealed, the engine recomputes the rate. If you declared less than that (allowing 1 wei rounding), anyone can void the Box with voidPrivate: you get your margin back minus fees, and the premium paid so far is forfeited.
  5. Keeper watch. The keeper decrypts the ciphertext, checks it against the commitment and the declared rate, and watches the band off chain.
  6. Collapse. When the oracle mark crosses the band, the keeper calls collapsePrivate with b, t and the salt. The engine checks the commitment, checks that the current mark is beyond E·(1±b), and collapses at that mark. From then on it is a normal Box with a public trailing stop.
  7. Trader reveal. You can make the Box public at any time with revealPrivate. It keeps its locked rate.

Exact formulas and encodings

Commitment (on chain)
commit = keccak256(abi.encode(
  address trader, uint32 coin, uint32 bandBps, uint32 trailBps, bytes32 salt))
Premium rate check (on reveal, collapse or void)
computed = premiumPerHour(N, b, σ1h at open, util at open)
valid    ⇔ ratePerHour ≥ computed − 1 wei
ECIES payload
plaintext  = abi.encode(uint32 bandBps, uint32 trailBps, bytes32 salt)
eph        = random secp256k1 key
shared     = ECDH(eph, privateKeeperKey)
key        = HKDF-SHA256(shared, info = "schrodinger-private-v1")
ciphertext = ephPub (65 bytes, uncompressed) ‖ iv (12) ‖ ct ‖ tag (16)
             AES-256-GCM(key, iv, plaintext)
Engine calls
openPrivate(uint32 coin, uint256 size, uint16 lev, bytes32 commit,
            uint256 ratePerHour, uint256 budget, bytes ciphertext) → id
collapsePrivate(uint256 id, uint32 bandBps, uint32 trailBps, bytes32 salt)
revealPrivate(uint256 id, uint32 bandBps, uint32 trailBps, bytes32 salt)
voidPrivate(uint256 id, uint32 bandBps, uint32 trailBps, bytes32 salt)

collapsePrivate reverts unless the mark is beyond the committed band. Anyone holding the preimage can call it.

Trust and limits

  • Delay. A keeper could hold back a collapse. The Box then stays un-collapsed and keeps paying the agreed premium. Any keeper, or you, can collapse it. A late collapse costs you at most the move between the true cross and the actual collapse. Keepers are paid a reward per collapse, so they are paid to be fast.
  • Losing your salt. Without b, t and the salt you can't reveal or collapse the Box yourself. The keepers can still collapse it, because they can decrypt the ciphertext.
  • Mispriced rate. Declaring a rate below the formula voids the Box and forfeits the premium paid. Use the rate the app computes.

Roadmap, to remove the keeper trust:

  1. Threshold decryption, so no single keeper can read a trigger.
  2. A zero-knowledge collapse proof (“the mark is outside the committed band”) that reveals nothing, even to keepers.

Gas

CallCost vs a public Box
openPrivate429,243 gas, vs 379,873 for a standard open (+49,370: three extra storage slots and the 189-byte ciphertext event; the ciphertext is not stored)
collapsePrivate223,850 gas, vs 264,126 for a standard collapse through poke (one keccak to check the commit)