Class XMSSMTPrivateKeyParameters

    • Method Detail

      • getEncoded

        public byte[] getEncoded()
                          throws java.io.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:
        java.io.IOException - if an issue arises generation the encoding.
      • toByteArray

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

        public long getIndex()
      • getUsagesRemaining

        public long getUsagesRemaining()
      • getSecretKeySeed

        public byte[] getSecretKeySeed()
      • getSecretKeyPRF

        public byte[] getSecretKeyPRF()
      • getPublicSeed

        public byte[] getPublicSeed()
      • getRoot

        public byte[] getRoot()
      • extractKeyShard

        public XMSSMTPrivateKeyParameters 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.
      • equals

        public boolean equals​(java.lang.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. XMSSPrivateKeyParameters 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 BCXMSSMTPrivateKey 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 java.lang.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 java.lang.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 keys the per-layer BDS traversal states retain for the leaves they last processed.

        The public seed, the root, the index and the traversal states' 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 javax.security.auth.Destroyable
      • isDestroyed

        public boolean isDestroyed()
        Specified by:
        isDestroyed in interface javax.security.auth.Destroyable