Repository navigation
fix: use random bytes for randomUtxo/randomToken/randomNFT ids (fixes… - #476
Open
AhmadReza6610 wants to merge 1 commit into
Open
AhmadReza6610 wants to merge 1 commit into
AhmadReza6610 wants to merge 1 commit into
Conversation
…ashScript#471) randomUtxo, randomToken and randomNFT derived txids, token categories and NFT commitments from randomInt(), which has only 10,000 values, so tests with many random UTXOs or tokens got shared outpoints and categories. Use crypto.getRandomValues instead: 32 bytes for txids and categories, 4 bytes for NFT commitments. Amounts still use randomInt(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@AhmadReza6610 is attempting to deploy a commit to the Kalis Software Team on Vercel. A member of the Team first needs to authorize it. |
Pull request stats
Reviewable churn: 55 lines (net +43), version bumps and generated files excluded. Package source changed without an update to |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #476 +/- ##
=======================================
Coverage 89.25% 89.25%
=======================================
Files 61 61
Lines 5081 5082 +1
Branches 950 950
=======================================
+ Hits 4535 4536 +1
Misses 421 421
Partials 125 125 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Fixes #471
randomUtxo,randomTokenandrandomNFTderived txids, token categories and NFT commitments fromrandomInt(), which has only 10,000 values, so tests with many random UTXOs or tokens got shared outpoints and categories.As proposed in the issue, they now use
crypto.getRandomValues: 32 bytes for txids and categories, 4 bytes for NFT commitments (the same length as before). Satoshi and token amounts still userandomInt(). The API is unchanged and defaults still override every field.sha256andbigIntToVmNumberare no longer used inutils.ts, so their imports are removed.Tests (
packages/cashscript/test/util.test.ts, newrandom test helpersblock):I checked that the three uniqueness tests fail on
masterand pass with this change. Thecashscriptpackage tests and lint pass.The pr-stats bot notes there's no release-notes entry. Since v0.14.0 is already released, I didn't want to guess the next version heading. Happy to add a line under whichever heading you prefer, e.g. ":bug: Fix bug where
randomUtxo(),randomToken()andrandomNFT()could return colliding txids, token categories and NFT commitments."