Search in sources :

Example 1 with SCryptParam

use of tech.pegasys.signers.bls.keystore.model.SCryptParam 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 SCryptParam

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

the class DecryptionKeyTest method sCryptDecryptionKeyGeneration.

@Test
void sCryptDecryptionKeyGeneration() {
    final SCryptParam kdfParam = new SCryptParam(DKLEN, MEMORY_CPU_COST, PARALLELIZATION, BLOCKSIZE, SALT);
    final Bytes decryptionKey = kdfParam.generateDecryptionKey(PASSWORD);
    assertThat(decryptionKey.size()).isEqualTo(DKLEN);
    assertThat(decryptionKey).isEqualTo(SCRYPT_DERIVED_KEY);
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) SCryptParam(tech.pegasys.signers.bls.keystore.model.SCryptParam) Test(org.junit.jupiter.api.Test)

Example 3 with SCryptParam

use of tech.pegasys.signers.bls.keystore.model.SCryptParam 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 SCryptParam

use of tech.pegasys.signers.bls.keystore.model.SCryptParam 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 SCryptParam

use of tech.pegasys.signers.bls.keystore.model.SCryptParam 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

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