Skip to content

fix: use getRandomValues from WebCrypto#3540

Merged
tabcat merged 3 commits into
mainfrom
fix/use-native-random-values
Jun 12, 2026
Merged

fix: use getRandomValues from WebCrypto#3540
tabcat merged 3 commits into
mainfrom
fix/use-native-random-values

Conversation

@achingbrain

@achingbrain achingbrain commented Jun 12, 2026

Copy link
Copy Markdown
Member

The randomBytes function exported from @libp2p/crypto was necessary when the WebCrypto function getRandomValues was not widely implemented.

Now it is so switch to that and deprecate randomBytes for future removal.

This removes a dependency on @libp2p/crypto in a few places which can have knock on effects for bundles due to duplicated transient deps of different versions, extra @noble/* deps, etc.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

The `randomBytes` function exported from `@libp2p/crypto` was necessary
when the WebCrypto function getRandomValues was not widely implemented.

Now is is so switch to that and deprecate `randomBytes` for future removal.

This Prevents accidentally pulling in the `@libp2p/crypto` dependency
which can have knock on effects for bundles due to transient dependencies.
@achingbrain achingbrain requested a review from a team as a code owner June 12, 2026 07:58
@tabcat tabcat merged commit 404c782 into main Jun 12, 2026
34 checks passed
@tabcat tabcat deleted the fix/use-native-random-values branch June 12, 2026 12:27
@tabcat tabcat mentioned this pull request Jun 12, 2026
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