Module consensus

Module consensus 

Source
Expand description

Network status consensus document parsing.

This module provides types for parsing Tor network status consensus documents which describe the current state of the Tor network including all known relays.

§Overview

Network status documents are the authoritative source of information about the Tor network. They come in two forms:

  • Votes: Individual directory authority opinions about the network
  • Consensus: The agreed-upon view signed by multiple authorities

Clients download the consensus to learn about available relays, their capabilities, and which relays are recommended for different purposes.

§Document Types

TypeDescription
ConsensusAgreed network status signed by authorities
VoteIndividual authority’s view before consensus
Microdesc ConsensusConsensus using microdescriptor hashes

§Validity Times

Consensus documents have three important timestamps:

  • valid-after: When the consensus becomes valid
  • fresh-until: When clients should fetch a new consensus
  • valid-until: When the consensus expires completely

Clients should fetch a new consensus between fresh-until and valid-until.

§Document Format

network-status-version 3 [microdesc]
vote-status consensus|vote
consensus-method <N>
valid-after <YYYY-MM-DD HH:MM:SS>
fresh-until <YYYY-MM-DD HH:MM:SS>
valid-until <YYYY-MM-DD HH:MM:SS>
voting-delay <vote-seconds> <dist-seconds>
known-flags <flag> <flag> ...
recommended-client-protocols <proto>=<versions> ...
required-client-protocols <proto>=<versions> ...
params <key>=<value> ...
dir-source <nickname> <identity> <hostname> <address> <dirport> <orport>
...
directory-footer
bandwidth-weights <key>=<value> ...
directory-signature <identity> <signing-key-digest>
-----BEGIN SIGNATURE-----
<base64 signature>
-----END SIGNATURE-----

§Example

use stem_rs::descriptor::{NetworkStatusDocument, Descriptor};

let content = std::fs::read_to_string("cached-consensus").unwrap();
let consensus = NetworkStatusDocument::parse(&content).unwrap();

println!("Consensus method: {:?}", consensus.consensus_method);
println!("Valid after: {}", consensus.valid_after);
println!("Valid until: {}", consensus.valid_until);
println!("Known flags: {:?}", consensus.known_flags);
println!("Authorities: {}", consensus.authorities.len());
println!("Signatures: {}", consensus.signatures.len());

// Check protocol requirements
if let Some(versions) = consensus.required_client_protocols.get("Link") {
    println!("Required Link protocol versions: {:?}", versions);
}

§Shared Randomness

Modern consensus documents include shared randomness values used for hidden service directory assignment. These are computed collaboratively by the directory authorities.

§See Also

Structs§

DocumentSignature
A signature on a network status document.
NetworkStatusDocument
A network status consensus or vote document.
SharedRandomness
Shared randomness value from directory authority collaboration.