Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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;
}
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')),
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')),
};
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')),
};
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')),
};