@vechain/sdk-core
Advanced tools
Comparing version 1.0.0-beta.25 to 1.0.0-beta.26
{ | ||
"name": "@vechain/sdk-core", | ||
"version": "1.0.0-beta.25", | ||
"version": "1.0.0-beta.26", | ||
"description": "Includes modules for fundamental operations like hashing and cryptography", | ||
@@ -44,4 +44,4 @@ "author": "vechain Foundation", | ||
"@types/elliptic": "^6.4.18", | ||
"@vechain/sdk-errors": "1.0.0-beta.25", | ||
"@vechain/sdk-logging": "1.0.0-beta.25", | ||
"@vechain/sdk-errors": "1.0.0-beta.26", | ||
"@vechain/sdk-logging": "1.0.0-beta.26", | ||
"bignumber.js": "^9.1.2", | ||
@@ -48,0 +48,0 @@ "blakejs": "^1.2.1", |
@@ -76,4 +76,22 @@ import * as n_utils from '@noble/curves/abstract/utils'; | ||
*/ | ||
function generatePrivateKey(): Uint8Array { | ||
return n_secp256k1.utils.randomPrivateKey(); | ||
async function generatePrivateKey(): Promise<Uint8Array> { | ||
try { | ||
return n_secp256k1.utils.randomPrivateKey(); | ||
} catch (error) { | ||
// Generate an ECDSA key pair | ||
const cryptoKey = await global.crypto.subtle.generateKey( | ||
{ | ||
name: 'AES-GCM', | ||
length: 256 | ||
}, | ||
true, | ||
['encrypt', 'decrypt'] | ||
); | ||
// Export the private key to raw format | ||
const rawKey = await global.crypto.subtle.exportKey('raw', cryptoKey); | ||
// Convert the ArrayBuffer to Uint8Array | ||
return new Uint8Array(rawKey); | ||
} | ||
} | ||
@@ -154,3 +172,7 @@ | ||
function randomBytes(bytesLength?: number | undefined): Uint8Array { | ||
return _randomBytes(bytesLength); | ||
try { | ||
return _randomBytes(bytesLength); | ||
} catch (error) { | ||
return global.crypto.getRandomValues(new Uint8Array(bytesLength ?? 32)); | ||
} | ||
} | ||
@@ -157,0 +179,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1045192
27770
+ Added@vechain/sdk-errors@1.0.0-beta.26(transitive)
+ Added@vechain/sdk-logging@1.0.0-beta.26(transitive)
- Removed@vechain/sdk-errors@1.0.0-beta.25(transitive)
- Removed@vechain/sdk-logging@1.0.0-beta.25(transitive)