From d96670d4ffb7798f166544192b96a590ca9e34cc Mon Sep 17 00:00:00 2001 From: Carl Beekhuizen Date: Mon, 25 May 2020 14:54:36 +0200 Subject: [PATCH] Revert to DepositMessage & DepositData as per spec --- eth2deposit/credentials.py | 12 ++++++------ eth2deposit/utils/ssz.py | 4 ++-- eth2deposit/utils/validation.py | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/eth2deposit/credentials.py b/eth2deposit/credentials.py index 5873f29..99ec291 100644 --- a/eth2deposit/credentials.py +++ b/eth2deposit/credentials.py @@ -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) ) diff --git a/eth2deposit/utils/ssz.py b/eth2deposit/utils/ssz.py index 961bf3f..0246028 100644 --- a/eth2deposit/utils/ssz.py +++ b/eth2deposit/utils/ssz.py @@ -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), diff --git a/eth2deposit/utils/validation.py b/eth2deposit/utils/validation.py index 50bd941..eb41e58 100644 --- a/eth2deposit/utils/validation.py +++ b/eth2deposit/utils/validation.py @@ -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,