Class LandmarkSequence


  • public final class LandmarkSequence
    extends java.lang.Object
    The published landmark sequence for a single issuance log, as defined by Section 6.3 of draft-ietf-plants-merkle-tree-certs.

    A LandmarkSequence captures the num_active_landmarks + 1 most recent landmarks (numbered last_landmark - num_active_landmarks through last_landmark), with each landmark's tree size. Landmark 0 always has tree size 0; subsequent landmarks are strictly monotonically increasing in tree size and consecutive in landmark number.

    The published wire format (Section 6.3.3) is plain UTF-8 text:

     <last_landmark> <num_active_landmarks>
     tree_size of landmark last_landmark
     tree_size of landmark last_landmark - 1
     ...
     tree_size of landmark last_landmark - num_active_landmarks
     

    Each line is terminated with U+000A. Tree sizes within the sequence MUST be strictly monotonically decreasing reading from line 1 to line N.

    • Constructor Summary

      Constructors 
      Constructor Description
      LandmarkSequence​(long lastLandmark, long[] treeSizesNewestFirst)  
    • Constructor Detail

      • LandmarkSequence

        public LandmarkSequence​(long lastLandmark,
                                long[] treeSizesNewestFirst)
        Parameters:
        lastLandmark - the landmark number of the newest landmark
        treeSizesNewestFirst - tree sizes for landmarks lastLandmark down to lastLandmark - treeSizes.length + 1; must be strictly monotonically decreasing
    • Method Detail

      • parse

        public static LandmarkSequence parse​(java.lang.String text)
                                      throws java.io.IOException
        Parses a landmark sequence from its published text form (Section 6.3.3).
        Throws:
        java.io.IOException
      • format

        public java.lang.String format()
        Serializes the landmark sequence in the format defined by Section 6.3.3 (each line terminated with U+000A).
      • getLastLandmark

        public long getLastLandmark()
        Returns:
        the landmark number of the newest landmark.
      • getNumActiveLandmarks

        public int getNumActiveLandmarks()
        Returns:
        num_active_landmarks as published (one less than the tree size count).
      • getTreeSize

        public long getTreeSize​(long landmarkNumber)
        Returns:
        the tree size of the landmark with the given number.
      • activeLandmarkSubtrees

        public java.util.List<long[]> activeLandmarkSubtrees()
        Returns the landmark subtree intervals determined by this sequence per Section 6.3.1: between consecutive landmarks (excluding landmark 0) the interval [prev_tree_size, tree_size) is covered by one or two subtrees from MerkleTreePrimitives.findCoveringSubtrees(long, long). The returned list is ordered oldest-first.