use of tech.pegasys.signers.bls.keystore.model.Pbkdf2Param in project signers by ConsenSys.
the class KeyStoreTest method encryptUsingPBKDF2AndSaveKeyStore.
@Test
void encryptUsingPBKDF2AndSaveKeyStore(@TempDir final Path tempDir) throws IOException {
final KdfParam kdfParam = new Pbkdf2Param(DKLEN, ITERATIVE_COUNT, Pbkdf2PseudoRandomFunction.HMAC_SHA256, SALT);
encryptSaveAndReloadKeyStore(tempDir, kdfParam);
}
use of tech.pegasys.signers.bls.keystore.model.Pbkdf2Param in project signers by ConsenSys.
the class DecryptionKeyTest method pbkdf2DecryptionKeyGeneration.
@Test
void pbkdf2DecryptionKeyGeneration() {
final Pbkdf2Param kdfParam = new Pbkdf2Param(DKLEN, ITERATIVE_COUNT, Pbkdf2PseudoRandomFunction.HMAC_SHA256, SALT);
final Bytes decryptionKey = kdfParam.generateDecryptionKey(PASSWORD);
assertThat(decryptionKey.size()).isEqualTo(DKLEN);
assertThat(decryptionKey).isEqualTo(PBKDF2_DERIVED_KEY);
}
use of tech.pegasys.signers.bls.keystore.model.Pbkdf2Param in project web3signer by ConsenSys.
the class MetadataFileHelpers method createKeyStoreFile.
private void createKeyStoreFile(final Path keyStoreFilePath, final String password, final Bytes privateKey, final Bytes publicKey, final KdfFunction kdfFunctionType) {
final KdfParam kdfParam = kdfFunctionType == KdfFunction.SCRYPT ? new SCryptParam(32, SALT) : new Pbkdf2Param(32, 262144, HMAC_SHA256, SALT);
final Cipher cipher = new Cipher(CipherFunction.AES_128_CTR, IV);
final KeyStoreData keyStoreData = KeyStore.encrypt(privateKey, publicKey, password, "m/12381/3600/0/0/0", kdfParam, cipher);
try {
KeyStoreLoader.saveToFile(keyStoreFilePath, keyStoreData);
} catch (IOException e) {
fail("Unable to create keystore file", e);
}
}
use of tech.pegasys.signers.bls.keystore.model.Pbkdf2Param in project web3signer by ConsenSys.
the class KeystoreUtil method createKeystoreFile.
public static void createKeystoreFile(final BLSKeyPair keyPair, final Path keystoreDir, final String password) {
final KdfParam kdfParam = new Pbkdf2Param(32, 2, HMAC_SHA256, SALT);
final Cipher cipher = new Cipher(CipherFunction.AES_128_CTR, IV);
final Bytes48 publicKey = keyPair.getPublicKey().toBytesCompressed();
final KeyStoreData keyStoreData = KeyStore.encrypt(keyPair.getSecretKey().toBytes(), publicKey, password, "", kdfParam, cipher);
try {
KeyStoreLoader.saveToFile(keystoreDir.resolve(publicKey + ".json"), keyStoreData);
publicKey.toHexString();
} catch (IOException e) {
throw new IllegalStateException("Unable to create keystore file", e);
}
}
use of tech.pegasys.signers.bls.keystore.model.Pbkdf2Param in project web3signer by ConsenSys.
the class FileValidatorManagerTest method createKeystoreString.
private String createKeystoreString() throws JsonProcessingException {
final Cipher cipher = new Cipher(CipherFunction.AES_128_CTR, IV);
final Pbkdf2Param pbkdf2Param = new Pbkdf2Param(32, 262144, HMAC_SHA256, SALT);
final KeyStoreData keyStoreData = KeyStore.encrypt(BLS_KEY_PAIR.getSecretKey().toBytes(), BLS_KEY_PAIR.getPublicKey().toBytesCompressed(), "password", "", pbkdf2Param, cipher);
return OBJECT_MAPPER.writeValueAsString(keyStoreData);
}
Aggregations