Class LandmarkSequence
A landmark consists of a landmark number, the tree size at the time it
was allocated, and an expiration time in seconds since the POSIX Epoch
(Section 6.4.1). Landmarks are numbered consecutively from zero; landmark 0
has tree size 0 and expiry 0, tree sizes are strictly increasing and expiries
non-decreasing with the landmark number. A landmark that has not yet expired
is active; landmark 0 never is. Each landmark has two landmark
subtrees: the two subtrees of Section 4.5 that cover the entries added since
the previous landmark, or [0, 0) twice for landmark 0.
A LandmarkSequence holds the window a CA publishes: the newest
landmark, latest_landmark, and the consecutive landmarks below it
down to at least one that has already expired. The published form
(Section 6.4.3) is plain text, each line terminated by U+000A:
<latest_landmark> <tree_size of landmark latest_landmark> <expiry of landmark latest_landmark> <tree_size of landmark latest_landmark - 1> <expiry of landmark latest_landmark - 1> ...
Tree sizes are strictly decreasing and expiries non-increasing down the
document, and the document must reach an expired landmark so that the active
set is delimited. The draft-05 form, with a num_active_landmarks
count in the header and no expiry times, is no longer read or written.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe largest landmark number or tree size the published form may carry, 2^48 - 1. -
Constructor Summary
ConstructorsConstructorDescriptionLandmarkSequence(long latestLandmark, long[] treeSizesNewestFirst, long[] expiriesNewestFirst) -
Method Summary
Modifier and TypeMethodDescriptionList<long[]> Returns the active landmark subtrees as of the current time, oldest landmark first; seeactiveLandmarkSubtrees(long).List<long[]> activeLandmarkSubtrees(long nowSeconds) Returns the active landmark subtrees as ofnowSeconds(Section 6.4.1): the two landmark subtrees of every landmark in the published window that has not yet expired and whose predecessor is also in the window, ordered oldest landmark first.format()Serializes the landmarks in the format defined by Section 6.4.3 (each line terminated with U+000A).longgetExpiry(long landmarkNumber) longintlonglonggetTreeSize(long landmarkNumber) booleanisActive(long landmarkNumber, long nowSeconds) longlandmarkFor(long index) Finds the landmark a landmark-relative certificate for entryindexis constructed against (Section 6.4.4 step 2): the lowest numbered landmark whose tree size is greater thanindex.long[]landmarkSubtreeFor(long index) Finds the landmark subtree a landmark-relative certificate for entryindexis constructed against (Section 6.4.4 steps 2 and 3): the one ofits landmark's two subtrees whose interval containsindex.List<long[]> landmarkSubtrees(long landmarkNumber) Returns the two landmark subtrees of a landmark (Section 6.4.1): the subtrees of Section 4.5 covering the entries between the previous landmark's tree size and this one's, or[0, 0)twice for landmark 0.static LandmarkSequenceParses a published landmark document (Section 6.4.3), requiring at least one landmark to have expired as of the current time.static LandmarkSequenceParses a published landmark document (Section 6.4.3).
-
Field Details
-
MAX_VALUE
public static final long MAX_VALUEThe largest landmark number or tree size the published form may carry, 2^48 - 1.- See Also:
-
-
Constructor Details
-
LandmarkSequence
public LandmarkSequence(long latestLandmark, long[] treeSizesNewestFirst, long[] expiriesNewestFirst) - Parameters:
latestLandmark- the landmark number of the newest landmarktreeSizesNewestFirst- tree sizes for landmarkslatestLandmarkdown tolatestLandmark - n + 1; strictly decreasingexpiriesNewestFirst- expiry times, in seconds since the Epoch, for the same landmarks in the same order; non-increasing
-
-
Method Details
-
parse
Parses a published landmark document (Section 6.4.3), requiring at least one landmark to have expired as of the current time.- Throws:
IOException- if the document does not strictly conform
-
parse
Parses a published landmark document (Section 6.4.3). The document must strictly conform: a header line holdinglatest_landmark, then one line per landmark of<tree_size> <expiry>, every line terminated by U+000A, no other whitespace, strictly decreasing tree sizes, non-increasing expiry times, and at least one expiry beforenowSeconds.- Parameters:
text- the documentnowSeconds- the current time in seconds since the Epoch- Throws:
IOException- if the document does not strictly conform
-
format
Serializes the landmarks in the format defined by Section 6.4.3 (each line terminated with U+000A). -
getLastLandmark
public long getLastLandmark()- Returns:
latest_landmark, the landmark number of the newest landmark.
-
getOldestLandmark
public long getOldestLandmark()- Returns:
- the number of the oldest landmark this sequence holds.
-
getNumActiveLandmarks
public int getNumActiveLandmarks()- Returns:
- the number of landmarks published beyond the terminating one, that
is
num_active_landmarksas of publication (Section 6.4.3)
-
getTreeSize
public long getTreeSize(long landmarkNumber) - Returns:
- the tree size of the landmark with the given number.
-
getExpiry
public long getExpiry(long landmarkNumber) - Returns:
- the expiry time of the landmark with the given number, in seconds since the Epoch.
-
isActive
public boolean isActive(long landmarkNumber, long nowSeconds) - Returns:
- whether the landmark is active at
nowSeconds, that is not yet expired (Section 6.4.1); landmark 0 is never active
-
landmarkSubtrees
Returns the two landmark subtrees of a landmark (Section 6.4.1): the subtrees of Section 4.5 covering the entries between the previous landmark's tree size and this one's, or[0, 0)twice for landmark 0. The previous landmark must be within the published window.- Returns:
- the two subtrees as
{start, end}pairs, left then right
-
activeLandmarkSubtrees
Returns the active landmark subtrees as of the current time, oldest landmark first; seeactiveLandmarkSubtrees(long). -
activeLandmarkSubtrees
Returns the active landmark subtrees as ofnowSeconds(Section 6.4.1): the two landmark subtrees of every landmark in the published window that has not yet expired and whose predecessor is also in the window, ordered oldest landmark first. These are the subtrees a relying party predistributes as trusted (Section 7.4). -
landmarkFor
public long landmarkFor(long index) Finds the landmark a landmark-relative certificate for entryindexis constructed against (Section 6.4.4 step 2): the lowest numbered landmark whose tree size is greater thanindex.- Returns:
- the landmark number, or
-1if no published landmark contains the entry yet
-
landmarkSubtreeFor
public long[] landmarkSubtreeFor(long index) Finds the landmark subtree a landmark-relative certificate for entryindexis constructed against (Section 6.4.4 steps 2 and 3): the one ofits landmark's two subtrees whose interval containsindex.- Returns:
- the subtree as a
{start, end}pair, ornullif no published landmark contains the entry yet or the landmark's predecessor is outside the published window
-