01 / Commit–reveal spec
What gets hashed, byte for byte.
Before any order, the backend publishes one 32-byte hash to ProofRegistry on Elysium. After the position closes it publishes the preimage. Anyone can recompute the hash; if one byte differs, the trade is marked FAILED forever.
1.1Encoding
The commitment is standard Solidity ABI encoding (abi.encode, not abi.encodePacked) of seven fields in this fixed order, hashed with keccak256. Using padded ABI encoding removes the ambiguity that packed encoding has with two adjacent dynamic strings.
commitHash = keccak256(
abi.encode(
bytes32 tradeId,
string thesisJson,
string pair, // "BTC" | "ETH" | "HYPE" | "SOL"
uint8 side, // 0 = LONG, 1 = SHORT
uint256 sizeUsd, // notional in USD, 1e6 precision
uint256 entryTarget, // limit / trigger price, 1e8 precision
bytes32 salt // 32 random bytes, never reused
)
)1.2Fields & precision
| Field | ABI type | Encoding rule | Example |
|---|---|---|---|
| tradeId | bytes32 | Unique per trade. Also the ProofRegistry storage key. | 0xa41c…3d |
| thesisJson | string | UTF-8 JSON exactly as committed. No re-serialisation, no whitespace normalisation. | {"v":1,…} |
| pair | string | Upper-case base asset as listed on Hyperliquid. | "BTC" |
| side | uint8 | 0 = LONG, 1 = SHORT. Any other value reverts. | 0 |
| sizeUsd | uint256 | Notional USD × 1e6 (USDC precision), rounded half-up. | 25000000000 |
| entryTarget | uint256 | Limit or trigger price × 1e8, rounded half-up. | 6741250000000 |
| salt | bytes32 | 32 bytes from a CSPRNG. Unique per trade, never derived from tradeId. | 0x9b4e…01e1 |
sizeUsd = round(notionalUsd * 1_000_000) // $25,000 -> 25000000000
entryTarget = round(price * 100_000_000) // 67,412.5 -> 6741250000000
// HYPE 31.0425 -> 3104250000
side = side === "LONG" ? 0 : 1
tradeId = keccak256(toHex(`${deskId}:${nonce}`)) // any unique bytes32
salt = crypto.getRandomValues(new Uint8Array(32))1.3Thesis JSON
The thesis is the full council record at decision time: every vote, its confidence and reasoning, plus the stop, targets and the condition that would invalidate the idea. It is committed as one string, so field order and whitespace are part of the hash. Version v: 1 looks like this:
{
"v": 1,
"pair": "BTC",
"side": "LONG",
"leverage": 3,
"stopLoss": 65390.0,
"takeProfit": [68900.0, 70250.0],
"invalidation": "4h close below 65,800 range low",
"votes": [
{ "role": "ORDERFLOW", "stance": "LONG", "confidence": 0.72, "note": "funding flipped negative while OI rose; shorts paying" },
{ "role": "TECHNICAL", "stance": "LONG", "confidence": 0.64, "note": "reclaimed 67.1k range mid on rising volume" },
{ "role": "MACRO", "stance": "FLAT", "confidence": 0.41, "note": "CPI in 30h; no edge either way" },
{ "role": "RISK", "stance": "LONG", "confidence": 1.0, "note": "3x, SL set, $25k cap, DD 0.8% of 4%" }
],
"createdAt": "2026-11-27T14:02:09Z"
}Note that pair and side appear both inside the thesis and as separate fields. The separate fields are what the contract and the ledger index on; the copy inside the thesis is for humans. A reveal where they disagree still hashes correctly, so the ledger flags it as inconsistent.
1.4Verify in TypeScript (viem)
The shared package exports COMMIT_ABI_PARAMS and verifyCommit(). The snippet below does the same thing by hand and then checks the API's claimed hash against the chain.
import { createPublicClient, http, encodeAbiParameters, keccak256 } from "viem";
import { elysium, COMMIT_ABI_PARAMS } from "@desk/shared";
const res = await fetch("https://api.quietdesk.xyz/api/trades/0xa41c…3d");
const t = await res.json(); // TradeRecord, status REVEALED or VERIFIED
const recomputed = keccak256(
encodeAbiParameters(COMMIT_ABI_PARAMS, [
t.tradeId,
t.thesisJson, // exact string, byte for byte
t.pair,
t.side === "LONG" ? 0 : 1,
BigInt(t.sizeUsd), // e.g. "25000000000" = $25,000.000000
BigInt(t.entryTarget), // e.g. "6741250000000" = 67,412.50000000
t.salt,
]),
);
console.log(recomputed === t.commitHash.toLowerCase()); // true
// Don't trust the API either — read the hash straight from the chain:
const client = createPublicClient({ chain: elysium(), transport: http() });
const onchain = await client.readContract({
address: process.env.NEXT_PUBLIC_PROOF_REGISTRY as `0x${string}`,
abi: [{ type: "function", name: "getTrade", stateMutability: "view",
inputs: [{ name: "tradeId", type: "bytes32" }],
outputs: [{ name: "", type: "tuple", components: [
{ name: "commitHash", type: "bytes32" },
{ name: "committedAt", type: "uint64" },
{ name: "revealedAt", type: "uint64" },
{ name: "verified", type: "bool" },
{ name: "pnlUsd", type: "int256" } ] }] }],
functionName: "getTrade",
args: [t.tradeId],
});
console.log(onchain.commitHash === recomputed);1.5Verify in Solidity
ProofRegistry exposes the same function as a view (computeCommit) so wallets and other contracts can check a preimage without sending a transaction.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
function computeCommit(
bytes32 tradeId,
string calldata thesisJson,
string calldata pair,
uint8 side,
uint256 sizeUsd,
uint256 entryTarget,
bytes32 salt
) pure returns (bytes32) {
require(side <= 1, "side");
return keccak256(abi.encode(tradeId, thesisJson, pair, side, sizeUsd, entryTarget, salt));
}
// Inside ProofRegistry.reveal(...):
// Trade storage t = trades[tradeId];
// require(t.committedAt != 0 && t.revealedAt == 0, "state");
// bool ok = computeCommit(tradeId, thesisJson, pair, side, sizeUsd, entryTarget, salt) == t.commitHash;
// t.revealedAt = uint64(block.timestamp);
// t.verified = ok;
// emit TradeRevealed(tradeId, ok, pnlUsd);1.6Threat model
Front-running and copy-trading
The commit reveals nothing usable: no pair, side, size or price, only a hash. Brute-forcing the preimage is impossible because the salt adds 256 bits of entropy, and the thesis string alone is unguessable. Orders themselves go out from addresses not linked to the desk (see Private execution).
Selective disclosure
A desk that only shows winners is the default failure mode of trading track records. Here every trade must exist on-chain before it is opened, with a block timestamp. Losing trades cannot be hidden without leaving a permanently SEALED commit on the ledger, and the ledger sorts unrevealed commits by age. The desk policy is to reveal every commit within 24 hours of close.
Hindsight editing
Changing anything after the fact — a tighter stop, a better entry, a smaller size, a sharper-sounding thesis — changes the hash. The contract rejects nothing; it records verified = false, which is worse for the desk than a loss.
Why the salt
- Hiding. Without a salt, the low-entropy fields (4 pairs × 2 sides × a few sizes × nearby prices) could be enumerated if the thesis ever leaked or was templated. A random 32-byte salt makes the commitment computationally hiding.
- Unlinkability. Two trades with similar theses produce unrelated hashes, so commits cannot be clustered.
- Binding stays intact. keccak256 is collision resistant; once committed, the desk cannot find a second preimage, salt or not.
Reveal checklist
- Fetch the trade and confirm
statusisVERIFIED. - Recompute the hash locally from the revealed fields.
- Read
getTrade(tradeId)on Elysium and compare. - Check
committedAtis earlier than the first fill time in the receipt. - Optionally match the fill receipt against Hyperliquid's public fills for the revealed sub-account.