Mines에서 입증된 공정성이 작동하는 방식
Cloudbet에서 Mines를 플레이하는 방법과, 매 라운드의 지뢰 배치가 입증된 공정성을 갖추고 있는지 확인하는 방법을 알아보세요.
Mines 플레이 방법
Cloudbet의 모든 Mines 라운드는 서버 시드, 클라이언트 시드, 논스, SHA3-256/SHAKE256이라는 동일한 입증된 공정성 기반을 사용하며, 이에 대한 자세한 내용은 입증된 공정성 작동 방식 허브 페이지에서 다룹니다. 이 페이지에서는 Mines에 특화된 부분, 즉 그 무작위 숫자 시퀀스가 어떻게 실제로 플레이하는 지뢰 그리드로 바뀌는지를 다룹니다.
무작위 숫자를 지뢰 그리드로 바꾸는 과정
게임 시작 시 배치할 지뢰 개수를 선택하며, 이 숫자를 N이라고 부릅니다. 5×5 Mines 그리드는 각각 1부터 시작하는 고유한 인덱스를 가진 25개의 위치로 이루어진 한 줄로 펼쳐볼 수 있습니다.

무작위 시퀀스(입증된 공정성 페이지에서 설명한 것과 동일한 방식으로 생성됨)에서 숫자 하나를 추출해 첫 번째 지뢰의 위치를 결정합니다.

지뢰를 더 배치해야 한다면 또 다른 무작위 숫자를 추출해 이 과정을 반복하지만, 이제는 남은 24개의 위치 중에서만 선택합니다.

이 과정은 모든 지뢰가 배치될 때까지 반복됩니다. 전체 그리드는 이렇게 재구성된 다음 라운드가 끝날 때까지 비밀로 유지됩니다.

기술적 세부사항: 각 지뢰 위치 선택하기
각 선택 이전에, 선택 가능한 남은 지뢰 없는 위치의 수를 P라고 합니다. P는 25에서 시작해 지뢰가 하나씩 배치될 때마다 1씩 줄어듭니다.
각 지뢰마다 SHAKE256 출력에서 무작위 4바이트(32비트) 숫자가 추출되며, 범위는 0에서 4,294,967,295까지입니다. P개의 위치 중에서 공정하게 하나를 선택하기 위해 거부 샘플링을 적용한 다음(입증된 공정성 작동 방식에서 설명하는 일반적인 개념 참고), 그 결과를 P로 나눈 나머지를 구해 배치 인덱스로 삼습니다.
// Pseudo Code
const placementIndex = randomNumber % P;

지뢰가 더 남아 있다면, 선택된 위치는 목록에서 제거되고 P는 1만큼 줄어들며, 이 과정이 반복됩니다.
게임 진행
지뢰로 채워진 최종 그리드는 플레이어가 움직이기 전에 서버에서 생성되어 숨겨지며, 이미 공유된 커밋먼트(Commitment) 덕분에 이후에는 감지되지 않고 변경되거나 조작될 수 없습니다. 선택하는 각 타일은 단순히 이 숨겨진 그리드와 대조됩니다.
독립 검증을 위한 코드
이 프로그램은 Cloudbet의 Mines 구현과 정확히 일치합니다. 서버 시드, 클라이언트 시드, 논스, 지뢰 개수를 입력하고 의존성 하나를 설치한 다음 직접 실행해 게임 결과를 재현해 보세요.
참고: Cloudbet에서 완료된 게임의 서버 시드를 공개하려면 이미 새로운 라운드를 시작한 상태여야 합니다(이는 새로운 시드 쌍으로 교체됩니다).
의존성:
npm install js-sha3
코드:
// If you are running this yourself, then you can input your own data here
// You can then compare:
// 1) Cloudbet's provided Commitment to the Commitment outputted here. This proves that the Server Seed was not altered during gameplay.
// 2) Cloudbet's provided game outcome to the game outcome outputted here. This proves that your game's outcome was determined solely by the pre-game seeds and was not altered afterwards.
let myServerSeed = 'your_server_seed'; // ✍️YOUR_INPUT✍️: Enter your (unhashed) Server Seed here
let myClientSeed = 'your_client_seed'; // ✍️YOUR_INPUT✍️: Enter your Client Seed here
let myNonce = 1; // ✍️YOUR_INPUT✍️: Enter your Nonce here
let myNumberOfMines = 3; // ✍️YOUR_INPUT✍️: Enter your number of mines here
const usingCustomData = false; // Change this to true if you are using your own data
// Load libraries
const crypto = require('crypto');
const { sha3_256, shake256 } = require('js-sha3');
// Step 1: Generate a Server Seed and Commitment
// And generate a Client Seed - either by player input or by the player's browser
function generateServerSeed() {
let seed = crypto.randomBytes(32).toString('hex');
if (usingCustomData) { seed = myServerSeed; }
const commitment = sha3_256(seed);
return { 'serverSeed': seed, 'commitment': commitment };
}
function getClientSeed() {
let seed = crypto.randomBytes(32).toString('hex');
if (usingCustomData) { seed = myClientSeed; }
return seed;
}
// Step 2: Create a Round Signature with SHA3 using a Server Seed, Client Seed, and Nonce
function createRoundSignature(serverSeed, clientSeed, nonce) {
return sha3_256(`${serverSeed}:${clientSeed}:${nonce}`);
}
// Step 3: Create a SHAKE256 stream generator from a Round Signature.
// To simplify this example program, this function doesn't create a stream, but instead a sequence of custom length.
function* createRandomNumberSequence(numbersToGenerate, roundSignature) {
const numOfBytes = 4 * numbersToGenerate; // 4 bytes (32 bits) per random number we generate
const byteStream = shake256.create(8 * numOfBytes); // shaker256 takes bits as input
byteStream.update(roundSignature); // Use the Round Signature to seed the generator
const buf = Buffer.from(byteStream.digest()); // The Buffer class lets us package every 4 bytes into one 32-bit integer
for (let i = 0; i < numbersToGenerate; i++) {
yield buf.readUInt32BE(i * 4); // Read buf in 4-byte steps
}
throw new Error("No more numbers in the random number sequence! Fix: make 'numbersToGenerate' larger.");
}
// Step 4: Generate the mine locations
function pickUniquePositions(mineCount, totalTiles, rng) {
const available = Array.from({ length: totalTiles }, (_, i) => i);
let result = [];
for (let i = 0; i < mineCount; ++i) {
const index = sample(available.length, rng);
result.push(available[index]);
available.splice(index, 1); // Remove chosen position from list of available positions
}
result.sort((a, b) => a - b); // Sort the mine positions from smallest to largest
result = result.map(num => num + 1); // Increment positions by one so that they start with 1, 2, 3, ...
return result;
}
// Rejection sampling for fair results
function sample(P, rng) {
const maxAcceptable = Math.floor(0x100000000 / P) * P;
// Rejection sampling
let rand;
do {
rand = rng.next().value;
} while (rand >= maxAcceptable);
// Modulo operation
const sampled_number = rand % P;
return sampled_number;
}
// Example usage
(function main() {
const gridSize = 25;
let mineCount = 3;
let nonce = 1;
if (usingCustomData) { mineCount = myNumberOfMines; nonce = myNonce; }
const { serverSeed, commitment } = generateServerSeed();
const clientSeed = getClientSeed();
const roundSignature = createRoundSignature(serverSeed, clientSeed, nonce);
const numbersToGenerate = 24 * 2; // There are max. 24 mines, however due to rejection sampling we may need more random numbers
const rng = createRandomNumberSequence(numbersToGenerate, roundSignature);
const minePositions = pickUniquePositions(mineCount, gridSize, rng);
console.log('📝 Commitment (shown before the game):', commitment);
console.log('🔒 Server Seed (revealed after the game):', serverSeed);
console.log('🎲 Client Seed:', clientSeed);
console.log('🔢 Nonce:', nonce);
console.log('🔁 Round Signature (can be verified after the game):', roundSignature);
console.log('💣 Mine Positions (1 = top-left square, 5 = top-right square, 25 = bottom-right square):', minePositions);
})();
지금 Mines에서 여러분의 행운을 시험하세요
실제로 경험하고 싶으신가요? Cloudbet Mines를 플레이하고, 입증된 공정성 계산기로 결과를 검증해 보세요. 몇 초면 충분하며, 기술적인 지식은 전혀 필요하지 않습니다.
전체 과정을 직접 확인하고, 시드를 살펴보고, 도구가 처음부터 결과를 어떻게 재구성하는지 지켜보세요.
