use of tech.pegasys.teku.bls.BLSKeyPair in project teku by ConsenSys.
the class EncryptedKeystoreWriterTest method keysAreWrittenToEncryptedKeystores.
@Test
void keysAreWrittenToEncryptedKeystores(@TempDir final Path tempDir) {
final KeysWriter keysWriter = new EncryptedKeystoreWriter(SecureRandomProvider.createSecureRandom(), PASSWORD, PASSWORD, tempDir, System.out::println);
keysWriter.writeKeys(new BLSKeyPair(validator1SecretKey), new BLSKeyPair(withdrawal1SecretKey));
assertKeyStoreCreatedAndCanBeDecrypted(tempDir.resolve(trimPublicKey(validator1PubKey) + "_validator.json"), validator1SecretKey);
assertKeyStoreCreatedAndCanBeDecrypted(tempDir.resolve(trimPublicKey(validator1PubKey) + "_withdrawal.json"), withdrawal1SecretKey);
keysWriter.writeKeys(new BLSKeyPair(validator2SecretKey), new BLSKeyPair(withdrawal2SecretKey));
assertKeyStoreCreatedAndCanBeDecrypted(tempDir.resolve(trimPublicKey(validator2PubKey) + "_validator.json"), validator2SecretKey);
assertKeyStoreCreatedAndCanBeDecrypted(tempDir.resolve(trimPublicKey(validator2PubKey) + "_withdrawal.json"), withdrawal2SecretKey);
}
use of tech.pegasys.teku.bls.BLSKeyPair in project teku by ConsenSys.
the class ActiveKeyManagerTest method shouldReturnActiveRemoteValidatorsList.
@Test
void shouldReturnActiveRemoteValidatorsList() throws MalformedURLException {
final BLSKeyPair keyPair1 = BLSTestUtil.randomKeyPair(1);
final BLSKeyPair keyPair2 = BLSTestUtil.randomKeyPair(2);
final BLSKeyPair keyPair3 = BLSTestUtil.randomKeyPair(3);
final Validator validator1 = new Validator(keyPair1.getPublicKey(), NO_OP_REMOTE_SIGNER, Optional::empty, true);
final Validator validator2 = new Validator(keyPair2.getPublicKey(), NO_OP_REMOTE_SIGNER, Optional::empty, false);
final Validator validator3 = new Validator(keyPair3.getPublicKey(), NO_OP_SIGNER, Optional::empty, false);
List<Validator> activeValidators = Arrays.asList(validator1, validator2, validator3);
when(ownedValidators.getActiveValidators()).thenReturn(activeValidators);
when(validatorLoader.getOwnedValidators()).thenReturn(ownedValidators);
final List<ExternalValidator> result = keyManager.getActiveRemoteValidatorKeys();
List<ExternalValidator> externalValidators = Arrays.asList(new ExternalValidator(keyPair1.getPublicKey(), Optional.of(new URL("http://example.com/")), true), new ExternalValidator(keyPair2.getPublicKey(), Optional.of(new URL("http://example.com/")), false));
assertThat(result).isEqualTo(externalValidators);
}
use of tech.pegasys.teku.bls.BLSKeyPair in project teku by ConsenSys.
the class GetKeysTest method getValidatorList.
private List<Validator> getValidatorList() {
BLSKeyPair keyPair1 = BLSTestUtil.randomKeyPair(1);
BLSKeyPair keyPair2 = BLSTestUtil.randomKeyPair(2);
Validator validator1 = new Validator(keyPair1.getPublicKey(), NO_OP_SIGNER, Optional::empty, true);
Validator validator2 = new Validator(keyPair2.getPublicKey(), NO_OP_SIGNER, Optional::empty, false);
return Arrays.asList(validator1, validator2);
}
use of tech.pegasys.teku.bls.BLSKeyPair in project teku by ConsenSys.
the class GetRemoteKeysTest method getValidatorList.
private List<Validator> getValidatorList() {
BLSKeyPair keyPair1 = BLSTestUtil.randomKeyPair(1);
BLSKeyPair keyPair2 = BLSTestUtil.randomKeyPair(2);
Validator validator1 = new Validator(keyPair1.getPublicKey(), NO_OP_REMOTE_SIGNER, Optional::empty, false);
Validator validator2 = new Validator(keyPair2.getPublicKey(), NO_OP_REMOTE_SIGNER, Optional::empty, false);
return Arrays.asList(validator1, validator2);
}
use of tech.pegasys.teku.bls.BLSKeyPair in project web3signer by ConsenSys.
the class MetadataFileHelpers method createRandomUnencryptedBlsKeys.
public void createRandomUnencryptedBlsKeys(final Path directory, final int numberOfKeys) {
final SecureRandom secureRandom = new SecureRandom();
final MetadataFileHelpers metadataFileHelpers = new MetadataFileHelpers();
for (int i = 0; i < numberOfKeys; i++) {
final BLSKeyPair keyPair = BLSKeyPair.random(secureRandom);
final String privateKey = keyPair.getSecretKey().toBytes().toHexString();
final Path filename = directory.resolve(keyPair.getPublicKey().toString() + ".yaml");
metadataFileHelpers.createUnencryptedYamlFileAt(filename, privateKey, KeyType.BLS);
}
}
Aggregations