文档 · 游戏规则
可证明公平
杀手房间由预先承诺的服务器种子、所有承诺值的根以及一个未来的 BSC 区块哈希共同决定。这里给出精确公式和自行验证的方法。
三个输入
| 输入 | 何时确定 | 谁知道 |
|---|---|---|
serverSeed(32 个随机字节) | 开局时生成;开局即公布其哈希 seedHash | 只有服务器,直到结算后公开 |
commitmentsRoot | 加入阶段结束时冻结 | 所有人(只包含承诺值,不包含房间) |
| 信标区块哈希 | 揭示结束时选定区块号(当时最新区块 + 3),出块后才有哈希 | 出块前没有任何人知道 |
信标区块是在揭示阶段关闭之后才选定的:此时中继已经完成自动揭示,服务器不再接受任何揭示。因此任何人(包括运营方和玩家)都无法先看到信标、再决定是否揭示。
精确公式
text
seedHash = keccak256(serverSeed) // published at round open
commitmentsRoot = keccak256(concat(commitments sorted ascending, 32 bytes each)) // frozen at JOIN close; empty -> keccak256(0x)
beaconBlock = latest BSC block number at REVEAL close + 3 // chosen after the reveal closes
killerRoom = uint256(keccak256(abi.encode(
bytes32 serverSeed, bytes32 commitmentsRoot, bytes32 beaconBlockHash, uint256 roundId
))) % 6结果 0–5 对应界面中的房间 01–06。
为什么谁都无法操纵
- 运营方在承诺冻结时已经锁定了
serverSeed(seedHash早已公开),而此时信标区块还不存在,所以无法挑选一个对自己有利的结果。 - 玩家不知道
serverSeed,即使能预测区块哈希也算不出结果。 - 事后篡改会被发现:公开的
serverSeed必须哈希到开局时的seedHash,区块哈希可以从任何 BSC 节点独立获取。
在网站内验证
在 竞技场 点击“验证公平性”(当前轮或上一轮结果卡片上),或点击历史条中任一杀手房间小方块,都会打开验证抽屉。它读取 GET /api/rounds/:id/fairness,在你的浏览器中重新计算 keccak256(serverSeed) 与杀手房间,并与公布值对比,显示“Verified”或“Mismatch”。
完全自行验证
- 调用
GET https://backend-production-2085d74c.up.railway.app/api/rounds/<id>/fairness,得到seedHash、serverSeed、commitments[]、commitmentsRoot、beacon(含latestAtRevealClose、offset: 3、blockNumber、blockHash)和killerRoom。 - 检查
keccak256(serverSeed) == seedHash。 - 把
commitments按 uint256 升序排序、拼接后做 keccak256,应等于commitmentsRoot。 - 检查
blockNumber == latestAtRevealClose + 3,并从任意 BSC 主网 RPC(eth_getBlockByNumber)获取该区块哈希。 - 按上面的公式重新计算
killerRoom。
verify.mjs · viem
// verify.mjs — node verify.mjs <roundId> (npm i viem)
import { createPublicClient, http, keccak256, encodeAbiParameters, concat } from "viem";
import { bsc } from "viem/chains";
const API = "https://backend-production-2085d74c.up.railway.app";
const roundId = process.argv[2];
const f = await (await fetch(`${API}/api/rounds/${roundId}/fairness`)).json();
// 1. the seed revealed after settlement must hash to the seedHash published at open
const seedOk = keccak256(f.serverSeed) === f.seedHash.toLowerCase();
// 2. rebuild commitmentsRoot from the published commitments
const sorted = f.commitments.map((c) => c.toLowerCase()).sort((a, b) => (BigInt(a) < BigInt(b) ? -1 : 1));
const root = keccak256(sorted.length ? concat(sorted) : "0x");
// 3. fetch the beacon block hash yourself from any BSC RPC
const client = createPublicClient({ chain: bsc, transport: http("https://bsc-dataseed.bnbchain.org") });
const block = await client.getBlock({ blockNumber: BigInt(f.beacon.blockNumber) });
// 4. recompute the killer room
const h = keccak256(encodeAbiParameters(
[{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "uint256" }],
[f.serverSeed, root, block.hash, BigInt(f.roundId)],
));
const killer = Number(BigInt(h) % 6n);
console.log({ seedOk, rootOk: root === f.commitmentsRoot, blockOk: block.hash === f.beacon.blockHash,
killer, published: f.killerRoom, verified: seedOk && killer === f.killerRoom });ethers v6
// ethers v6 equivalent of step 4
import { AbiCoder, keccak256 } from "ethers";
const killer = Number(BigInt(keccak256(AbiCoder.defaultAbiCoder().encode(
["bytes32", "bytes32", "bytes32", "uint256"], [serverSeed, commitmentsRoot, blockHash, roundId],
))) % 6n);一个真实的轮次
主网闪电轮 #4000004(无人参与,因此承诺列表为空)。我们用上面的脚本复核:种子、根、区块哈希全部一致,重新计算的杀手房间为 5(界面中的 06),与公布值相同。
| 字段 | 值 |
|---|---|
| seedHash | 0x731014d888af4384710e57220ca89744d99f410db8b4ef958c7aca42df54f159 |
| serverSeed | 0x7f372db74cd65a31306000baf2397093ab216d3945f8d17d269344a2af76d16b |
| commitmentsRoot | 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 |
| latestAtRevealClose | 135850901 |
| beacon blockNumber | 135850904 |
| beacon blockHash | 0x76d23b8fd356d43dee45673739d8c3bfe48a36e41775f5813670b5e07531f9d8 |
| killerRoom | 5 |
边界情况
- 信标区块哈希在 60 秒内取不到时,该轮取消并全额退款,不会使用任何替代随机源。
- 演示(sim)模式使用模拟信标,验证接口会明确标注;实盘的
beacon.source为BSC mainnet block hash。
最后核对:2026-11-26 · 依据线上代码与 /api/config