ppad-bolt7-0.0.1: Routing gossip per BOLT #7
Copyright(c) 2025 Jared Tobin
LicenseMIT
MaintainerJared Tobin <jared@ppad.tech>
Safe HaskellNone
LanguageHaskell2010

Lightning.Protocol.BOLT7.Hash

Description

Signature hash computation for BOLT #7 messages.

These functions compute the double-SHA256 hash that is signed in each message type. The hash covers the message content excluding the signature field(s).

Synopsis

Signature hashes

channelAnnouncementHash :: ByteString -> ByteString Source #

Compute signature hash for channel_announcement.

The hash covers the message starting at byte offset 256, which is after the four 64-byte signatures (node_sig_1, node_sig_2, bitcoin_sig_1, bitcoin_sig_2).

Returns the double-SHA256 hash (32 bytes).

nodeAnnouncementHash :: ByteString -> ByteString Source #

Compute signature hash for node_announcement.

The hash covers the message starting after the signature field (64 bytes).

Returns the double-SHA256 hash (32 bytes).

channelUpdateHash :: ByteString -> ByteString Source #

Compute signature hash for channel_update.

The hash covers the message starting after the signature field (64 bytes).

Returns the double-SHA256 hash (32 bytes).

Checksums

channelUpdateChecksum :: ByteString -> Word32 Source #

Compute checksum for channel_update.

This is the CRC-32C of the channel_update message excluding the signature field (bytes 0-63) and timestamp field (bytes 96-99).

The checksum is used in the checksums_tlv of reply_channel_range.

Message layout after signature: - chain_hash: 32 bytes (offset 64-95) - short_channel_id: 8 bytes (offset 96-103) - timestamp: 4 bytes (offset 104-107) -- EXCLUDED - message_flags: 1 byte (offset 108) - channel_flags: 1 byte (offset 109) - cltv_expiry_delta: 2 bytes (offset 110-111) - htlc_minimum_msat: 8 bytes (offset 112-119) - fee_base_msat: 4 bytes (offset 120-123) - fee_proportional_millionths: 4 bytes (offset 124-127) - htlc_maximum_msat: 8 bytes (offset 128-135, if present)