Search in sources :

Example 1 with VoluntaryExit

use of tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit in project teku by ConsenSys.

the class LocalSignerTest method shouldSignVoluntaryExit.

@Test
public void shouldSignVoluntaryExit() {
    final VoluntaryExit voluntaryExit = dataStructureUtil.randomVoluntaryExit();
    final BLSSignature expectedSignature = BLSSignature.fromBytesCompressed(Bytes.fromBase64String("qumUYTSgi8hmsS3/a1oDLGSIfOQ4+PgByZpDprnvlQKaDTXnlzGQloQ/W0kAeMa8EhXvGvF0OiGkQxEEznpVsFNhZ01H+3S2StWqq7S0mbRcbJhT6fEcyrOMqRer36q8"));
    final SafeFuture<BLSSignature> result = signer.signVoluntaryExit(voluntaryExit, fork);
    asyncRunner.executeQueuedActions();
    assertThat(result).isCompletedWithValue(expectedSignature);
}
Also used : VoluntaryExit(tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit) BLSSignature(tech.pegasys.teku.bls.BLSSignature) Test(org.junit.jupiter.api.Test)

Example 2 with VoluntaryExit

use of tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit in project teku by ConsenSys.

the class DeletableSignerTest method signVoluntaryExit_shouldSignWhenActive.

@Test
void signVoluntaryExit_shouldSignWhenActive() {
    final VoluntaryExit aggregateAndProof = dataStructureUtil.randomVoluntaryExit();
    when(delegate.signVoluntaryExit(aggregateAndProof, forkInfo)).thenReturn(signatureFuture);
    assertThatSafeFuture(signer.signVoluntaryExit(aggregateAndProof, forkInfo)).isCompletedWithValue(signature);
}
Also used : VoluntaryExit(tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit) Test(org.junit.jupiter.api.Test)

Example 3 with VoluntaryExit

use of tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit in project teku by ConsenSys.

the class VoluntaryExitGenerator method create.

private SignedVoluntaryExit create(ForkInfo forkInfo, UInt64 epoch, int validatorIndex, boolean valid) {
    VoluntaryExit exit = new VoluntaryExit(epoch, UInt64.valueOf(validatorIndex));
    BLSSignature exitSignature = new LocalSigner(spec, getKeypair(validatorIndex, valid), SYNC_RUNNER).signVoluntaryExit(exit, forkInfo).join();
    return new SignedVoluntaryExit(exit, exitSignature);
}
Also used : SignedVoluntaryExit(tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit) LocalSigner(tech.pegasys.teku.core.signatures.LocalSigner) VoluntaryExit(tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit) SignedVoluntaryExit(tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit) BLSSignature(tech.pegasys.teku.bls.BLSSignature)

Example 4 with VoluntaryExit

use of tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit in project teku by ConsenSys.

the class VoluntaryExitCommand method submitExitForValidator.

private void submitExitForValidator(final BLSPublicKey publicKey, final int validatorIndex) {
    try {
        final ForkInfo forkInfo = new ForkInfo(fork, genesisRoot);
        final VoluntaryExit message = new VoluntaryExit(epoch, UInt64.valueOf(validatorIndex));
        final BLSSignature signature = validators.getValidator(publicKey).orElseThrow().getSigner().signVoluntaryExit(message, forkInfo).join();
        apiClient.sendVoluntaryExit(new SignedVoluntaryExit(message, signature));
        SUB_COMMAND_LOG.display("Exit for validator " + publicKey.toAbbreviatedString() + " submitted.");
    } catch (IllegalArgumentException ex) {
        SUB_COMMAND_LOG.error("Failed to submit exit for validator " + publicKey.toAbbreviatedString());
        SUB_COMMAND_LOG.error(ex.getMessage());
    }
}
Also used : SignedVoluntaryExit(tech.pegasys.teku.api.schema.SignedVoluntaryExit) ForkInfo(tech.pegasys.teku.spec.datastructures.state.ForkInfo) SignedVoluntaryExit(tech.pegasys.teku.api.schema.SignedVoluntaryExit) VoluntaryExit(tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit) BLSSignature(tech.pegasys.teku.bls.BLSSignature)

Example 5 with VoluntaryExit

use of tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit in project teku by ConsenSys.

the class OperationSignatureVerifier method verifyVoluntaryExitSignature.

public boolean verifyVoluntaryExitSignature(Fork fork, BeaconState state, SignedVoluntaryExit signedExit, BLSSignatureVerifier signatureVerifier) {
    final VoluntaryExit exit = signedExit.getMessage();
    Optional<BLSPublicKey> maybePublicKey = beaconStateAccessors.getValidatorPubKey(state, exit.getValidatorIndex());
    if (maybePublicKey.isEmpty()) {
        return false;
    }
    final Bytes32 domain = beaconStateAccessors.getDomain(Domain.VOLUNTARY_EXIT, exit.getEpoch(), fork, state.getGenesis_validators_root());
    final Bytes signing_root = miscHelpers.computeSigningRoot(exit, domain);
    return signatureVerifier.verify(maybePublicKey.get(), signing_root, signedExit.getSignature());
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) SignedVoluntaryExit(tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit) VoluntaryExit(tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit) BLSPublicKey(tech.pegasys.teku.bls.BLSPublicKey) Bytes32(org.apache.tuweni.bytes.Bytes32)

Aggregations

VoluntaryExit (tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit)8 Test (org.junit.jupiter.api.Test)5 BLSSignature (tech.pegasys.teku.bls.BLSSignature)4 SignedVoluntaryExit (tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit)2 Bytes (org.apache.tuweni.bytes.Bytes)1 Bytes32 (org.apache.tuweni.bytes.Bytes32)1 SignedVoluntaryExit (tech.pegasys.teku.api.schema.SignedVoluntaryExit)1 BLSPublicKey (tech.pegasys.teku.bls.BLSPublicKey)1 LocalSigner (tech.pegasys.teku.core.signatures.LocalSigner)1 ForkInfo (tech.pegasys.teku.spec.datastructures.state.ForkInfo)1