Skip to content

Fix wallet manager keystore fixtures - #7

Open
giwaov wants to merge 5 commits into
canopy-network:mainfrom
giwaov:fix-wallet-manager-keystore-fixtures
Open

Fix wallet manager keystore fixtures#7
giwaov wants to merge 5 commits into
canopy-network:mainfrom
giwaov:fix-wallet-manager-keystore-fixtures

Conversation

@giwaov

@giwaov giwaov commented Jul 4, 2026

Copy link
Copy Markdown

Summary

  • update wallet-manager keystore fixtures to use addresses derived from their mocked BLS public keys
  • use a distinct second BLS key/address pair for the multi-account fixture

Tests

  • npm test
  • npm run build

amathxbt and others added 5 commits July 4, 2026 03:12
…anopy-network#2)

importFromGoKeystore() compared the stored keyAddress against the address
derived from the public key, but only issued a console.warn on mismatch
and then silently returned the stored (wrong) address.

A corrupted or tampered keystore entry would be accepted without error,
causing outgoing transactions to be signed with a key that does not match
the on-chain address — resulting in fund loss or permanently rejected txs.

Fix: throw an Error with a clear message so callers can detect and reject
integrity failures before any funds are at risk.
…anopy-network#4)

computeDiceRoll() computed raw % 10000 on a uint32. Because 2^32
(4,294,967,296) is not evenly divisible by 10,000, values 0–7,295 appear
slightly more often than values 7,296–9,999 — a systematic bias of ~1.7
per million per value in the favoured range.

In a high-volume casino context this is not negligible: over millions of
rolls the house retains a hidden edge on top of the declared house edge.

Replace modulo with rejection sampling over successive 4-byte HMAC
windows using a rejection threshold of floor(2^32 / 10000) * 10000
(4,294,960,000). Values at or above the threshold are discarded; the
next 4-byte window is used. Average iterations per roll < 2.
…-network#6)

computeCrashPoint() called computeHMAC(serverSeed, "", nonce) — always
passing an empty string as the client seed. The client seed is the
player-supplied entropy that lets them independently verify outcomes are
not predetermined. With an empty seed, the crash point is solely a
function of the server seed and nonce; the player contributes nothing
and cannot verify the game was not rigged against them.

Add clientSeed as a required parameter and throw if it is empty.
Update the JSDoc comment accordingly.
…anopy-network#5)

When result % 33 === 0 the function returned 1.0, but the JSDoc and the
clamp at the bottom of the function both state the output range is
[1.01, 100.0]. Returning 1.0 contradicts the advertised minimum and
gives players a payout that is 1% worse than the published house-edge
formula implies for the instant-crash case.

Change the early return to 1.01 so every code path respects the
advertised floor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants