Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Thumbs.db
*.temp
.cache
.parcel-cache
.claude-flow/

# claude-flow runtime (keep config, ignore runtime data)
.claude-flow/data/
Expand Down
5 changes: 2 additions & 3 deletions src/engine/insurance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ export function canPlaceInsurance(dealerUpCard: Card, hand: Hand, balance: numbe
return false;
}

// Must have enough balance for at least the maximum insurance bet
const maxInsuranceBet = getMaxInsuranceBet(hand);
if (balance < maxInsuranceBet) {
// Must have enough balance for at least some insurance bet (any amount > 0)
if (balance <= 0) {
return false;
}

Expand Down
13 changes: 11 additions & 2 deletions src/engine/probablyFair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ export async function verifyShuffleProof(proof: ShuffleProof): Promise<Verificat
versionSupported: false,
};

// Validate seed format first
if (!/^[a-f0-9]{64}$/i.test(proof.seed)) {
return {
valid: false,
error: 'Invalid seed format. Expected 64 hexadecimal characters.',
details,
};
}

// Verify seed hash
try {
const calculatedHash = await hashSeed(proof.seed);
Expand Down Expand Up @@ -254,8 +263,8 @@ export async function seededShuffle(deck: number[], seed: string): Promise<numbe
seedCounter++;

const view = new Uint32Array(hashBuffer);
// Convert first 4 bytes to number in range [0, 1)
const value = view[0] / 0xffffffff;
// Convert first 4 bytes to number in range [0, 1) using exclusive upper bound
const value = view[0] / 0x100000000;
return value;
};

Expand Down
Loading