mirror of
https://gitlab.com/pulsechaincom/staking-deposit-cli.git
synced 2024-12-23 11:57:19 +00:00
Revert to DepositMessage & DepositData as per spec
This commit is contained in:
parent
f3eee88bc2
commit
d96670d4ff
@ -17,8 +17,8 @@ from eth2deposit.utils.crypto import SHA256
|
|||||||
from eth2deposit.utils.ssz import (
|
from eth2deposit.utils.ssz import (
|
||||||
compute_domain,
|
compute_domain,
|
||||||
compute_signing_root,
|
compute_signing_root,
|
||||||
SignedDeposit,
|
DepositData,
|
||||||
UnsignedDeposit,
|
DepositMessage,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -58,17 +58,17 @@ 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) -> UnsignedDeposit:
|
def unsigned_deposit(self) -> DepositMessage:
|
||||||
return UnsignedDeposit(
|
return DepositMessage(
|
||||||
pubkey=self.signing_pk,
|
pubkey=self.signing_pk,
|
||||||
withdrawal_credentials=self.withdrawal_credentials,
|
withdrawal_credentials=self.withdrawal_credentials,
|
||||||
amount=self.amount,
|
amount=self.amount,
|
||||||
)
|
)
|
||||||
|
|
||||||
def signed_deposit(self) -> SignedDeposit:
|
def signed_deposit(self) -> DepositData:
|
||||||
domain = compute_domain(domain_type=DOMAIN_DEPOSIT)
|
domain = compute_domain(domain_type=DOMAIN_DEPOSIT)
|
||||||
signing_root = compute_signing_root(self.unsigned_deposit(), domain)
|
signing_root = compute_signing_root(self.unsigned_deposit(), domain)
|
||||||
signed_deposit = SignedDeposit(
|
signed_deposit = DepositData(
|
||||||
**self.unsigned_deposit().as_dict(),
|
**self.unsigned_deposit().as_dict(),
|
||||||
signature=bls.Sign(self.signing_sk, signing_root)
|
signature=bls.Sign(self.signing_sk, signing_root)
|
||||||
)
|
)
|
||||||
|
@ -42,7 +42,7 @@ def compute_signing_root(ssz_object: Serializable, domain: bytes) -> bytes:
|
|||||||
return domain_wrapped_object.hash_tree_root
|
return domain_wrapped_object.hash_tree_root
|
||||||
|
|
||||||
|
|
||||||
class UnsignedDeposit(Serializable):
|
class DepositMessage(Serializable):
|
||||||
fields = [
|
fields = [
|
||||||
('pubkey', bytes48),
|
('pubkey', bytes48),
|
||||||
('withdrawal_credentials', bytes32),
|
('withdrawal_credentials', bytes32),
|
||||||
@ -50,7 +50,7 @@ class UnsignedDeposit(Serializable):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class SignedDeposit(Serializable):
|
class DepositData(Serializable):
|
||||||
fields = [
|
fields = [
|
||||||
('pubkey', bytes48),
|
('pubkey', bytes48),
|
||||||
('withdrawal_credentials', bytes32),
|
('withdrawal_credentials', bytes32),
|
||||||
|
@ -10,8 +10,8 @@ from py_ecc.bls import G2ProofOfPossession as bls
|
|||||||
from eth2deposit.utils.ssz import (
|
from eth2deposit.utils.ssz import (
|
||||||
compute_domain,
|
compute_domain,
|
||||||
compute_signing_root,
|
compute_signing_root,
|
||||||
SignedDeposit,
|
DepositData,
|
||||||
UnsignedDeposit,
|
DepositMessage,
|
||||||
)
|
)
|
||||||
from eth2deposit.utils.constants import (
|
from eth2deposit.utils.constants import (
|
||||||
DOMAIN_DEPOSIT,
|
DOMAIN_DEPOSIT,
|
||||||
@ -43,14 +43,14 @@ def validate_deposit(deposit_data_dict: Dict[str, Any]) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# Verify deposit signature && pubkey
|
# 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)
|
domain = compute_domain(domain_type=DOMAIN_DEPOSIT)
|
||||||
signing_root = compute_signing_root(unsigned_deposit, domain)
|
signing_root = compute_signing_root(unsigned_deposit, domain)
|
||||||
if not bls.Verify(pubkey, signing_root, signature):
|
if not bls.Verify(pubkey, signing_root, signature):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Verify Deposit Root
|
# Verify Deposit Root
|
||||||
signed_deposit = SignedDeposit(
|
signed_deposit = DepositData(
|
||||||
pubkey=pubkey,
|
pubkey=pubkey,
|
||||||
withdrawal_credentials=withdrawal_credentials,
|
withdrawal_credentials=withdrawal_credentials,
|
||||||
amount=amount,
|
amount=amount,
|
||||||
|
Loading…
Reference in New Issue
Block a user