Files
com.blitzwallet/patches/@noble+secp256k1+1.7.1.patch
T
2024-03-23 21:27:48 -04:00

27 lines
1.2 KiB
Diff

diff --git a/node_modules/@noble/secp256k1/lib/index.js b/node_modules/@noble/secp256k1/lib/index.js
index 33a0843..eab0bdf 100644
--- a/node_modules/@noble/secp256k1/lib/index.js
+++ b/node_modules/@noble/secp256k1/lib/index.js
@@ -1132,16 +1132,12 @@ exports.utils = {
return numTo32b(num);
},
randomBytes: (bytesLength = 32) => {
- if (crypto.web) {
- return crypto.web.getRandomValues(new Uint8Array(bytesLength));
- }
- else if (crypto.node) {
- const { randomBytes } = crypto.node;
- return Uint8Array.from(randomBytes(bytesLength));
- }
- else {
- throw new Error("The environment doesn't have randomBytes function");
- }
+ try {
+ const randomBytes = require('expo-crypto').getRandomBytes;
+ return randomBytes(bytesLength);
+ } catch (e) {
+ throw new Error("The environment doesn't have randomBytes function and we couldn't use expo-crypto");
+ }
},
randomPrivateKey: () => exports.utils.hashToPrivateKey(exports.utils.randomBytes(groupLen + 8)),
precompute(windowSize = 8, point = Point.BASE) {