mirror of
https://gitlab.com/pulsechaincom/staking-deposit-cli.git
synced 2024-12-23 11:57:19 +00:00
Rename json file fields
1. `deposit_data_root` -> `deposit_message_root` 2. `signed_deposit_data_root` -> `deposit_data_root`
This commit is contained in:
parent
a784a73cdd
commit
dbac6d236b
@ -66,7 +66,7 @@ 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) -> DepositMessage:
|
def deposit_message(self) -> DepositMessage:
|
||||||
return DepositMessage(
|
return DepositMessage(
|
||||||
pubkey=self.signing_pk,
|
pubkey=self.signing_pk,
|
||||||
withdrawal_credentials=self.withdrawal_credentials,
|
withdrawal_credentials=self.withdrawal_credentials,
|
||||||
@ -75,9 +75,9 @@ class Credential:
|
|||||||
|
|
||||||
def signed_deposit(self) -> DepositData:
|
def signed_deposit(self) -> DepositData:
|
||||||
domain = compute_deposit_domain(fork_version=self.fork_version)
|
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(
|
signed_deposit = DepositData(
|
||||||
**self.unsigned_deposit().as_dict(),
|
**self.deposit_message().as_dict(),
|
||||||
signature=bls.Sign(self.signing_sk, signing_root)
|
signature=bls.Sign(self.signing_sk, signing_root)
|
||||||
)
|
)
|
||||||
return signed_deposit
|
return signed_deposit
|
||||||
@ -108,8 +108,8 @@ class CredentialList:
|
|||||||
for credential in self.credentials:
|
for credential in self.credentials:
|
||||||
signed_deposit_datum = credential.signed_deposit()
|
signed_deposit_datum = credential.signed_deposit()
|
||||||
datum_dict = signed_deposit_datum.as_dict()
|
datum_dict = signed_deposit_datum.as_dict()
|
||||||
datum_dict.update({'deposit_data_root': credential.unsigned_deposit().hash_tree_root})
|
datum_dict.update({'deposit_message_root': credential.deposit_message().hash_tree_root})
|
||||||
datum_dict.update({'signed_deposit_data_root': signed_deposit_datum.hash_tree_root})
|
datum_dict.update({'deposit_data_root': signed_deposit_datum.hash_tree_root})
|
||||||
datum_dict.update({'fork_version': credential.fork_version})
|
datum_dict.update({'fork_version': credential.fork_version})
|
||||||
deposit_data.append(datum_dict)
|
deposit_data.append(datum_dict)
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ def validate_deposit(deposit_data_dict: Dict[str, Any]) -> bool:
|
|||||||
withdrawal_credentials = bytes.fromhex(deposit_data_dict['withdrawal_credentials'])
|
withdrawal_credentials = bytes.fromhex(deposit_data_dict['withdrawal_credentials'])
|
||||||
amount = deposit_data_dict['amount']
|
amount = deposit_data_dict['amount']
|
||||||
signature = BLSSignature(bytes.fromhex(deposit_data_dict['signature']))
|
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'])
|
fork_version = bytes.fromhex(deposit_data_dict['fork_version'])
|
||||||
|
|
||||||
# Verify deposit amount
|
# Verify deposit amount
|
||||||
@ -43,9 +43,9 @@ def validate_deposit(deposit_data_dict: Dict[str, Any]) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# Verify deposit signature && pubkey
|
# 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)
|
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):
|
if not bls.Verify(pubkey, signing_root, signature):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -56,4 +56,4 @@ def validate_deposit(deposit_data_dict: Dict[str, Any]) -> bool:
|
|||||||
amount=amount,
|
amount=amount,
|
||||||
signature=signature,
|
signature=signature,
|
||||||
)
|
)
|
||||||
return signed_deposit.hash_tree_root == deposit_data_root
|
return signed_deposit.hash_tree_root == deposit_message_root
|
||||||
|
Loading…
Reference in New Issue
Block a user