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

public Class GMSSRootCalc

extends Object
Class Inheritance
Imports
java.util.Enumeration, .Vector, org.bouncycastle.crypto.Digest, org.bouncycastle.util.Arrays, .Integers, org.bouncycastle.util.encoders.Hex

This class computes a whole Merkle tree and saves the needed values for AuthPath computation. It is used for precomputation of the root of a following tree. After initialization, 2^H updates are required to complete the root. Every update requires one leaf value as parameter. While computing the root all initial values for the authentication path algorithm (treehash, auth, retain) are stored for later use.

Field Summary

Modifier and TypeField and Description
private byte[][]
AuthPath

stores the authentication path y_1(i), i = 0..H-1

private GMSSDigestProvider
digestProvider

An array of strings containing the name of the hash function used to construct the authentication trees and used by the OTS.

private int
heightOfNextSeed

temporary integer that stores the height of the next treehash instance that gets initialized with a seed

private Vector<E>
heightOfNodes

stores the height of all nodes laying on the tailStack

private int
heightOfTree

max height of the tree

private int[]
index

stores the index of the current node on each height of the tree

private int
indexForNextSeed

Integer that stores the index of the next seed that has to be omitted to the treehashs

private boolean
isFinished

true it instance was finished

private boolean
isInitialized

true if instance was already initialized, false otherwise

private int
K

the value K for the authentication path computation

private int
mdLength

length of the messageDigest

private Digest
messDigestTree

The hash function used for the construction of the authentication trees

private Vector<E>[]
retain

stores the retain nodes for authPath computation

private byte[]
root

finally stores the root of the tree when finished

private Vector<E>
tailStack

Vector element that stores the nodes on the stack

private Treehash[]
treehash

the treehash instances of the tree

Constructor Summary

AccessConstructor and Description
public
GMSSRootCalc(int
maximal height of the tree
heightOfTree
,
int K, GMSSDigestProvider
an array of strings, containing the name of the used hash function and PRNG and the name of the corresponding provider
digestProvider
)

Constructor

Method Summary

Modifier and TypeMethod and Description
public byte[][]

Returns:

the authentication path of the first leaf of the tree
getAuthPath
()

returns the authentication path of the first leaf of the tree

public Vector<E>[]

Returns:

the retain stacks storing all right nodes near to the root
getRetain
()

returns the retain stacks storing all right nodes near to the root

public byte[]

Returns:

the finished root value
getRoot
()

returns the finished root value

public Vector<E>

Returns:

the shared stack
getStack
()

returns the shared stack

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 Treehash[]

Returns:

the initial treehash instances, storing value y_3(i)
getTreehash
()

returns the initial treehash instances, storing value y_3(i)

public void
initialize(Vector<E>
the stack shared by all treehash instances of this tree
sharedStack
)

Initializes the calculation of a new root

public void
initializeTreehashSeed(byte[]
the initial seed for treehash: seedNext
seed
,
int
the height of the treehash
index
)

initializes the seeds for the treehashs of the tree precomputed by this class

public String

Returns:

a human readable version of the structure
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
update(byte[]
the initial seed for treehash: seedNext
seed
,
byte[]
the height of the treehash
leaf
)

updates the root with one leaf and stores needed values in retain, treehash or authpath.

public void
update(byte[] leaf)

Updates the root with one leaf and stores the needed values in retain, treehash or authpath

public boolean

Returns:

true if tree 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

AuthPathback to summary
private byte[][] AuthPath

stores the authentication path y_1(i), i = 0..H-1

digestProviderback to summary
private GMSSDigestProvider digestProvider

An array of strings containing the name of the hash function used to construct the authentication trees and used by the OTS.

heightOfNextSeedback to summary
private int heightOfNextSeed

temporary integer that stores the height of the next treehash instance that gets initialized with a seed

heightOfNodesback to summary
private Vector<E> heightOfNodes

stores the height of all nodes laying on the tailStack

heightOfTreeback to summary
private int heightOfTree

max height of the tree

indexback to summary
private int[] index

stores the index of the current node on each height of the tree

indexForNextSeedback to summary
private int indexForNextSeed

Integer that stores the index of the next seed that has to be omitted to the treehashs

isFinishedback to summary
private boolean isFinished

true it instance was finished

isInitializedback to summary
private boolean isInitialized

true if instance was already initialized, false otherwise

Kback to summary
private int K

the value K for the authentication path computation

mdLengthback to summary
private int mdLength

length of the messageDigest

messDigestTreeback to summary
private Digest messDigestTree

The hash function used for the construction of the authentication trees

retainback to summary
private Vector<E>[] retain

stores the retain nodes for authPath computation

rootback to summary
private byte[] root

finally stores the root of the tree when finished

tailStackback to summary
private Vector<E> tailStack

Vector element that stores the nodes on the stack

treehashback to summary
private Treehash[] treehash

the treehash instances of the tree

Constructor Detail

GMSSRootCalcback to summary
public GMSSRootCalc(int heightOfTree, int K, GMSSDigestProvider digestProvider)

Constructor

Parameters
heightOfTree:int

maximal height of the tree

digestProvider:GMSSDigestProvider

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

Method Detail

getAuthPathback to summary
public byte[][] getAuthPath()

returns the authentication path of the first leaf of the tree

Returns:byte[][]

the authentication path of the first leaf of the tree

getRetainback to summary
public Vector<E>[] getRetain()

returns the retain stacks storing all right nodes near to the root

Returns:Vector<E>[]

the retain stacks storing all right nodes near to the root

getRootback to summary
public byte[] getRoot()

returns the finished root value

Returns:byte[]

the finished root value

getStackback to summary
public Vector<E> getStack()

returns the shared stack

Returns:Vector<E>

the shared stack

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

getTreehashback to summary
public Treehash[] getTreehash()

returns the initial treehash instances, storing value y_3(i)

Returns:Treehash[]

the initial treehash instances, storing value y_3(i)

initializeback to summary
public void initialize(Vector<E> sharedStack)

Initializes the calculation of a new root

Parameters
sharedStack:Vector<E>

the stack shared by all treehash instances of this tree

initializeTreehashSeedback to summary
public void initializeTreehashSeed(byte[] seed, int index)

initializes the seeds for the treehashs of the tree precomputed by this class

Parameters
seed:byte[]

the initial seed for treehash: seedNext

index:int

the height of the treehash

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a human readable version of the structure

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

updates the root with one leaf and stores needed values in retain, treehash or authpath. Additionally counts the seeds used. This method is used when performing the updates for TREE++.

Parameters
seed:byte[]

the initial seed for treehash: seedNext

leaf:byte[]

the height of the treehash

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

Updates the root with one leaf and stores the needed values in retain, treehash or authpath

wasFinishedback to summary
public boolean wasFinished()

Method to check whether the instance has been finished or not

Returns:boolean

true if tree 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