pub struct Address { /* private fields */ }Expand description
A self-certifying protocol address: off1….
§Ordering
Ord compares the underlying hash bytes, not the rendered string.
The two orders differ: the bech32 charset (qpzry9x8gf2tvdw0s3jn54khce6mua7l)
is not monotonic in ASCII — value 4 renders as y (0x79) and value 5 as
9 (0x39) — and a string comparison would also weigh the checksum
characters.
Which order a tiebreaker uses is fixed per site, and the sites disagree.
Both-create session ownership compares Address values (hash bytes); group
leave election, admin auto-promotion and fork leader election sort rendered
strings. Each converges on its own, because every peer running that
tiebreaker sorts the same way.
Do not “harmonize” one site onto the other order. Peers that changed and
peers that did not would then elect different winners from identical input,
with no way to detect the disagreement locally. Prefer hash-byte order for
anything new. See docs/adr/0003-self-certifying-addresses.md.
Implementations§
Source§impl Address
impl Address
Sourcepub const HASH_LEN: usize = 20
pub const HASH_LEN: usize = 20
Length of the truncated identity-key hash, in bytes.
160 bits, which is a second-preimage margin of ~2^160 and a collision margin of ~2^80 — the birthday bound on the same truncation. Both are stated here because they buy different things and only the first is what the impersonation claim rests on:
- ~2^160 is the cost of aiming at an address that already exists: producing a key that derives to someone else’s address. That is the attack the sender-derivation gate replaced the trust-pin store to stop, and it is the figure the guides and changelog quote.
- ~2^80 is the cost of producing two identity keys that share one address, neither fixed in advance. It impersonates nobody, but it does let a single entity hold two signing keys that are indistinguishable at the address layer — enough to equivocate, and enough to defeat the “one identity cannot hold two leaves” property that the MLS leaf binding otherwise inherits from MLS signature-key uniqueness.
~2^80 is below the ~2^128 a greenfield design would target, and is a
deliberate trade rather than an oversight: every mesh frame carries a
sender and a recipient address, and BLE budget is the binding
constraint. Widening the hash changes the wire, so it is a VERSION
bump and a migration, not a patch.
Sourcepub const PAYLOAD_LEN: usize
pub const PAYLOAD_LEN: usize
Length of the encoded payload: version byte followed by the hash.
Sourcepub const ENCODED_LEN: usize = 44
pub const ENCODED_LEN: usize = 44
Length of the canonical string form.
off (3) + separator (1) + data (34) + checksum (6). The data part is
34 characters because 21 bytes is 168 bits, which needs 34 five-bit
groups and leaves 2 padding bits.
Sourcepub fn from_hash_bytes(hash: [u8; 20]) -> Self
pub fn from_hash_bytes(hash: [u8; 20]) -> Self
Builds an address from a truncated identity-key hash.
Infallible: every 20-byte value is a valid address payload.
Sourcepub fn from_payload(payload: &[u8]) -> Result<Self, AddressError>
pub fn from_payload(payload: &[u8]) -> Result<Self, AddressError>
Builds an address from a version ‖ hash payload.
Sourcepub fn hash_bytes(&self) -> &[u8; 20]
pub fn hash_bytes(&self) -> &[u8; 20]
Returns the truncated identity-key hash.