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 (
compute_domain,
compute_signing_root,
SignedDeposit,
UnsignedDeposit,
DepositData,
DepositMessage,
)
@ -58,17 +58,17 @@ class Credential:
secret_bytes = saved_keystore.decrypt(password)
return self.signing_sk == int.from_bytes(secret_bytes, 'big')
def unsigned_deposit(self) -> UnsignedDeposit:
return UnsignedDeposit(
def unsigned_deposit(self) -> DepositMessage:
return DepositMessage(
pubkey=self.signing_pk,
withdrawal_credentials=self.withdrawal_credentials,
amount=self.amount,
)
def signed_deposit(self) -> SignedDeposit:
def signed_deposit(self) -> DepositData:
domain = compute_domain(domain_type=DOMAIN_DEPOSIT)
signing_root = compute_signing_root(self.unsigned_deposit(), domain)
signed_deposit = SignedDeposit(
signed_deposit = DepositData(
**self.unsigned_deposit().as_dict(),
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
class UnsignedDeposit(Serializable):
class DepositMessage(Serializable):
fields = [
('pubkey', bytes48),
('withdrawal_credentials', bytes32),
@ -50,7 +50,7 @@ class UnsignedDeposit(Serializable):
]
class SignedDeposit(Serializable):
class DepositData(Serializable):
fields = [
('pubkey', bytes48),
('withdrawal_credentials', bytes32),

View File

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