Revert to DepositMessage & DepositData as per spec

This commit is contained in:
Carl Beekhuizen 2020-05-25 14:54:36 +02:00
parent f3eee88bc2
commit d96670d4ff
No known key found for this signature in database
GPG Key ID: 8F29E54F49E7AAB5
3 changed files with 12 additions and 12 deletions

View File

@ -17,8 +17,8 @@ from eth2deposit.utils.crypto import SHA256
from eth2deposit.utils.ssz import ( from eth2deposit.utils.ssz import (
compute_domain, compute_domain,
compute_signing_root, compute_signing_root,
SignedDeposit, DepositData,
UnsignedDeposit, DepositMessage,
) )
@ -58,17 +58,17 @@ class Credential:
secret_bytes = saved_keystore.decrypt(password) secret_bytes = saved_keystore.decrypt(password)
return self.signing_sk == int.from_bytes(secret_bytes, 'big') return self.signing_sk == int.from_bytes(secret_bytes, 'big')
def unsigned_deposit(self) -> UnsignedDeposit: def unsigned_deposit(self) -> DepositMessage:
return UnsignedDeposit( return DepositMessage(
pubkey=self.signing_pk, pubkey=self.signing_pk,
withdrawal_credentials=self.withdrawal_credentials, withdrawal_credentials=self.withdrawal_credentials,
amount=self.amount, amount=self.amount,
) )
def signed_deposit(self) -> SignedDeposit: def signed_deposit(self) -> DepositData:
domain = compute_domain(domain_type=DOMAIN_DEPOSIT) domain = compute_domain(domain_type=DOMAIN_DEPOSIT)
signing_root = compute_signing_root(self.unsigned_deposit(), domain) signing_root = compute_signing_root(self.unsigned_deposit(), domain)
signed_deposit = SignedDeposit( signed_deposit = DepositData(
**self.unsigned_deposit().as_dict(), **self.unsigned_deposit().as_dict(),
signature=bls.Sign(self.signing_sk, signing_root) signature=bls.Sign(self.signing_sk, signing_root)
) )

View File

@ -42,7 +42,7 @@ def compute_signing_root(ssz_object: Serializable, domain: bytes) -> bytes:
return domain_wrapped_object.hash_tree_root return domain_wrapped_object.hash_tree_root
class UnsignedDeposit(Serializable): class DepositMessage(Serializable):
fields = [ fields = [
('pubkey', bytes48), ('pubkey', bytes48),
('withdrawal_credentials', bytes32), ('withdrawal_credentials', bytes32),
@ -50,7 +50,7 @@ class UnsignedDeposit(Serializable):
] ]
class SignedDeposit(Serializable): class DepositData(Serializable):
fields = [ fields = [
('pubkey', bytes48), ('pubkey', bytes48),
('withdrawal_credentials', bytes32), ('withdrawal_credentials', bytes32),

View File

@ -10,8 +10,8 @@ from py_ecc.bls import G2ProofOfPossession as bls
from eth2deposit.utils.ssz import ( from eth2deposit.utils.ssz import (
compute_domain, compute_domain,
compute_signing_root, compute_signing_root,
SignedDeposit, DepositData,
UnsignedDeposit, DepositMessage,
) )
from eth2deposit.utils.constants import ( from eth2deposit.utils.constants import (
DOMAIN_DEPOSIT, DOMAIN_DEPOSIT,
@ -43,14 +43,14 @@ def validate_deposit(deposit_data_dict: Dict[str, Any]) -> bool:
return False return False
# Verify deposit signature && pubkey # Verify deposit signature && pubkey
unsigned_deposit = UnsignedDeposit(pubkey=pubkey, withdrawal_credentials=withdrawal_credentials, amount=amount) unsigned_deposit = DepositMessage(pubkey=pubkey, withdrawal_credentials=withdrawal_credentials, amount=amount)
domain = compute_domain(domain_type=DOMAIN_DEPOSIT) domain = compute_domain(domain_type=DOMAIN_DEPOSIT)
signing_root = compute_signing_root(unsigned_deposit, domain) signing_root = compute_signing_root(unsigned_deposit, domain)
if not bls.Verify(pubkey, signing_root, signature): if not bls.Verify(pubkey, signing_root, signature):
return False return False
# Verify Deposit Root # Verify Deposit Root
signed_deposit = SignedDeposit( signed_deposit = DepositData(
pubkey=pubkey, pubkey=pubkey,
withdrawal_credentials=withdrawal_credentials, withdrawal_credentials=withdrawal_credentials,
amount=amount, amount=amount,