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

@zilliqa-js/crypto

Package Overview
Dependencies
Maintainers
2
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.3.3 to 3.3.4

2

dist/bech32.js
"use strict";
// Copyright (C) 2018 Zilliqa
//
// This file is part of Zilliqa-Javascript-Library.
// This file is part of zilliqa-js
//

@@ -6,0 +6,0 @@ // This program is free software: you can redistribute it and/or modify

@@ -0,1 +1,2 @@

import randbytes from 'sodium-randbytes';
import elliptic, { ec } from 'elliptic';

@@ -12,74 +13,8 @@ import hashjs from 'hash.js';

// Copyright (C) 2018 Zilliqa
//
// This file is part of Zilliqa-Javascript-Library.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/**
* randomBytes
*
* 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 randomBytes = function (bytes$$1) {
var _a, _b;
var b = Buffer.allocUnsafe(bytes$$1);
var n = b.byteLength;
var isBrowserEnv = typeof window !== 'undefined' && typeof window.document !== 'undefined';
var isWebWorkerEnv = typeof self === 'object' &&
((_a = self.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'DedicatedWorkerGlobalScope';
var isNodeEnv = typeof process !== 'undefined' &&
typeof ((_b = process === null || process === void 0 ? void 0 : process.versions) === null || _b === void 0 ? void 0 : _b.node) === 'string';
var crypto = undefined;
if (isBrowserEnv || isWebWorkerEnv) {
// web worker: self.crypto
// browser: window.crypto
// @ts-ignore
crypto = global.crypto || global.msCrypto; // for IE 11
}
if (typeof (crypto === null || crypto === void 0 ? void 0 : crypto.getRandomValues) === 'function') {
// For browser or web worker enviroment, use window.crypto.getRandomValues()
// https://paragonie.com/blog/2016/05/how-generate-secure-random-numbers-in-various-programming-languages#js-csprng
// limit of getRandomValues()
// The requested length exceeds 65536 bytes.
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues#exceptions
var MAX_BYTES = 65536;
for (var i = 0; i < n; i += MAX_BYTES) {
// typedArray = crypto.getRandomValues(typedArray);
// Note that typedArray is modified in-place, and no copy is made.
crypto.getRandomValues(new Uint8Array(b.buffer, i + b.byteOffset, Math.min(n - i, MAX_BYTES)));
}
}
else if (isNodeEnv) {
// 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
//
// This logic should run only in node env. Otherwise, it will throw an error 'require is not defined'.
//
// Consider using createRequire when typescipt 4.5 is available.
// https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta
// https://nodejs.org/api/module.html#modulecreaterequirefilename
//
// eslint-disable-next-line
var sodium = require('sodium-native');
sodium.randombytes_buf(b);
}
else {
throw new Error('No secure random number generator available');
}
// 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$$1);
return b.toString('hex');

@@ -531,3 +466,3 @@ };

* Utility method for recovering account from 0x private key.
* See https://github.com/Zilliqa/Zilliqa-JavaScript-Library/pull/159
* See https://github.com/Zilliqa/zilliqa-js/pull/159
* @param privateKeyWith0x : private key with 0x prefix

@@ -534,0 +469,0 @@ */

"use strict";
// Copyright (C) 2018 Zilliqa
//
// This file is part of Zilliqa-Javascript-Library.
// This file is part of zilliqa-js
//

@@ -6,0 +6,0 @@ // This program is free software: you can redistribute it and/or modify

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('elliptic'), require('hash.js'), require('hmac-drbg'), require('@zilliqa-js/util'), require('tslib'), require('aes-js'), require('pbkdf2'), require('scrypt-js'), require('uuid')) :
typeof define === 'function' && define.amd ? define(['exports', 'elliptic', 'hash.js', 'hmac-drbg', '@zilliqa-js/util', 'tslib', 'aes-js', 'pbkdf2', 'scrypt-js', 'uuid'], factory) :
(factory((global.zjsCrypto = {}),global.elliptic,global.hash.js,global['hmac-drbg'],global['@zilliqa-js/util'],global.tslib,global['aes-js'],global.pbkdf2,global['scrypt-js'],global.uuid));
}(this, (function (exports,elliptic,hashjs,DRBG,util,tslib,aes,pbkdf2,scrypt,uuid) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('sodium-randbytes'), require('elliptic'), require('hash.js'), require('hmac-drbg'), require('@zilliqa-js/util'), require('tslib'), require('aes-js'), require('pbkdf2'), require('scrypt-js'), require('uuid')) :
typeof define === 'function' && define.amd ? define(['exports', 'sodium-randbytes', 'elliptic', 'hash.js', 'hmac-drbg', '@zilliqa-js/util', 'tslib', 'aes-js', 'pbkdf2', 'scrypt-js', 'uuid'], factory) :
(factory((global.zjsCrypto = {}),global['sodium-randbytes'],global.elliptic,global.hash.js,global['hmac-drbg'],global['@zilliqa-js/util'],global.tslib,global['aes-js'],global.pbkdf2,global['scrypt-js'],global.uuid));
}(this, (function (exports,randbytes,elliptic,hashjs,DRBG,util,tslib,aes,pbkdf2,scrypt,uuid) { 'use strict';
randbytes = randbytes && randbytes.hasOwnProperty('default') ? randbytes['default'] : randbytes;
var elliptic__default = 'default' in elliptic ? elliptic['default'] : elliptic;

@@ -14,74 +15,8 @@ hashjs = hashjs && hashjs.hasOwnProperty('default') ? hashjs['default'] : hashjs;

// Copyright (C) 2018 Zilliqa
//
// This file is part of Zilliqa-Javascript-Library.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/**
* randomBytes
*
* 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 randomBytes = function (bytes) {
var _a, _b;
var b = Buffer.allocUnsafe(bytes);
var n = b.byteLength;
var isBrowserEnv = typeof window !== 'undefined' && typeof window.document !== 'undefined';
var isWebWorkerEnv = typeof self === 'object' &&
((_a = self.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'DedicatedWorkerGlobalScope';
var isNodeEnv = typeof process !== 'undefined' &&
typeof ((_b = process === null || process === void 0 ? void 0 : process.versions) === null || _b === void 0 ? void 0 : _b.node) === 'string';
var crypto = undefined;
if (isBrowserEnv || isWebWorkerEnv) {
// web worker: self.crypto
// browser: window.crypto
// @ts-ignore
crypto = global.crypto || global.msCrypto; // for IE 11
}
if (typeof (crypto === null || crypto === void 0 ? void 0 : crypto.getRandomValues) === 'function') {
// For browser or web worker enviroment, use window.crypto.getRandomValues()
// https://paragonie.com/blog/2016/05/how-generate-secure-random-numbers-in-various-programming-languages#js-csprng
// limit of getRandomValues()
// The requested length exceeds 65536 bytes.
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues#exceptions
var MAX_BYTES = 65536;
for (var i = 0; i < n; i += MAX_BYTES) {
// typedArray = crypto.getRandomValues(typedArray);
// Note that typedArray is modified in-place, and no copy is made.
crypto.getRandomValues(new Uint8Array(b.buffer, i + b.byteOffset, Math.min(n - i, MAX_BYTES)));
}
}
else if (isNodeEnv) {
// 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
//
// This logic should run only in node env. Otherwise, it will throw an error 'require is not defined'.
//
// Consider using createRequire when typescipt 4.5 is available.
// https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta
// https://nodejs.org/api/module.html#modulecreaterequirefilename
//
// eslint-disable-next-line
var sodium = require('sodium-native');
sodium.randombytes_buf(b);
}
else {
throw new Error('No secure random number generator available');
}
// 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');

@@ -533,3 +468,3 @@ };

* Utility method for recovering account from 0x private key.
* See https://github.com/Zilliqa/Zilliqa-JavaScript-Library/pull/159
* See https://github.com/Zilliqa/zilliqa-js/pull/159
* @param privateKeyWith0x : private key with 0x prefix

@@ -536,0 +471,0 @@ */

"use strict";
// Copyright (C) 2018 Zilliqa
//
// This file is part of Zilliqa-Javascript-Library.
// This file is part of zilliqa-js
//

@@ -6,0 +6,0 @@ // This program is free software: you can redistribute it and/or modify

@@ -1,11 +0,2 @@

/**
* randomBytes
*
* 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}
*/
export declare const randomBytes: (bytes: number) => string;
//# sourceMappingURL=random.d.ts.map
"use strict";
// Copyright (C) 2018 Zilliqa
//
// This file is part of Zilliqa-Javascript-Library.
// This file is part of zilliqa-js
//

@@ -20,2 +20,3 @@ // This program is free software: you can redistribute it and/or modify

exports.randomBytes = void 0;
var tslib_1 = require("tslib");
/**

@@ -30,50 +31,9 @@ * randomBytes

*/
var sodium_randbytes_1 = (0, tslib_1.__importDefault)(require("sodium-randbytes"));
var randomBytes = function (bytes) {
var _a, _b;
var b = Buffer.allocUnsafe(bytes);
var n = b.byteLength;
var isBrowserEnv = typeof window !== 'undefined' && typeof window.document !== 'undefined';
var isWebWorkerEnv = typeof self === 'object' &&
((_a = self.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'DedicatedWorkerGlobalScope';
var isNodeEnv = typeof process !== 'undefined' &&
typeof ((_b = process === null || process === void 0 ? void 0 : process.versions) === null || _b === void 0 ? void 0 : _b.node) === 'string';
var crypto = undefined;
if (isBrowserEnv || isWebWorkerEnv) {
// web worker: self.crypto
// browser: window.crypto
// @ts-ignore
crypto = global.crypto || global.msCrypto; // for IE 11
}
if (typeof (crypto === null || crypto === void 0 ? void 0 : crypto.getRandomValues) === 'function') {
// For browser or web worker enviroment, use window.crypto.getRandomValues()
// https://paragonie.com/blog/2016/05/how-generate-secure-random-numbers-in-various-programming-languages#js-csprng
// limit of getRandomValues()
// The requested length exceeds 65536 bytes.
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues#exceptions
var MAX_BYTES = 65536;
for (var i = 0; i < n; i += MAX_BYTES) {
// typedArray = crypto.getRandomValues(typedArray);
// Note that typedArray is modified in-place, and no copy is made.
crypto.getRandomValues(new Uint8Array(b.buffer, i + b.byteOffset, Math.min(n - i, MAX_BYTES)));
}
}
else if (isNodeEnv) {
// 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
//
// This logic should run only in node env. Otherwise, it will throw an error 'require is not defined'.
//
// Consider using createRequire when typescipt 4.5 is available.
// https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta
// https://nodejs.org/api/module.html#modulecreaterequirefilename
//
// eslint-disable-next-line
var sodium = require('sodium-native');
sodium.randombytes_buf(b);
}
else {
throw new Error('No secure random number generator available');
}
// 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');

@@ -80,0 +40,0 @@ };

"use strict";
// Copyright (C) 2018 Zilliqa
//
// This file is part of Zilliqa-Javascript-Library.
// This file is part of zilliqa-js
//

@@ -6,0 +6,0 @@ // This program is free software: you can redistribute it and/or modify

"use strict";
// Copyright (C) 2018 Zilliqa
//
// This file is part of Zilliqa-Javascript-Library.
// This file is part of zilliqa-js
//

@@ -6,0 +6,0 @@ // This program is free software: you can redistribute it and/or modify

"use strict";
// Copyright (C) 2018 Zilliqa
//
// This file is part of Zilliqa-Javascript-Library.
// This file is part of zilliqa-js
//

@@ -6,0 +6,0 @@ // This program is free software: you can redistribute it and/or modify

@@ -25,3 +25,3 @@ /**

* Utility method for recovering account from 0x private key.
* See https://github.com/Zilliqa/Zilliqa-JavaScript-Library/pull/159
* See https://github.com/Zilliqa/zilliqa-js/pull/159
* @param privateKeyWith0x : private key with 0x prefix

@@ -28,0 +28,0 @@ */

"use strict";
// Copyright (C) 2018 Zilliqa
//
// This file is part of Zilliqa-Javascript-Library.
// This file is part of zilliqa-js
//

@@ -61,3 +61,3 @@ // This program is free software: you can redistribute it and/or modify

* Utility method for recovering account from 0x private key.
* See https://github.com/Zilliqa/Zilliqa-JavaScript-Library/pull/159
* See https://github.com/Zilliqa/zilliqa-js/pull/159
* @param privateKeyWith0x : private key with 0x prefix

@@ -64,0 +64,0 @@ */

{
"name": "@zilliqa-js/crypto",
"version": "3.3.3",
"version": "3.3.4",
"description": "Core crypto utilities for signing/verification/hashing Zilliqa transactions.",

@@ -10,3 +10,3 @@ "author": "Ian Tan (https://github.com/iantanwx)",

"bugs": {
"url": "https://github.com/Zilliqa/Zilliqa-JavaScript-Library/issues"
"url": "https://github.com/Zilliqa/zilliqa-js/issues"
},

@@ -20,3 +20,3 @@ "main": "dist/index.js",

"typings": "dist/index.d.ts",
"repository": "https://github.com/zilliqa/zilliqa-javascript-library/",
"repository": "https://github.com/Zilliqa/zilliqa-js/",
"license": "GPL-3.0",

@@ -32,3 +32,3 @@ "publishConfig": {

"@types/uuid": "8.3.1",
"@zilliqa-js/util": "^3.3.3",
"@zilliqa-js/util": "^3.3.4",
"aes-js": "^3.1.1",

@@ -40,6 +40,5 @@ "bsert": "^0.0.4",

"pbkdf2": "^3.0.16",
"randombytes": "^2.0.6",
"scrypt-js": "^3.0.1",
"scryptsy": "^2.1.0",
"sodium-native": "^3.2.1",
"sodium-randbytes": "0.14.0",
"tslib": "2.3.1",

@@ -56,3 +55,3 @@ "uuid": "8.3.2"

],
"gitHead": "c0aab06f22ac07da9fc5f9f049fc8bfaa6a4d56f"
"gitHead": "4c49d56db14609dea8916aa7c13bc4313051080f"
}

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

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