calculatorcompute_deposit_data_root

Compute deposit data root hash for validator deposits

Compute the deposit data root hash (SHA-256 SSZ hash tree root) for validator deposits.

Overview

compute_deposit_data_root() computes the 32-byte deposit data root hash that must be passed to the deposit contract's deposit() function. This hash is computed using SSZ (Simple Serialize) hash tree root over the deposit data structure and mirrors the on-chain verification logic in DepositContract.sol.

The function validates all input lengths and raises ValueError if any parameter has the wrong byte length.

Signature

def compute_deposit_data_root(
    *,
    node_pubkey: bytes,
    consensus_pubkey: bytes,
    withdrawal_credentials: bytes,
    node_signature: bytes,
    consensus_signature: bytes,
    amount_gwei: int,
) -> bytes

Import

from seismic_web3 import compute_deposit_data_root

Parameters

Parameter
Type
Required
Description

node_pubkey

bytes

Yes

32-byte ED25519 public key for node identity

consensus_pubkey

bytes

Yes

48-byte BLS12-381 public key for consensus

withdrawal_credentials

bytes

Yes

32-byte withdrawal credentials (use make_withdrawal_credentials())

node_signature

bytes

Yes

64-byte ED25519 signature over deposit data

consensus_signature

bytes

Yes

96-byte BLS12-381 signature over deposit data

amount_gwei

int

Yes

Deposit amount in gwei (e.g., 32_000_000_000 for 32 ETH)

Note: All parameters are keyword-only. You must use name=value syntax when calling.

Returns

Type
Description

bytes

32-byte deposit data root hash (SHA-256 SSZ hash tree root)

Examples

Basic Usage

Complete Deposit Flow

Varying Deposit Amounts

Verifying Deposit Data

How It Works

The function computes the SSZ hash tree root using the following structure:

  1. Public Key Root:

  2. Signature Root:

  3. Final Root:

Where:

  • amount is encoded as 8-byte little-endian gwei value

  • padding extends data to chunk boundaries (16/32/64 bytes)

  • All hashes are SHA-256

Parameter Requirements

node_pubkey (32 bytes)

ED25519 public key for node identity:

consensus_pubkey (48 bytes)

BLS12-381 public key for consensus:

withdrawal_credentials (32 bytes)

ETH1-style withdrawal credentials:

Format: 0x01 + 11 zero bytes + 20-byte address

node_signature (64 bytes)

ED25519 signature over deposit message:

consensus_signature (96 bytes)

BLS12-381 signature over deposit message:

amount_gwei (integer)

Deposit amount in gwei (10⁹ wei):

Error Handling

Validation

The function validates all input lengths:

Parameter
Expected Length
Error if Wrong

node_pubkey

32 bytes

ValueError

consensus_pubkey

48 bytes

ValueError

withdrawal_credentials

32 bytes

ValueError

node_signature

64 bytes

ValueError

consensus_signature

96 bytes

ValueError

amount_gwei

Any int

No validation

Security Considerations

Signature Verification

  • Signatures must be valid for the deposit data

  • On-chain contract will verify signatures match pubkeys

  • Invalid signatures will cause deposit to revert

Amount Consistency

  • amount_gwei in root computation must match transaction value

  • Contract receives value in wei (not gwei)

  • Convert correctly: value_wei = amount_gwei * 10**9

Root Uniqueness

  • Different deposit data produces different roots

  • Changing any parameter changes the root

  • Root acts as commitment to all deposit parameters

Key Reuse

  • Never reuse validator keys across networks

  • Each network should have unique keys

  • Reusing keys can lead to slashing

Common Pitfalls

Wrong Unit Conversion

Mismatched Transaction Value

Wrong Byte Length

When to Use

Use compute_deposit_data_root() when:

  • Making a validator deposit

  • Verifying deposit data before submitting

  • Building validator onboarding tools

  • Testing deposit contract interactions

  • Implementing custom deposit flows

See Also

Last updated