Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@zilliqa-js/crypto

Package Overview
Dependencies
Maintainers
6
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zilliqa-js/crypto - npm Package Compare versions

Comparing version 3.4.4 to 3.5.0

6

dist/cjs/src/random.d.ts

@@ -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

20

dist/cjs/src/random.js
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc