Advertisement
Sweetening

Smart Contract PWN

Nov 22nd, 2023 (edited)
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. from eth2.beacon.deposit_contract import IDepositContract
  2. from eth2.beacon.deposit_data import DepositData
  3. from eth2.beacon.signature_helpers import sign_deposit_data
  4. from eth2.utils.ssz import encode_ssz
  5.  
  6. def submit_deposit_data(
  7. deposit_contract: IDepositContract,
  8. pubkey: bytes,
  9. withdrawal_credentials: bytes,
  10. signature: bytes,
  11. deposit_data_root: bytes32,
  12. ) -> None:
  13. deposit_data = DepositData(
  14. pubkey=pubkey,
  15. withdrawal_credentials=withdrawal_credentials,
  16. signature=signature,
  17. )
  18.  
  19. encoded_deposit_data = encode_ssz(deposit_data)
  20. assert deposit_data_root == sha256(encoded_deposit_data).digest()
  21.  
  22. deposit_contract.deposit(
  23. pubkey=pubkey,
  24. withdrawal_credentials=withdrawal_credentials,
  25. signature=signature,
  26. deposit_data_root=deposit_data_root,
  27. )
  28.  
  29. if __name__ == "__main__":
  30. deposit_contract = IDepositContract.deploy()
  31.  
  32. pubkey = bytes.fromhex("0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
  33. withdrawal_credentials = bytes.fromhex(
  34. "0x2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f"
  35. )
  36. signature = bytes.fromhex(
  37. "0x4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f"
  38. )
  39. deposit_data_root = bytes.fromhex(
  40. "0x672b0185ac4dc1b7ef0fd4d0820a893c4862e648bacadef997957c3b825d9383"
  41. )
  42.  
  43. submit_deposit_data(
  44. deposit_contract=deposit_contract,
  45. pubkey=pubkey,
  46. withdrawal_credentials=withdrawal_credentials,
  47. signature=signature,
  48. deposit_data_root=deposit_data_root,
  49. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement