Class XMSSPrivateKeyParameters

All Implemented Interfaces:
Destroyable, CipherParameters, Encodable

public final class XMSSPrivateKeyParameters extends XMSSKeyParameters implements Encodable, Destroyable
XMSS Private Key.
  • Method Details

    • getUsagesRemaining

      public long getUsagesRemaining()
    • getEncoded

      public byte[] getEncoded() throws IOException
      Description copied from interface: Encodable
      Return a byte array representing the implementing object.
      Specified by:
      getEncoded in interface Encodable
      Returns:
      a byte array representing the encoding.
      Throws:
      IOException - if an issue arises generation the encoding.
    • rollKey

      public XMSSPrivateKeyParameters rollKey()
    • getNextKey

      public XMSSPrivateKeyParameters getNextKey()
    • extractKeyShard

      public XMSSPrivateKeyParameters extractKeyShard(int usageCount)
      Return a key that can be used usageCount times.

      Note: this will use the range [index...index + usageCount) for the current key.

      Parameters:
      usageCount - the number of usages the key should have.
      Returns:
      a key based on the current key that can be used usageCount times.
    • toByteArray

      @Deprecated public byte[] toByteArray()
      Deprecated.
      use getEncoded() - this method will become private.
    • getIndex

      public int getIndex()
    • getSecretKeySeed

      public byte[] getSecretKeySeed()
    • getSecretKeyPRF

      public byte[] getSecretKeyPRF()
    • getPublicSeed

      public byte[] getPublicSeed()
    • getRoot

      public byte[] getRoot()
    • getBDSState

      public BDS getBDSState()
    • getParameters

      public XMSSParameters getParameters()
    • equals

      public boolean equals(Object o)
      Whether these are the same key at the same position, which for a stateful key means the same traversal state too.

      Both halves of that are XMSSPrivateKeyCodec's, beside the layout they are over: Fields is the seven things decided ahead of the state and State is the state, each taken from one key under that key's own monitor and never both at once, and fieldsEqual and stateEqual compare them. XMSSMTPrivateKeyParameters held a line for line copy of all of it. What is left here is a snapshot per key and the two calls over them, joined with && because what the fields decide is whether the state is compared at all - the codec says why the short circuit goes there and nowhere inside.

      The comparison belongs on this class rather than on the provider key that wraps it because every part of it does: the monitor a signature is taken under is this object's, the fields are this object's, and a caller reaching in through the accessors gets a clone of each array and no way to hold any two of them still. HSSPrivateKeyParameters does the same for the other stateful family in this package, leaving BCLMSPrivateKey.equals() a single delegating line, and BCXMSSPrivateKey is now that line as well. It carries the tree digest a second time, as the OID it was constructed with, and no longer compares it: that OID is params.getTreeDigestOID() at every route a key is built by - generation, a PKCS#8 round trip, extractKeyShard, and the key a signature hands back - so the first comparison the codec makes is the comparison it was making.

      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      The fields that do not move as this key signs, hashed as XMSSPrivateKeyCodec.hashCode hashes them: the tree digest, the root and the public seed.
      Overrides:
      hashCode in class Object
    • destroy

      public void destroy()
      Destroy this key, zeroizing the secret key material it holds: the seed the WOTS+ secret keys are derived from, the PRF key that randomizes message digests, and the WOTS+ secret key its BDS traversal state retains for the leaf it last processed.

      The public seed, the root, the index and the traversal state's tree nodes are retained - none of them is secret. After destruction isDestroyed() returns true and getSecretKeySeed(), getSecretKeyPRF(), getEncoded(), getNextKey() and extractKeyShard(int) throw IllegalStateException; a signature attempt fails before the index is advanced. Keys previously split off this one hold their own copies of the seeds and are unaffected.

      Specified by:
      destroy in interface Destroyable
    • isDestroyed

      public boolean isDestroyed()
      Specified by:
      isDestroyed in interface Destroyable