Skip to content

Commit

Permalink
fix: update crypto package dependencies and replace crypto-browserify…
Browse files Browse the repository at this point in the history
… with randombytes
  • Loading branch information
vikinatora committed Dec 21, 2023
1 parent 7c9142f commit 853f04c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"bn.js": "5.2.1",
"borsh": "1.0.0",
"@noble/curves": "1.2.0",
"crypto-browserify": "3.12.0"
"randombytes": "2.1.0"
},
"devDependencies": {
"@types/node": "18.11.18",
Expand Down
4 changes: 2 additions & 2 deletions packages/crypto/src/key_pair_ed25519.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { baseEncode, baseDecode } from '@near-js/utils';
import { ed25519 } from '@noble/curves/ed25519';
import crypto from 'crypto-browserify';
import randombytes from 'randombytes';

import { KeySize, KeyType } from './constants';
import { KeyPairBase, Signature } from './key_pair_base';
Expand Down Expand Up @@ -41,7 +41,7 @@ export class KeyPairEd25519 extends KeyPairBase {
* // returns [SECRET_KEY]
*/
static fromRandom() {
const secretKey = crypto.randomBytes(KeySize.SECRET_KEY);
const secretKey = randombytes(KeySize.SECRET_KEY);
const publicKey = ed25519.getPublicKey(secretKey);
const extendedSecretKey = new Uint8Array([...secretKey, ...publicKey]);
return new KeyPairEd25519(baseEncode(extendedSecretKey));
Expand Down
32 changes: 30 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 853f04c

Please sign in to comment.