How to use the @liskhq/lisk-cryptography.getPrivateAndPublicKeyFromPassphrase 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 / elements / lisk-transactions / src / create_signature_object.ts View on Github external
}

	if (!transaction.id) {
		throw new Error('Transaction ID is required to create a signature object.');
	}

	// tslint:disable-next-line variable-name
	const TransactionClass = transactionMap[transaction.type];
	const tx = new TransactionClass(transaction) as BaseTransaction;

	const validStatus = tx.validate();
	if (validStatus.errors.length > 0) {
		throw new Error('Invalid transaction.');
	}

	const { publicKey } = cryptography.getPrivateAndPublicKeyFromPassphrase(
		passphrase,
	);

	// tslint:disable-next-line no-any
	(tx as any)._signature = undefined;
	// tslint:disable-next-line no-any
	(tx as any)._signSignature = undefined;

	const multiSignature = cryptography.signData(
		cryptography.hash(tx.getBytes()),
		passphrase,
	);

	return {
		transactionId: tx.id,
		publicKey,
github LiskHQ / lisk-sdk / protocol-specs / generators / block_processing_votes / index.js View on Github external
balance: '0',
	},
};

// Decrypt all passwords from delegate genesis and add to accounts array
// eslint-disable-next-line no-restricted-syntax
for (const anAccount of genesisDelegateAccounts) {
	const { encryptedPassphrase } = defaultConfig.forging.delegates.find(
		aDelegate => aDelegate.publicKey === anAccount.publicKey,
	);

	const passphrase = decryptPassphraseWithPassword(
		parseEncryptedPassphrase(encryptedPassphrase),
		defaultConfig.forging.defaultPassword,
	);
	const keys = getPrivateAndPublicKeyFromPassphrase(passphrase);
	const address = getAddressFromPrivateKey(keys.privateKey);

	accounts[`${anAccount.username}_delegate`] = {
		passphrase,
		privateKey: keys.privateKey,
		publicKey: keys.publicKey,
		address,
		balance: '0',
	};
}

// Generators
const generateTestCasesValidBlockVotesTx = () => {
	const chainStateBuilder = new ChainStateBuilder(
		genesisBlock,
		initialAccountsState,
github LiskHQ / lisk-sdk-examples / lisk / scripts / update_config.js View on Github external
config.forging.secret.forEach(secret => {
						console.info('.......');
						config.forging.delegates.push({
							encryptedPassphrase: stringifyEncryptedPassphrase(
								encryptPassphraseWithPassword(secret, password)
							),
							publicKey: getPrivateAndPublicKeyFromPassphrase(secret).publicKey,
						});
					});
github LiskHQ / lisk-core / scripts / update_config.js View on Github external
config.forging.secret.forEach(secret => {
						console.info('.......');
						config.forging.delegates.push({
							encryptedPassphrase: stringifyEncryptedPassphrase(
								encryptPassphraseWithPassword(secret, password)
							),
							publicKey: getPrivateAndPublicKeyFromPassphrase(secret).publicKey,
						});
					});
github LiskHQ / lisk-sdk-examples / delivery / client / create_and_initialize_packet_account.js View on Github external
const getPacketCredentials = () => {
    const passphrase = Mnemonic.generateMnemonic();
    const keys = cryptography.getPrivateAndPublicKeyFromPassphrase(
        passphrase
    );
    const credentials = {
        address: cryptography.getAddressFromPublicKey(keys.publicKey),
        passphrase: passphrase,
        publicKey: keys.publicKey,
        privateKey: keys.privateKey
    };
    return credentials;
};
github LiskHQ / lisk-sdk-examples / transport / client / scripts / create_and_initialize_packet_account.js View on Github external
const getPacketCredentials = () => {
    const passphrase = Mnemonic.generateMnemonic();
    const keys = cryptography.getPrivateAndPublicKeyFromPassphrase(
        passphrase
    );
    const credentials = {
        address: cryptography.getAddressFromPublicKey(keys.publicKey),
        passphrase: passphrase,
        publicKey: keys.publicKey,
        privateKey: keys.privateKey
    };
    return credentials;
};
github LiskHQ / lisk-sdk / elements / lisk-transactions / src / utils / sign_raw_transaction.ts View on Github external
export const signRawTransaction = ({
	transaction,
	passphrase,
	secondPassphrase,
	timeOffset,
}: SignRawTransactionInput): TransactionJSON => {
	const {
		publicKey,
		address,
	} = cryptography.getAddressAndPublicKeyFromPassphrase(passphrase);
	const senderSecondPublicKey = secondPassphrase
		? cryptography.getPrivateAndPublicKeyFromPassphrase(secondPassphrase)
				.publicKey
		: undefined;

	const propertiesToAdd = {
		senderPublicKey: publicKey,
		senderSecondPublicKey,
		senderId: address,
		timestamp: getTimeWithOffset(timeOffset),
	};

	const transactionWithProperties = {
		...transaction,
		...propertiesToAdd,
	};

	return prepareTransaction(
github LiskHQ / lisk-sdk / protocol-specs / utils / chain_state_builder.js View on Github external
static createAccount() {
		const passphrase = Mnemonic.generateMnemonic();
		const keys = getPrivateAndPublicKeyFromPassphrase(passphrase);
		const address = getAddressFromPrivateKey(keys.privateKey);

		return {
			passphrase,
			privateKey: keys.privateKey,
			publicKey: keys.publicKey,
			address,
			balance: '0',
		};
	}
}
github LiskHQ / lisk-sdk-examples / transport / client / app.js View on Github external
const getPacketCredentials = () => {
        const passphrase = Mnemonic.generateMnemonic();
        const keys = cryptography.getPrivateAndPublicKeyFromPassphrase(
            passphrase
        );
        const credentials = {
            address: cryptography.getAddressFromPublicKey(keys.publicKey),
            passphrase: passphrase,
            publicKey: keys.publicKey,
            privateKey: keys.privateKey
        };
        return credentials;
    };