use of tech.pegasys.teku.spec.datastructures.operations.DepositMessage in project teku by ConsenSys.
the class DataStructureUtil method randomDepositData.
public DepositData randomDepositData() {
BLSKeyPair keyPair = BLSTestUtil.randomKeyPair(nextSeed());
BLSPublicKey pubkey = keyPair.getPublicKey();
Bytes32 withdrawal_credentials = randomBytes32();
DepositMessage proof_of_possession_data = new DepositMessage(pubkey, withdrawal_credentials, getMaxEffectiveBalance());
final Bytes32 domain = computeDomain();
final Bytes signing_root = getSigningRoot(proof_of_possession_data, domain);
BLSSignature proof_of_possession = BLS.sign(keyPair.getSecretKey(), signing_root);
return new DepositData(proof_of_possession_data, proof_of_possession);
}
use of tech.pegasys.teku.spec.datastructures.operations.DepositMessage in project teku by ConsenSys.
the class BlockProcessorTest method processDepositIgnoresDepositWithInvalidPublicKey.
@Test
void processDepositIgnoresDepositWithInvalidPublicKey() throws BlockProcessingException {
// The following deposit uses a "rogue" public key that is not in the G1 group
BLSPublicKey pubkey = BLSPublicKey.fromBytesCompressed(Bytes48.fromHexString("0x9378a6e3984e96d2cd50450c76ca14732f1300efa04aecdb805b22e6d6926a85ef409e8f3acf494a1481090bf32ce3bd"));
Bytes32 withdrawalCredentials = Bytes32.fromHexString("0x79e43d39ee55749c55994a7ab2a3cb91460cec544fdbf27eb5717c43f970c1b6");
UInt64 amount = UInt64.valueOf(1000000000L);
BLSSignature signature = BLSSignature.fromBytesCompressed(Bytes.fromHexString("0xddc1ca509e29c6452441069f26da6e073589b3bd1cace50e3427426af5bfdd566d077d4bdf618e249061b9770471e3d515779aa758b8ccb4b06226a8d5ebc99e19d4c3278e5006b837985bec4e0ce39df92c1f88d1afd0f98dbae360024a390d"));
DepositData depositInput = new DepositData(new DepositMessage(pubkey, withdrawalCredentials, amount), signature);
BeaconState preState = createBeaconState();
int originalValidatorRegistrySize = preState.getValidators().size();
int originalValidatorBalancesSize = preState.getBalances().size();
BeaconState postState = processDepositHelper(preState, depositInput);
assertEquals(postState.getValidators().size(), originalValidatorRegistrySize, "The validator was added to the validator registry.");
assertEquals(postState.getBalances().size(), originalValidatorBalancesSize, "The balance was added to the validator balances.");
assertEquals(preState.getBalances().hashTreeRoot(), postState.getBalances().hashTreeRoot(), "The balances list has changed.");
}
use of tech.pegasys.teku.spec.datastructures.operations.DepositMessage in project teku by ConsenSys.
the class AbstractBlockProcessor method depositSignatureIsValid.
private boolean depositSignatureIsValid(final Deposit deposit, BLSPublicKey pubkey) {
if (!BLS_VERIFY_DEPOSIT) {
return true;
}
final UInt64 amount = deposit.getData().getAmount();
final DepositMessage deposit_message = new DepositMessage(pubkey, deposit.getData().getWithdrawal_credentials(), amount);
final Bytes32 domain = miscHelpers.computeDomain(Domain.DEPOSIT);
final Bytes signing_root = miscHelpers.computeSigningRoot(deposit_message, domain);
// in blocks and processing differs based on whether the signature is valid or not.
return BLS.verify(pubkey, signing_root, deposit.getData().getSignature());
}
use of tech.pegasys.teku.spec.datastructures.operations.DepositMessage in project teku by ConsenSys.
the class DepositGenerator method createDepositData.
public DepositData createDepositData(final BLSKeyPair validatorKeyPair, final UInt64 amountInGwei, final BLSPublicKey withdrawalPublicKey) {
final Bytes32 withdrawalCredentials = createWithdrawalCredentials(withdrawalPublicKey);
final DepositMessage depositMessage = new DepositMessage(validatorKeyPair.getPublicKey(), withdrawalCredentials, amountInGwei);
final SpecVersion specVersion = spec.getGenesisSpec();
final Bytes32 depositDomain = specVersion.miscHelpers().computeDomain(Domain.DEPOSIT);
final BLSSignature signature = signDeposit ? BLS.sign(validatorKeyPair.getSecretKey(), specVersion.miscHelpers().computeSigningRoot(depositMessage, depositDomain)) : BLSSignature.empty();
return new DepositData(depositMessage, signature);
}
Aggregations