From dbac6d236b1627221d8339f2ff8ec1d9ba1cb500 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Tue, 2 Jun 2020 20:19:52 +0800 Subject: [PATCH] Rename json file fields 1. `deposit_data_root` -> `deposit_message_root` 2. `signed_deposit_data_root` -> `deposit_data_root` --- eth2deposit/credentials.py | 10 +++++----- eth2deposit/utils/validation.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/eth2deposit/credentials.py b/eth2deposit/credentials.py index 7518b63b..34be04bb 100644 --- a/eth2deposit/credentials.py +++ b/eth2deposit/credentials.py @@ -66,7 +66,7 @@ def verify_keystore(self, keystore_filefolder: str, password: str) -> bool: secret_bytes = saved_keystore.decrypt(password) return self.signing_sk == int.from_bytes(secret_bytes, 'big') - def unsigned_deposit(self) -> DepositMessage: + def deposit_message(self) -> DepositMessage: return DepositMessage( pubkey=self.signing_pk, withdrawal_credentials=self.withdrawal_credentials, @@ -75,9 +75,9 @@ def unsigned_deposit(self) -> DepositMessage: def signed_deposit(self) -> DepositData: domain = compute_deposit_domain(fork_version=self.fork_version) - signing_root = compute_signing_root(self.unsigned_deposit(), domain) + signing_root = compute_signing_root(self.deposit_message(), domain) signed_deposit = DepositData( - **self.unsigned_deposit().as_dict(), + **self.deposit_message().as_dict(), signature=bls.Sign(self.signing_sk, signing_root) ) return signed_deposit @@ -108,8 +108,8 @@ def export_deposit_data_json(self, folder: str) -> str: for credential in self.credentials: signed_deposit_datum = credential.signed_deposit() datum_dict = signed_deposit_datum.as_dict() - datum_dict.update({'deposit_data_root': credential.unsigned_deposit().hash_tree_root}) - datum_dict.update({'signed_deposit_data_root': signed_deposit_datum.hash_tree_root}) + datum_dict.update({'deposit_message_root': credential.deposit_message().hash_tree_root}) + datum_dict.update({'deposit_data_root': signed_deposit_datum.hash_tree_root}) datum_dict.update({'fork_version': credential.fork_version}) deposit_data.append(datum_dict) diff --git a/eth2deposit/utils/validation.py b/eth2deposit/utils/validation.py index ff309c5b..03c3fde6 100644 --- a/eth2deposit/utils/validation.py +++ b/eth2deposit/utils/validation.py @@ -35,7 +35,7 @@ def validate_deposit(deposit_data_dict: Dict[str, Any]) -> bool: withdrawal_credentials = bytes.fromhex(deposit_data_dict['withdrawal_credentials']) amount = deposit_data_dict['amount'] signature = BLSSignature(bytes.fromhex(deposit_data_dict['signature'])) - deposit_data_root = bytes.fromhex(deposit_data_dict['signed_deposit_data_root']) + deposit_message_root = bytes.fromhex(deposit_data_dict['deposit_data_root']) fork_version = bytes.fromhex(deposit_data_dict['fork_version']) # Verify deposit amount @@ -43,9 +43,9 @@ def validate_deposit(deposit_data_dict: Dict[str, Any]) -> bool: return False # Verify deposit signature && pubkey - unsigned_deposit = DepositMessage(pubkey=pubkey, withdrawal_credentials=withdrawal_credentials, amount=amount) + deposit_message = DepositMessage(pubkey=pubkey, withdrawal_credentials=withdrawal_credentials, amount=amount) domain = compute_deposit_domain(fork_version) - signing_root = compute_signing_root(unsigned_deposit, domain) + signing_root = compute_signing_root(deposit_message, domain) if not bls.Verify(pubkey, signing_root, signature): return False @@ -56,4 +56,4 @@ def validate_deposit(deposit_data_dict: Dict[str, Any]) -> bool: amount=amount, signature=signature, ) - return signed_deposit.hash_tree_root == deposit_data_root + return signed_deposit.hash_tree_root == deposit_message_root