java.lang.Object
net.i2p.router.crypto.ratchet.RatchetSessionTag

public class RatchetSessionTagextends Object
8-byte session tag for ratchet protocol messages with efficient long-based storage representation for memory optimization Does not extend SessionTag or DataStructure to save space.
  • Field Summary

    Modifier and Type
    Field
    Description
    private final long
    The 64-bit session tag value.
    static final int
    Length of the tag in bytes.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RatchetSessionTag(byte[] val)
    First 8 bytes of the given value are copied; the reference is not kept.
    Tag from a long value for compact 8-byte storage.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    boolean
    Compares by long value for fast identity.
    byte[]
    The tag as a byte array.
    long
    The tag as a long value.
    int
    We assume the data has enough randomness in it, so use 4 bytes for speed.
    int
    Return the fixed length of the tag.
    12 chars.
    Describe the tag for log messages.

    Methods inherited from class Object

    clone, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • LENGTH

      public static final int LENGTH
      Length of the tag in bytes.
      See Also:
    • _data

      private final long _data
      The 64-bit session tag value.
  • Constructor Details

    • RatchetSessionTag

      public RatchetSessionTag(long val)
      Tag from a long value for compact 8-byte storage.
      Parameters:
      val - the 64-bit tag value, stored as-is
    • RatchetSessionTag

      public RatchetSessionTag(byte[] val)
      First 8 bytes of the given value are copied; the reference is not kept.
      Parameters:
      val - will copy the first 8 bytes. Reference will not be kept.
  • Method Details

    • getData

      public byte[] getData()
      The tag as a byte array.
      Returns:
      data as a byte array
    • getLong

      public long getLong()
      The tag as a long value.
      Returns:
      data as a long value
    • length

      public int length()
      Return the fixed length of the tag.
      Returns:
      8, the same as LENGTH
    • toBase64

      public String toBase64()
      12 chars.
      Returns:
      the tag encoded with the I2P base64 alphabet, 12 characters ending in '='
    • hashCode

      public int hashCode()
      We assume the data has enough randomness in it, so use 4 bytes for speed.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code
    • equals

      public boolean equals(Object obj)
      Compares by long value for fast identity.
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Describe the tag for log messages.
      Overrides:
      toString in class Object
      Returns:
      "RatchetSessionTag: " followed by the 12-character base64 tag