Skip to main content

Module signing

Module signing 

Source
Expand description

BzzAddress sign-data byte layout (Swarm handshake / hive shared spec).

The Swarm peer record (overlay + underlay + nonce + timestamp + chequebook) is authenticated by an EIP-191 personal-sign signature over the byte sequence built by sign_data below. The layout matches bee pkg/bzz/address.go:138-160 exactly so any Swarm impl can interop.

sign_data = "bee-handshake-"        (14 bytes)
          || underlay_bytes         (caller-supplied wire encoding)
          || overlay                (32 bytes)
          || network_id big-endian  (8 bytes)
          || nonce                  (32 bytes)
          || timestamp big-endian   (8 bytes, i64 two's-complement)
          || chequebook             (20 bytes, all-zero if None)

Signing and recovery are not wrapped - callers use alloy directly:

use alloy_signer::SignerSync;
let sig = signer.sign_message_sync(&sign_data(/* … */))?;
let eth = sig.recover_address_from_msg(&sign_data(/* … */))?;

Overlay verification is also one line - compare against compute_overlay:

if compute_overlay(&recovered_eth, network_id, &nonce) == claimed_overlay { /* ok */ }

Nectar intentionally does not depend on libp2p - the underlay_bytes argument is whatever wire encoding the calling node uses for its multiaddr list.

Constants§

SIGN_DATA_PREFIX
Magic prefix matching bee pkg/bzz/address.go:138 (signDataPrefix).

Functions§

sign_data
Build the canonical sign-data buffer for a BzzAddress.