Skip to content

Commit

Permalink
Rename json file fields
Browse files Browse the repository at this point in the history
1. `deposit_data_root` -> `deposit_message_root`
2. `signed_deposit_data_root` -> `deposit_data_root`
  • Loading branch information
hwwhww committed Jun 2, 2020
1 parent a784a73 commit dbac6d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions eth2deposit/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions eth2deposit/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ 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
if not MIN_DEPOSIT_AMOUNT < amount <= MAX_DEPOSIT_AMOUNT:
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

Expand All @@ -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

0 comments on commit dbac6d2

Please sign in to comment.