@zilliqa-js/crypto
Advanced tools
Comparing version 3.4.4 to 3.5.0
@@ -0,2 +1,8 @@ | ||
/** | ||
* Generates random bytes using native crypto module version available in the current execution environment. | ||
* | ||
* @param {number} bytes | ||
* @returns {string} | ||
*/ | ||
export declare const randomBytes: (bytes: number) => string; | ||
//# sourceMappingURL=random.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.randomBytes = void 0; | ||
var tslib_1 = require("tslib"); | ||
// Copyright (C) 2018 Zilliqa | ||
@@ -18,24 +21,13 @@ // | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.randomBytes = void 0; | ||
var tslib_1 = require("tslib"); | ||
var crypto_js_1 = tslib_1.__importDefault(require("crypto-js")); | ||
/** | ||
* randomBytes | ||
* Generates random bytes using native crypto module version available in the current execution environment. | ||
* | ||
* Uses JS-native CSPRNG to generate a specified number of bytes. | ||
* NOTE: this method throws if no PRNG is available. | ||
* | ||
* @param {number} bytes | ||
* @returns {string} | ||
*/ | ||
var sodium_randbytes_1 = tslib_1.__importDefault(require("sodium-randbytes")); | ||
var randomBytes = function (bytes) { | ||
// For node enviroment, use sodium-native because we prefer kernel CSPRNG. | ||
// References: | ||
// - https://paragonie.com/blog/2016/05/how-generate-secure-random-numbers-in-various-programming-languages#nodejs-csprng | ||
// - https://github.com/nodejs/node/issues/5798 | ||
var b = (0, sodium_randbytes_1.default)(bytes); | ||
return b.toString('hex'); | ||
return crypto_js_1.default.lib.WordArray.random(bytes).toString(crypto_js_1.default.enc.Hex); | ||
}; | ||
exports.randomBytes = randomBytes; | ||
//# sourceMappingURL=random.js.map |
@@ -17,20 +17,12 @@ // Copyright (C) 2018 Zilliqa | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
import cryptoJs from "crypto-js"; | ||
/** | ||
* randomBytes | ||
* Generates random bytes using native crypto module version available in the current execution environment. | ||
* | ||
* Uses JS-native CSPRNG to generate a specified number of bytes. | ||
* NOTE: this method throws if no PRNG is available. | ||
* | ||
* @param {number} bytes | ||
* @returns {string} | ||
*/ | ||
import randbytes from 'sodium-randbytes'; | ||
export var randomBytes = function (bytes) { | ||
// For node enviroment, use sodium-native because we prefer kernel CSPRNG. | ||
// References: | ||
// - https://paragonie.com/blog/2016/05/how-generate-secure-random-numbers-in-various-programming-languages#nodejs-csprng | ||
// - https://github.com/nodejs/node/issues/5798 | ||
var b = randbytes(bytes); | ||
return b.toString('hex'); | ||
return cryptoJs.lib.WordArray.random(bytes).toString(cryptoJs.enc.Hex); | ||
}; | ||
//# sourceMappingURL=random.js.map |
@@ -0,2 +1,8 @@ | ||
/** | ||
* Generates random bytes using native crypto module version available in the current execution environment. | ||
* | ||
* @param {number} bytes | ||
* @returns {string} | ||
*/ | ||
export declare const randomBytes: (bytes: number) => string; | ||
//# sourceMappingURL=random.d.ts.map |
@@ -0,2 +1,8 @@ | ||
/** | ||
* Generates random bytes using native crypto module version available in the current execution environment. | ||
* | ||
* @param {number} bytes | ||
* @returns {string} | ||
*/ | ||
export declare const randomBytes: (bytes: number) => string; | ||
//# sourceMappingURL=random.d.ts.map |
{ | ||
"name": "@zilliqa-js/crypto", | ||
"version": "3.4.4", | ||
"version": "3.5.0", | ||
"description": "Core crypto utilities for signing/verification/hashing Zilliqa transactions.", | ||
@@ -25,2 +25,3 @@ "maintainers": [ | ||
"buffer": "^6.0.3", | ||
"crypto-js": "^4.2.0", | ||
"elliptic": "^6.5.0", | ||
@@ -32,6 +33,5 @@ "hash.js": "^1.1.5", | ||
"scryptsy": "^2.1.0", | ||
"sodium-randbytes": "0.14.0", | ||
"tslib": "2.3.1", | ||
"uuid": "8.3.2", | ||
"@zilliqa-js/util": "3.4.4" | ||
"@zilliqa-js/util": "3.5.0" | ||
}, | ||
@@ -44,2 +44,3 @@ "devDependencies": { | ||
"@types/camelcase": "^5.1.0", | ||
"@types/crypto-js": "^4.2.1", | ||
"@types/elliptic": "^6.4.14", | ||
@@ -71,3 +72,2 @@ "@types/fancy-log": "^1.3.0", | ||
"rollup-plugin-typescript2": "^0.34.1", | ||
"sodium-randbytes": "0.14.0", | ||
"ts-jest": "^27.1.3", | ||
@@ -74,0 +74,0 @@ "ts-loader": "8.0.4", |
@@ -11,7 +11,2 @@ # @zilliqa-js/crypto | ||
- For browser and web worker environment, we use | ||
[window.crypto.getRandomValues()](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) | ||
- For node environment, we use | ||
[sodium-native](https://github.com/sodium-friends/sodium-native) | ||
#### Parameters | ||
@@ -18,0 +13,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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 not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3425414
32450
211
+ Addedcrypto-js@^4.2.0
+ Added@zilliqa-js/util@3.5.0(transitive)
+ Addedcrypto-js@4.2.0(transitive)
- Removedsodium-randbytes@0.14.0
- Removed@types/node@22.10.0(transitive)
- Removed@types/sodium-native@2.3.5(transitive)
- Removed@zilliqa-js/util@3.4.4(transitive)
- Removednode-gyp-build@4.8.4(transitive)
- Removedsodium-native@3.3.0(transitive)
- Removedsodium-randbytes@0.14.0(transitive)
- Removedundici-types@6.20.0(transitive)
Updated@zilliqa-js/util@3.5.0