How to use the @liskhq/lisk-cryptography.getPrivateAndPublicKeyBytesFromPassphrase function in @liskhq/lisk-cryptography

To help you get started, we’ve selected a few @liskhq/lisk-cryptography examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LiskHQ / lisk-sdk / protocol-specs / utils / dpos / rounds.js View on Github external
// eslint-disable-next-line no-restricted-syntax
	for (const encryptedItem of encryptedList) {
		let passphrase;
		try {
			passphrase = decryptPassphraseWithPassword(
				parseEncryptedPassphrase(encryptedItem.encryptedPassphrase),
				password,
			);
		} catch (e) {
			throw new Error('Invalid password and public key combination');
		}

		const {
			publicKeyBytes,
			privateKeyBytes,
		} = getPrivateAndPublicKeyBytesFromPassphrase(passphrase);

		const keypair = {
			publicKey: publicKeyBytes,
			privateKey: privateKeyBytes,
		};

		if (keypair.publicKey.toString('hex') !== encryptedItem.publicKey) {
			throw new Error(
				`Invalid encryptedPassphrase for publicKey: ${
					encryptedItem.publicKey
				}. Public keys do not match`,
			);
		}

		keypairs[keypair.publicKey.toString('hex')] = keypair;
	}
github LiskHQ / lisk-sdk / framework / src / modules / chain / forger.js View on Github external
passphrase = decryptPassphraseWithPassword(
					parseEncryptedPassphrase(encryptedItem.encryptedPassphrase),
					this.config.forging.defaultPassword,
				);
			} catch (error) {
				const decryptionError = `Invalid encryptedPassphrase for publicKey: ${
					encryptedItem.publicKey
				}. ${error.message}`;
				this.logger.error(decryptionError);
				throw decryptionError;
			}

			const {
				publicKeyBytes,
				privateKeyBytes,
			} = getPrivateAndPublicKeyBytesFromPassphrase(passphrase);

			const keypair = {
				publicKey: publicKeyBytes,
				privateKey: privateKeyBytes,
			};

			if (keypair.publicKey.toString('hex') !== encryptedItem.publicKey) {
				throw new Error(
					`Invalid encryptedPassphrase for publicKey: ${
						encryptedItem.publicKey
					}. Public keys do not match`,
				);
			}

			const filters = {
				address: getAddressFromPublicKey(keypair.publicKey.toString('hex')),
github LiskHQ / lisk-sdk / framework / src / modules / chain / forger.js View on Github external
let keypair;
		let passphrase;

		if (encryptedItem) {
			try {
				passphrase = decryptPassphraseWithPassword(
					parseEncryptedPassphrase(encryptedItem.encryptedPassphrase),
					password,
				);
			} catch (e) {
				throw new Error('Invalid password and public key combination');
			}
			const {
				publicKeyBytes,
				privateKeyBytes,
			} = getPrivateAndPublicKeyBytesFromPassphrase(passphrase);

			keypair = {
				publicKey: publicKeyBytes,
				privateKey: privateKeyBytes,
			};
		} else {
			throw new Error(`Delegate with publicKey: ${publicKey} not found`);
		}

		if (keypair.publicKey.toString('hex') !== publicKey) {
			throw new Error('Invalid password and public key combination');
		}

		const filters = {
			address: getAddressFromPublicKey(keypair.publicKey.toString('hex')),
		};
github LiskHQ / lisk-sdk / framework / src / modules / chain / forger / forger.js View on Github external
let passphrase;
			try {
				passphrase = decryptPassphraseWithPassword(
					parseEncryptedPassphrase(encryptedItem.encryptedPassphrase),
					this.config.forging.defaultPassword,
				);
			} catch (error) {
				const decryptionError = `Invalid encryptedPassphrase for publicKey: ${encryptedItem.publicKey}. ${error.message}`;
				this.logger.error(decryptionError);
				throw decryptionError;
			}

			const {
				publicKeyBytes,
				privateKeyBytes,
			} = getPrivateAndPublicKeyBytesFromPassphrase(passphrase);

			const keypair = {
				publicKey: publicKeyBytes,
				privateKey: privateKeyBytes,
			};

			if (keypair.publicKey.toString('hex') !== encryptedItem.publicKey) {
				throw new Error(
					`Invalid encryptedPassphrase for publicKey: ${encryptedItem.publicKey}. Public keys do not match`,
				);
			}

			const filters = {
				address: getAddressFromPublicKey(keypair.publicKey.toString('hex')),
			};
github LiskHQ / lisk-sdk / framework / src / modules / chain / forger / forger.js View on Github external
let keypair;
		let passphrase;

		if (encryptedItem) {
			try {
				passphrase = decryptPassphraseWithPassword(
					parseEncryptedPassphrase(encryptedItem.encryptedPassphrase),
					password,
				);
			} catch (e) {
				throw new Error('Invalid password and public key combination');
			}
			const {
				publicKeyBytes,
				privateKeyBytes,
			} = getPrivateAndPublicKeyBytesFromPassphrase(passphrase);

			keypair = {
				publicKey: publicKeyBytes,
				privateKey: privateKeyBytes,
			};
		} else {
			throw new Error(`Delegate with publicKey: ${publicKey} not found`);
		}

		if (keypair.publicKey.toString('hex') !== publicKey) {
			throw new Error('Invalid password and public key combination');
		}

		const filters = {
			address: getAddressFromPublicKey(keypair.publicKey.toString('hex')),
		};