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§
- HsDir
Params - 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.