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

@liskhq/lisk-cryptography

Package Overview
Dependencies
Maintainers
3
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@liskhq/lisk-cryptography - npm Package Compare versions

Comparing version 4.1.0-beta.1 to 4.1.0-rc.0

9

dist-node/address.js

@@ -29,3 +29,3 @@ "use strict";

const buffer = (0, utils_1.hash)(publicKey);
const truncatedBuffer = buffer.slice(0, constants_1.BINARY_ADDRESS_LENGTH);
const truncatedBuffer = buffer.subarray(0, constants_1.BINARY_ADDRESS_LENGTH);
if (truncatedBuffer.length !== constants_1.BINARY_ADDRESS_LENGTH) {

@@ -75,3 +75,8 @@ throw new Error(`Lisk address must contain exactly ${constants_1.BINARY_ADDRESS_LENGTH} bytes`);

};
const getLisk32AddressFromPublicKey = (publicKey, prefix = constants_1.DEFAULT_LISK32_ADDRESS_PREFIX) => `${prefix}${addressToLisk32((0, exports.getAddressFromPublicKey)(publicKey))}`;
const getLisk32AddressFromPublicKey = (publicKey, prefix = constants_1.DEFAULT_LISK32_ADDRESS_PREFIX) => {
if (publicKey.length !== constants_1.ED25519_PUBLIC_KEY_LENGTH) {
throw new Error(`publicKey length must be ${constants_1.ED25519_PUBLIC_KEY_LENGTH}.`);
}
return `${prefix}${addressToLisk32((0, exports.getAddressFromPublicKey)(publicKey))}`;
};
exports.getLisk32AddressFromPublicKey = getLisk32AddressFromPublicKey;

@@ -78,0 +83,0 @@ const validateLisk32Address = (address, prefix = constants_1.DEFAULT_LISK32_ADDRESS_PREFIX) => {

@@ -111,3 +111,3 @@ "use strict";

}
return OKM.slice(0, length);
return OKM.subarray(0, length);
};

@@ -119,3 +119,3 @@ const toLamportSK = (IKM, salt) => {

for (let i = 0; i < 255; i += 1) {
lamportSK.push(OKM.slice(i * 32, (i + 1) * 32));
lamportSK.push(OKM.subarray(i * 32, (i + 1) * 32));
}

@@ -122,0 +122,0 @@ return lamportSK;

@@ -15,1 +15,2 @@ /// <reference types="node" />

export declare const MESSAGE_TAG_NON_PROTOCOL_MESSAGE = "LSK_NPM_";
export declare const ED25519_PUBLIC_KEY_LENGTH = 32;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MESSAGE_TAG_NON_PROTOCOL_MESSAGE = exports.LISK32_ADDRESS_LENGTH = exports.LISK32_CHARSET = exports.SHA256 = exports.EMPTY_BUFFER = exports.EMPTY_SALT = exports.L = exports.HASH_LENGTH = exports.HARDENED_OFFSET = exports.MAX_UINT32 = exports.ED25519_CURVE = exports.DEFAULT_LISK32_ADDRESS_PREFIX = exports.BINARY_ADDRESS_LENGTH = void 0;
exports.ED25519_PUBLIC_KEY_LENGTH = exports.MESSAGE_TAG_NON_PROTOCOL_MESSAGE = exports.LISK32_ADDRESS_LENGTH = exports.LISK32_CHARSET = exports.SHA256 = exports.EMPTY_BUFFER = exports.EMPTY_SALT = exports.L = exports.HASH_LENGTH = exports.HARDENED_OFFSET = exports.MAX_UINT32 = exports.ED25519_CURVE = exports.DEFAULT_LISK32_ADDRESS_PREFIX = exports.BINARY_ADDRESS_LENGTH = void 0;
exports.BINARY_ADDRESS_LENGTH = 20;

@@ -17,2 +17,3 @@ exports.DEFAULT_LISK32_ADDRESS_PREFIX = 'lsk';

exports.MESSAGE_TAG_NON_PROTOCOL_MESSAGE = 'LSK_NPM_';
exports.ED25519_PUBLIC_KEY_LENGTH = 32;
//# sourceMappingURL=constants.js.map

@@ -20,4 +20,4 @@ "use strict";

const digest = hmac.update(seed).digest();
const leftBytes = digest.slice(0, 32);
const rightBytes = digest.slice(32);
const leftBytes = digest.subarray(0, 32);
const rightBytes = digest.subarray(32);
return {

@@ -33,4 +33,4 @@ key: leftBytes,

const digest = crypto.createHmac('sha512', node.chainCode).update(data).digest();
const leftBytes = digest.slice(0, 32);
const rightBytes = digest.slice(32);
const leftBytes = digest.subarray(0, 32);
const rightBytes = digest.subarray(32);
return {

@@ -37,0 +37,0 @@ key: leftBytes,

@@ -36,3 +36,3 @@ "use strict";

const encryptAES128GCMWithPassword = async (plainText, password, options) => {
var _a, _b, _c, _d, _e, _f, _g;
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
const kdf = (_a = options === null || options === void 0 ? void 0 : options.kdf) !== null && _a !== void 0 ? _a : KDF.ARGON2;

@@ -43,5 +43,5 @@ const IV_BUFFER_SIZE = 16;

const iv = crypto.randomBytes(IV_BUFFER_SIZE);
const iterations = kdf === KDF.ARGON2 ? ARGON2_ITERATIONS : (_c = (_b = options === null || options === void 0 ? void 0 : options.kdfparams) === null || _b === void 0 ? void 0 : _b.iterations) !== null && _c !== void 0 ? _c : PBKDF2_ITERATIONS;
const parallelism = (_e = (_d = options === null || options === void 0 ? void 0 : options.kdfparams) === null || _d === void 0 ? void 0 : _d.parallelism) !== null && _e !== void 0 ? _e : ARGON2_PARALLELISM;
const memorySize = (_g = (_f = options === null || options === void 0 ? void 0 : options.kdfparams) === null || _f === void 0 ? void 0 : _f.memorySize) !== null && _g !== void 0 ? _g : exports.ARGON2_MEMORY;
const iterations = (_c = (_b = options === null || options === void 0 ? void 0 : options.kdfparams) === null || _b === void 0 ? void 0 : _b.iterations) !== null && _c !== void 0 ? _c : (kdf === KDF.ARGON2 ? ARGON2_ITERATIONS : (_e = (_d = options === null || options === void 0 ? void 0 : options.kdfparams) === null || _d === void 0 ? void 0 : _d.iterations) !== null && _e !== void 0 ? _e : PBKDF2_ITERATIONS);
const parallelism = (_g = (_f = options === null || options === void 0 ? void 0 : options.kdfparams) === null || _f === void 0 ? void 0 : _f.parallelism) !== null && _g !== void 0 ? _g : ARGON2_PARALLELISM;
const memorySize = (_j = (_h = options === null || options === void 0 ? void 0 : options.kdfparams) === null || _h === void 0 ? void 0 : _h.memorySize) !== null && _j !== void 0 ? _j : exports.ARGON2_MEMORY;
let key;

@@ -70,3 +70,3 @@ if ((options === null || options === void 0 ? void 0 : options.getKey) !== undefined) {

}
const cipher = crypto.createCipheriv('aes-128-gcm', key.slice(0, 16), iv);
const cipher = crypto.createCipheriv('aes-128-gcm', key.subarray(0, 16), iv);
const firstBlock = Buffer.isBuffer(plainText)

@@ -79,3 +79,3 @@ ? cipher.update(plainText)

ciphertext: encrypted.toString('hex'),
mac: crypto.createHash('sha256').update(key.slice(16, 32)).update(encrypted).digest('hex'),
mac: crypto.createHash('sha256').update(key.subarray(16, 32)).update(encrypted).digest('hex'),
kdf,

@@ -131,3 +131,3 @@ kdfparams: {

}
const decipher = crypto.createDecipheriv('aes-128-gcm', key.slice(0, 16), (0, utils_1.hexToBuffer)(iv, 'IV'));
const decipher = crypto.createDecipheriv('aes-128-gcm', key.subarray(0, 16), (0, utils_1.hexToBuffer)(iv, 'IV'));
decipher.setAuthTag(tagBuffer);

@@ -134,0 +134,0 @@ const firstBlock = decipher.update((0, utils_1.hexToBuffer)(ciphertext, 'Cipher text'));

@@ -11,5 +11,5 @@ "use strict";

if (typeof input === 'string') {
return reverse(Buffer.from(input).slice(0, BUFFER_SIZE));
return reverse(Buffer.from(input).subarray(0, BUFFER_SIZE));
}
return reverse(Buffer.from(input).slice(0, BUFFER_SIZE));
return reverse(Buffer.from(input).subarray(0, BUFFER_SIZE));
};

@@ -16,0 +16,0 @@ exports.getFirstEightBytesReversed = getFirstEightBytesReversed;

@@ -31,3 +31,3 @@ "use strict";

const getPublicKey = privateKey => {
const { publicKey } = tweetnacl.sign.keyPair.fromSeed(Uint8Array.from(privateKey.slice(0, PRIVATE_KEY_LENGTH)));
const { publicKey } = tweetnacl.sign.keyPair.fromSeed(Uint8Array.from(privateKey.subarray(0, PRIVATE_KEY_LENGTH)));
return Buffer.from(publicKey);

@@ -34,0 +34,0 @@ };

@@ -29,3 +29,3 @@ "use strict";

if (!path.startsWith('m') || !path.includes('/')) {
throw new Error('Invalid path format');
throw new Error('Invalid key derivation path format');
}

@@ -37,7 +37,7 @@ return (path

if (!/^[0-9']+$/g.test(segment)) {
throw new Error('Invalid path format');
throw new Error('Invalid key derivation path format');
}
if (segment.includes(`'`)) {
if (parseInt(segment.slice(0, -1), 10) > constants_1.MAX_UINT32 / 2) {
throw new Error('Invalid path format');
throw new Error('Invalid key derivation path format');
}

@@ -47,3 +47,3 @@ return parseInt(segment, 10) + constants_1.HARDENED_OFFSET;

if (parseInt(segment, 10) > constants_1.MAX_UINT32) {
throw new Error('Invalid path format');
throw new Error('Invalid key derivation path format');
}

@@ -138,3 +138,3 @@ return parseInt(segment, 10);

const defaultDistance = 1000;
const generateHashOnionSeed = () => (0, exports.hash)((0, nacl_1.getRandomBytes)(INPUT_SIZE)).slice(0, HASH_SIZE);
const generateHashOnionSeed = () => (0, exports.hash)((0, nacl_1.getRandomBytes)(INPUT_SIZE)).subarray(0, HASH_SIZE);
exports.generateHashOnionSeed = generateHashOnionSeed;

@@ -151,3 +151,3 @@ const hashOnion = (seed, count = defaultCount, distance = defaultDistance) => {

for (let i = 1; i <= count; i += 1) {
const nextHash = (0, exports.hash)(previousHash).slice(0, HASH_SIZE);
const nextHash = (0, exports.hash)(previousHash).subarray(0, HASH_SIZE);
if (i % distance === 0) {

@@ -154,0 +154,0 @@ hashes.push(nextHash);

{
"name": "@liskhq/lisk-cryptography",
"version": "4.1.0-beta.1",
"version": "4.1.0-rc.0",
"description": "General cryptographic functions for use with Lisk-related software",

@@ -38,3 +38,3 @@ "author": "Lisk Foundation <admin@lisk.com>, lightcurve GmbH <admin@lightcurve.io>",

"dependencies": {
"@liskhq/lisk-passphrase": "^4.1.0-beta.0",
"@liskhq/lisk-passphrase": "^4.1.0-rc.0",
"buffer-reverse": "1.0.1",

@@ -79,3 +79,4 @@ "hash-wasm": "4.9.0",

"typescript": "5.0.2"
}
},
"gitHead": "fef17823eb43545360c106386ff20bf0928636bb"
}

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