Handle pre-aborted request signals - #9
Open
giwaov wants to merge 5 commits into
Open
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tests