Module hsdir_params

Source
Available on crate feature hs-common only.
Expand description

Compute which time period and shared random value from a consensus to use at any given time.

This is, unfortunately, a bit complex. It works as follows:

  • The current time period is the one that contains the valid-after time for the consensus…

    • but to compute the time period interval, you need to look at the consensus parameters,
    • and to compute the time period offset, you need to know the consensus voting interval.
  • The SRV for any given time period is the one that that was the most recent at the start of the time period…

    • but to know when an SRV was most recent, you need to read a timestamp from it that won’t be there until proposal 342 is implemented…
    • and until then, you have to compute the start of the UTC day when the consensus became valid.

This module could conceivably be part of tor-netdoc, but it seems better to make it part of tor-netdir: this is where we put our complexity.

Structs§

HsDirParams
Parameters for generating and using an HsDir ring.

Constants§

ONE_DAY 🔒
One day.
VOTING_PERIODS_IN_OFFSET 🔒
By how many voting periods do we offset the beginning of our first time period from the epoch?
VOTING_PERIODS_IN_SRV_ROUND 🔒
How many voting periods make up an entire round of the shared random value commit-and-reveal protocol?

Functions§

disaster_params 🔒
Compute ring parameters using a Disaster SRV for this period.
disaster_srv 🔒
Compute the “Disaster SRV” for a given time period.
extract_srvs 🔒
Return every SRV from a consensus, along with a duration over which it is most recent SRV.
find_params_for_time 🔒
Given a list of SrvInfo, return an HsRingParams instance for a given time period, if possible.
find_srv_for_time 🔒
Given a list of SrvInfo, return the SrvInfo (if any) that is the most recent SRV at when.
srv_interval 🔒
Return the length of time for which a single SRV value is valid.
start_of_day_containing 🔒
Return the length of the voting period in the consensus.

Type Aliases§

SrvInfo 🔒
Helper type: A SharedRandVal, and the time range over which it is the most recent.