forked from libp2p/js-libp2p-crypto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove iso-random-stream dependency (libp2p#262)
This dependency brings in NodeJS's `Buffer` which then needs to be polyfilled in the browser. `@noble/*` already brings a utility that switch between Node's and the browser's `randomBytes` interfaces.
- Loading branch information
Showing
5 changed files
with
4 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import isoRandomBytes from 'iso-random-stream/src/random.js' | ||
import { utils } from '@noble/secp256k1' | ||
import errcode from 'err-code' | ||
|
||
export default function randomBytes (length: number): Uint8Array { | ||
if (isNaN(length) || length <= 0) { | ||
throw errcode(new Error('random bytes length must be a Number bigger than 0'), 'ERR_INVALID_LENGTH') | ||
} | ||
return isoRandomBytes(length) | ||
return utils.randomBytes(length) | ||
} |