Search in sources :

Example 1 with KdfParam

use of tech.pegasys.signers.bls.keystore.model.KdfParam in project signers by ConsenSys.

the class KeyStoreTest method encryptUsingSCryptAndSaveKeyStore.

@Test
void encryptUsingSCryptAndSaveKeyStore(@TempDir final Path tempDir) throws IOException {
    final KdfParam kdfParam = new SCryptParam(DKLEN, MEMORY_CPU_COST, PARALLELIZATION, BLOCKSIZE, SALT);
    encryptSaveAndReloadKeyStore(tempDir, kdfParam);
}
Also used : SCryptParam(tech.pegasys.signers.bls.keystore.model.SCryptParam) KdfParam(tech.pegasys.signers.bls.keystore.model.KdfParam) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with KdfParam

use of tech.pegasys.signers.bls.keystore.model.KdfParam 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);
}
Also used : KdfParam(tech.pegasys.signers.bls.keystore.model.KdfParam) Pbkdf2Param(tech.pegasys.signers.bls.keystore.model.Pbkdf2Param) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with KdfParam

use of tech.pegasys.signers.bls.keystore.model.KdfParam in project web3signer by ConsenSys.

the class BlsArtifactSignerFactoryTest method createKeyStoreFile.

private static void createKeyStoreFile(final Path keyStoreFilePath, final String password, final Bytes privateKey, final Bytes publicKey) {
    final KdfParam kdfParam = new SCryptParam(32, KEYSTORE_SALT);
    final Cipher cipher = new Cipher(CipherFunction.AES_128_CTR, Bytes.fromHexString("e0f20a27d160f7cc92764579390e881a"));
    final KeyStoreData keyStoreData = KeyStore.encrypt(privateKey, publicKey, password, "", kdfParam, cipher);
    try {
        KeyStoreLoader.saveToFile(keyStoreFilePath, keyStoreData);
    } catch (IOException e) {
        fail("Unable to create keystore file", e);
    }
}
Also used : SCryptParam(tech.pegasys.signers.bls.keystore.model.SCryptParam) KdfParam(tech.pegasys.signers.bls.keystore.model.KdfParam) Cipher(tech.pegasys.signers.bls.keystore.model.Cipher) IOException(java.io.IOException) KeyStoreData(tech.pegasys.signers.bls.keystore.model.KeyStoreData)

Example 4 with KdfParam

use of tech.pegasys.signers.bls.keystore.model.KdfParam 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);
    }
}
Also used : SCryptParam(tech.pegasys.signers.bls.keystore.model.SCryptParam) KdfParam(tech.pegasys.signers.bls.keystore.model.KdfParam) Cipher(tech.pegasys.signers.bls.keystore.model.Cipher) IOException(java.io.IOException) KeyStoreData(tech.pegasys.signers.bls.keystore.model.KeyStoreData) Pbkdf2Param(tech.pegasys.signers.bls.keystore.model.Pbkdf2Param)

Example 5 with KdfParam

use of tech.pegasys.signers.bls.keystore.model.KdfParam in project web3signer by ConsenSys.

the class BlsArtifactSignerFactoryTest method createKeyStoreFile.

private static void createKeyStoreFile(final Path keyStoreFilePath, final String password, final Bytes privateKey, final Bytes publicKey) {
    final KdfParam kdfParam = new SCryptParam(32, KEYSTORE_SALT);
    final Cipher cipher = new Cipher(CipherFunction.AES_128_CTR, Bytes.fromHexString("e0f20a27d160f7cc92764579390e881a"));
    final KeyStoreData keyStoreData = KeyStore.encrypt(privateKey, publicKey, password, "", kdfParam, cipher);
    try {
        KeyStoreLoader.saveToFile(keyStoreFilePath, keyStoreData);
    } catch (IOException e) {
        fail("Unable to create keystore file", e);
    }
}
Also used : SCryptParam(tech.pegasys.signers.bls.keystore.model.SCryptParam) KdfParam(tech.pegasys.signers.bls.keystore.model.KdfParam) Cipher(tech.pegasys.signers.bls.keystore.model.Cipher) IOException(java.io.IOException) KeyStoreData(tech.pegasys.signers.bls.keystore.model.KeyStoreData)

Aggregations

KdfParam (tech.pegasys.signers.bls.keystore.model.KdfParam)8 Cipher (tech.pegasys.signers.bls.keystore.model.Cipher)6 Pbkdf2Param (tech.pegasys.signers.bls.keystore.model.Pbkdf2Param)5 IOException (java.io.IOException)4 KeyStoreData (tech.pegasys.signers.bls.keystore.model.KeyStoreData)4 SCryptParam (tech.pegasys.signers.bls.keystore.model.SCryptParam)4 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 Bytes48 (org.apache.tuweni.bytes.Bytes48)1