Skip to content

Commit

Permalink
randomBytes default 32
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Jun 14, 2023
1 parent eeb3b06 commit 317457d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ declare const etc: {
hmacSha256Async: (key: Bytes, ...msgs: Bytes[]) => Promise<Bytes>;
hmacSha256Sync: HmacFnSync;
hashToPrivateKey: typeof hashToPrivateKey;
randomBytes: (len: number) => Bytes;
randomBytes: (len?: number) => Bytes;
};
declare const utils: {
normPrivateKeyToScalar: (p: PrivKey) => bigint;
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ const etc = {
},
hmacSha256Sync: _hmacSync,
hashToPrivateKey,
randomBytes: (len) => {
randomBytes: (len = 32) => {
const crypto = cr(); // Must be shimmed in node.js <= 18 to prevent error. See README.
if (!crypto || !crypto.getRandomValues)
err('crypto.getRandomValues must be defined');
Expand Down
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ const etc = { // Not placed in utils b
},
hmacSha256Sync: _hmacSync, // For TypeScript. Actual logic is below
hashToPrivateKey,
randomBytes: (len: number): Bytes => { // CSPRNG (random number generator)
randomBytes: (len = 32): Bytes => { // CSPRNG (random number generator)
const crypto = cr(); // Must be shimmed in node.js <= 18 to prevent error. See README.
if (!crypto || !crypto.getRandomValues) err('crypto.getRandomValues must be defined');
return crypto.getRandomValues(u8n(len));
Expand Down

0 comments on commit 317457d

Please sign in to comment.