public final class LandmarkSequence
extends java.lang.Object
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.
| Modifier and Type | Field and Description |
|---|---|
static long |
MAX_VALUE
The largest landmark number or tree size the published form may carry, 2^48 - 1.
|
| Constructor and Description |
|---|
LandmarkSequence(long latestLandmark,
long[] treeSizesNewestFirst,
long[] expiriesNewestFirst) |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<long[]> |
activeLandmarkSubtrees()
Returns the active landmark subtrees as of the current time, oldest
landmark first; see
activeLandmarkSubtrees(long). |
java.util.List<long[]> |
activeLandmarkSubtrees(long nowSeconds)
Returns the active landmark subtrees as of
nowSeconds
(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. |
java.lang.String |
format()
Serializes the landmarks in the format defined by Section 6.4.3 (each
line terminated with U+000A).
|
long |
getExpiry(long landmarkNumber) |
long |
getLastLandmark() |
int |
getNumActiveLandmarks() |
long |
getOldestLandmark() |
long |
getTreeSize(long landmarkNumber) |
boolean |
isActive(long landmarkNumber,
long nowSeconds) |
long |
landmarkFor(long index)
Finds the landmark a landmark-relative certificate for entry
index is constructed against (Section 6.4.4 step 2): the lowest
numbered landmark whose tree size is greater than index. |
long[] |
landmarkSubtreeFor(long index)
Finds the landmark subtree a landmark-relative certificate for entry
index is constructed against (Section 6.4.4 steps 2 and 3): the
one of its landmark's two subtrees whose
interval contains index. |
java.util.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 LandmarkSequence |
parse(java.lang.String text)
Parses a published landmark document (Section 6.4.3), requiring at least
one landmark to have expired as of the current time.
|
static LandmarkSequence |
parse(java.lang.String text,
long nowSeconds)
Parses a published landmark document (Section 6.4.3).
|
public static final long MAX_VALUE
public LandmarkSequence(long latestLandmark,
long[] treeSizesNewestFirst,
long[] expiriesNewestFirst)
latestLandmark - the landmark number of the newest landmarktreeSizesNewestFirst - tree sizes for landmarks latestLandmark
down to latestLandmark - n + 1; strictly
decreasingexpiriesNewestFirst - expiry times, in seconds since the Epoch, for
the same landmarks in the same order; non-increasingpublic static LandmarkSequence parse(java.lang.String text) throws java.io.IOException
java.io.IOException - if the document does not strictly conformpublic static LandmarkSequence parse(java.lang.String text, long nowSeconds) throws java.io.IOException
latest_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 before
nowSeconds.text - the documentnowSeconds - the current time in seconds since the Epochjava.io.IOException - if the document does not strictly conformpublic java.lang.String format()
public long getLastLandmark()
latest_landmark, the landmark number of the newest landmark.public long getOldestLandmark()
public int getNumActiveLandmarks()
num_active_landmarks as of publication (Section 6.4.3)public long getTreeSize(long landmarkNumber)
public long getExpiry(long landmarkNumber)
public boolean isActive(long landmarkNumber,
long nowSeconds)
nowSeconds, that is not
yet expired (Section 6.4.1); landmark 0 is never activepublic java.util.List<long[]> landmarkSubtrees(long landmarkNumber)
[0, 0) twice for
landmark 0. The previous landmark must be within the published window.{start, end} pairs, left then rightpublic java.util.List<long[]> activeLandmarkSubtrees()
activeLandmarkSubtrees(long).public java.util.List<long[]> activeLandmarkSubtrees(long nowSeconds)
nowSeconds
(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).public long landmarkFor(long index)
index is constructed against (Section 6.4.4 step 2): the lowest
numbered landmark whose tree size is greater than index.-1 if no published landmark
contains the entry yetpublic long[] landmarkSubtreeFor(long index)
index is constructed against (Section 6.4.4 steps 2 and 3): the
one of its landmark's two subtrees whose
interval contains index.{start, end} pair, or null if
no published landmark contains the entry yet or the landmark's
predecessor is outside the published window