Skip to main content

Module address

Module address 

Source
Expand description

Self-certifying protocol addresses.

An address is a bech32m encoding of 0x01 ‖ SHA-256(ed25519_pub)[..20], rendered as off1… (44 characters). Because the payload is a hash of the identity key, an address authenticates itself: a peer claiming an address can be checked by re-deriving it from the public key it presents, with no trust-on-first-use pin store in between.

This module never touches key material — hashing happens upstream (see MlsManager::derive_address); Address is constructed from the already truncated hash.

§Exactly one string form

Every payload has exactly one accepted spelling. Address::from_str rejects uppercase input, the non-m bech32 checksum, wrong HRP, wrong version byte, wrong payload length, and — critically — encodings that decode to the right payload but are not the canonical spelling of it. The last class is not hypothetical: the bech32 crate’s decoder discards the trailing sub-byte bits without checking they are zero, and its fes-to-bytes length rule (n * 5 / 8) maps both 34- and 35-character data parts onto a 21-byte payload. Both shapes are checksum-valid and both are caught here by re-encoding and requiring byte-for-byte equality with the input. Briar’s “spare bit” address bug is the reference failure for what happens when this is skipped.

Structs§

Address
A self-certifying protocol address: off1….

Enums§

AddressError
Why an address string was rejected by Address::from_str.