hashtagstruct_hash

Compute TxSeismic EIP-712 struct hash

Compute EIP-712 struct hash for an UnsignedSeismicTx.

Signature

def struct_hash(tx: UnsignedSeismicTx) -> bytes

Parameters

Parameter
Type
Required
Description

tx

Yes

The unsigned Seismic transaction

Returns

Type
Description

bytes

32-byte keccak256 hash of the encoded struct

How it works

keccak256(
    TX_SEISMIC_TYPE_HASH
    ‖ encode(chain_id)
    ‖ encode(nonce)
    ‖ encode(gas_price)
    ‖ encode(gas)
    ‖ encode(to)
    ‖ encode(value)
    ‖ keccak256(data)              // dynamic type
    ‖ keccak256(encryption_pubkey) // dynamic type
    ‖ encode(encryption_nonce)
    ‖ encode(message_version)
    ‖ recent_block_hash            // already 32 bytes
    ‖ encode(expires_at_block)
    ‖ encode(signed_read)
)

Encoding details

  • Static fields are left-padded to 32 bytes

  • Dynamic bytes fields (tx.data, tx.seismic.encryption_pubkey) are hashed with keccak256 before inclusion

  • encryption_nonce is converted from 12 bytes to a uint96 integer via int.from_bytes(…, "big")

  • to becomes 32 zero bytes when tx.to is None

See Also

Last updated