Top Description Fields Constructors Methods
org.bouncycastle.pqc.legacy.crypto.gmss

public Class Treehash

extends Object
Class Inheritance
Imports
java.util.Vector, org.bouncycastle.crypto.Digest, org.bouncycastle.pqc.legacy.crypto.gmss.util.GMSSRandom, org.bouncycastle.util.Integers, org.bouncycastle.util.encoders.Hex

This class implements a treehash instance for the Merkle tree traversal algorithm. The first node of the stack is stored in this instance itself, additional tail nodes are stored on a tailstack.

Field Summary

Modifier and TypeField and Description
private byte[]
firstNode

the first node is stored in the treehash instance itself, not on stack

private int
firstNodeHeight

the height in the tree of the first node stored in treehash

private Vector<E>
heightOfNodes

Vector element that stores the height of the nodes on the stack

private boolean
isFinished

true if the first node's height equals the maxHeight of the treehash

private boolean
isInitialized

true if treehash instance was already initialized, false otherwise

private int
maxHeight

max height of current treehash instance.

private Digest
messDigestTree

denotes the Message Digest used by the tree to create nodes

private byte[]
seedActive

seedActive needed for the actual node

private boolean
seedInitialized

true if the nextSeed has been initialized with index 3*2^h needed for the seed scheduling

private byte[]
seedNext

the seed needed for the next re-initialization of the treehash instance

private int
tailLength

number of nodes stored on the stack and belonging to this treehash instance

private Vector<E>
tailStack

Vector element that stores the nodes on the stack

Constructor Summary

AccessConstructor and Description
public
Treehash(Digest
an array of strings, containing the name of the used hash function and PRNG and the name of the corresponding provider
name
,
byte[][]
status bytes
statByte
,
int[]
status ints
statInt
)

This constructor regenerates a prior treehash object

public
Treehash(Vector<E>
a vector element where the stack nodes are stored
tailStack
,
int
maximal height of the treehash instance
maxHeight
,
Digest
an array of strings, containing the name of the used hash function and PRNG and the name of the corresponding provider
digest
)

Constructor

Method Summary

Modifier and TypeMethod and Description
public void
destroy()

Destroys a treehash instance after the top node was taken for authentication path.

public byte[]

Returns:

the first node stored in treehash instance itself
getFirstNode
()

returns the first node stored in treehash instance itself

public int

Returns:

Height of the first node, the top node
getFirstNodeHeight
()

Returns the top node height

public int

Returns:

Height of the lowest node
getLowestNodeHeight
()

Returns the height of the lowest node stored either in treehash or on the stack.

public byte[]

Returns:

the active seed
getSeedActive
()

returns the active seed

public byte[][]

Returns:

The status bytes
getStatByte
()

Returns the status byte array used by the GMSSPrivateKeyASN.1 class

public int[]

Returns:

The status ints
getStatInt
()

Returns the status int array used by the GMSSPrivateKeyASN.1 class

public Vector<E>

Returns:

the tailstack
getTailStack
()

Returns the tailstack

public void
initialize()

initializes the treehash instance.

public void
initializeSeed(byte[] seedIn)

Method to initialize the seeds needed for the precomputation of right nodes.

public void
setFirstNode(byte[] hash)

This method sets the first node stored in the treehash instance itself

public String
toString()

Overrides java.lang.Object.toString.

returns a String representation of the treehash instance

public void
update(GMSSRandom
an instance of the PRNG
gmssRandom
,
byte[]
The byte value of the leaf needed for the update
leaf
)

Calculates one update of the treehash instance, i.e. creates a new leaf and hashes if possible

public void
updateNextSeed(GMSSRandom
the prng used for the seeds
gmssRandom
)

updates the nextSeed of this treehash instance one step needed for the schedulng of the seeds

public boolean

Returns:

true if treehash has reached its maximum height
wasFinished
()

Method to check whether the instance has been finished or not

public boolean

Returns:

true if treehash was already initialized
wasInitialized
()

Method to check whether the instance has been initialized or not

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

firstNodeback to summary
private byte[] firstNode

the first node is stored in the treehash instance itself, not on stack

firstNodeHeightback to summary
private int firstNodeHeight

the height in the tree of the first node stored in treehash

heightOfNodesback to summary
private Vector<E> heightOfNodes

Vector element that stores the height of the nodes on the stack

isFinishedback to summary
private boolean isFinished

true if the first node's height equals the maxHeight of the treehash

isInitializedback to summary
private boolean isInitialized

true if treehash instance was already initialized, false otherwise

maxHeightback to summary
private int maxHeight

max height of current treehash instance.

messDigestTreeback to summary
private Digest messDigestTree

denotes the Message Digest used by the tree to create nodes

seedActiveback to summary
private byte[] seedActive

seedActive needed for the actual node

seedInitializedback to summary
private boolean seedInitialized

true if the nextSeed has been initialized with index 3*2^h needed for the seed scheduling

seedNextback to summary
private byte[] seedNext

the seed needed for the next re-initialization of the treehash instance

tailLengthback to summary
private int tailLength

number of nodes stored on the stack and belonging to this treehash instance

tailStackback to summary
private Vector<E> tailStack

Vector element that stores the nodes on the stack

Constructor Detail

Treehashback to summary
public Treehash(Digest name, byte[][] statByte, int[] statInt)

This constructor regenerates a prior treehash object

Parameters
name:Digest

an array of strings, containing the name of the used hash function and PRNG and the name of the corresponding provider

statByte:byte[][]

status bytes

statInt:int[]

status ints

Treehashback to summary
public Treehash(Vector<E> tailStack, int maxHeight, Digest digest)

Constructor

Parameters
tailStack:Vector<E>

a vector element where the stack nodes are stored

maxHeight:int

maximal height of the treehash instance

digest:Digest

an array of strings, containing the name of the used hash function and PRNG and the name of the corresponding provider

Method Detail

destroyback to summary
public void destroy()

Destroys a treehash instance after the top node was taken for authentication path.

getFirstNodeback to summary
public byte[] getFirstNode()

returns the first node stored in treehash instance itself

Returns:byte[]

the first node stored in treehash instance itself

getFirstNodeHeightback to summary
public int getFirstNodeHeight()

Returns the top node height

Returns:int

Height of the first node, the top node

getLowestNodeHeightback to summary
public int getLowestNodeHeight()

Returns the height of the lowest node stored either in treehash or on the stack. It must not be set to infinity (as mentioned in the paper) because this cases are considered in the computeAuthPaths method of JDKGMSSPrivateKey

Returns:int

Height of the lowest node

getSeedActiveback to summary
public byte[] getSeedActive()

returns the active seed

Returns:byte[]

the active seed

getStatByteback to summary
public byte[][] getStatByte()

Returns the status byte array used by the GMSSPrivateKeyASN.1 class

Returns:byte[][]

The status bytes

getStatIntback to summary
public int[] getStatInt()

Returns the status int array used by the GMSSPrivateKeyASN.1 class

Returns:int[]

The status ints

getTailStackback to summary
public Vector<E> getTailStack()

Returns the tailstack

Returns:Vector<E>

the tailstack

initializeback to summary
public void initialize()

initializes the treehash instance. The seeds must already have been initialized to work correctly.

initializeSeedback to summary
public void initializeSeed(byte[] seedIn)

Method to initialize the seeds needed for the precomputation of right nodes. Should be initialized with index 3*2^i for treehash_i

setFirstNodeback to summary
public void setFirstNode(byte[] hash)

This method sets the first node stored in the treehash instance itself

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

returns a String representation of the treehash instance

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

updateback to summary
public void update(GMSSRandom gmssRandom, byte[] leaf)

Calculates one update of the treehash instance, i.e. creates a new leaf and hashes if possible

Parameters
gmssRandom:GMSSRandom

an instance of the PRNG

leaf:byte[]

The byte value of the leaf needed for the update

updateNextSeedback to summary
public void updateNextSeed(GMSSRandom gmssRandom)

updates the nextSeed of this treehash instance one step needed for the schedulng of the seeds

Parameters
gmssRandom:GMSSRandom

the prng used for the seeds

wasFinishedback to summary
public boolean wasFinished()

Method to check whether the instance has been finished or not

Returns:boolean

true if treehash has reached its maximum height

wasInitializedback to summary
public boolean wasInitialized()

Method to check whether the instance has been initialized or not

Returns:boolean

true if treehash was already initialized