Repository navigation
Conversation
blake2b() converted the key, salt, and personalization fields of the caller's options object from hex strings to Uint8Array in place, so the object came back changed (and a frozen options object threw a TypeError in strict mode). The same conversion already happened again when building the noble options object, so the in-place writes were pure side effect. Convert only into the fresh options object; hash outputs are unchanged (full suite green, existing vectors untouched).
🦋 Changeset detectedLatest commit: f6e4252 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Problem
blake2b()in@fleet-sdk/cryptoconverted thekey,salt, andpersonalizationfields of the caller's options object in place:Consequences for callers:
Uint8Arrays — surprising if the caller reuses, logs, or serializes it.Object.freeze({...})) throwsTypeError: Cannot assign to read only property 'key', because ES modules run in strict mode.The in-place writes were also pure redundancy: the very next block converts the same fields again with
ensureBytes()when building the options object for@noble/hashes.Fix
Remove the in-place assignments. The conversion now happens only in the fresh options object built for the underlying hash call, so the caller's object is left exactly as passed. Hash outputs are byte-identical — all existing test vectors pass unchanged.
Tests
Two new cases in
hashes.spec.ts, both failing on pristine master:key/salt/personalizationfields keep their values and types after the call, and the digest matches hashing with pre-decoded byte options.TypeError; now returns the same digest as the byte-options form.Results: crypto spec 7/7; full monorepo suite 1134/1134 (66 files); biome clean on the changed files. Changeset included (
@fleet-sdk/crypto: patch).Independent community contribution — @Kshot9000 (https://x.com/kshot9000). If this work is useful, tips are welcome: ERG
9fcM5RWnAjmP4vx5bnW6yohB6H9bLq8sJbaPLHtwZLtQPB32Pvy