Package org.bouncycastle.pqc.crypto.gmss
Class GMSSRootCalc
- java.lang.Object
-
- org.bouncycastle.pqc.crypto.gmss.GMSSRootCalc
-
public class GMSSRootCalc extends java.lang.Object
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.
-
-
Constructor Summary
Constructors Constructor Description GMSSRootCalc(int heightOfTree, int K, GMSSDigestProvider digestProvider)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[][]
getAuthPath()
returns the authentication path of the first leaf of the treejava.util.Vector[]
getRetain()
returns the retain stacks storing all right nodes near to the rootbyte[]
getRoot()
returns the finished root valuejava.util.Vector
getStack()
returns the shared stackbyte[][]
getStatByte()
Returns the status byte array used by the GMSSPrivateKeyASN.1 classint[]
getStatInt()
Returns the status int array used by the GMSSPrivateKeyASN.1 classTreehash[]
getTreehash()
returns the initial treehash instances, storing value y_3(i)void
initialize(java.util.Vector sharedStack)
Initializes the calculation of a new rootvoid
initializeTreehashSeed(byte[] seed, int index)
initializes the seeds for the treehashs of the tree precomputed by this classjava.lang.String
toString()
void
update(byte[] leaf)
Updates the root with one leaf and stores the needed values in retain, treehash or authpathvoid
update(byte[] seed, byte[] leaf)
updates the root with one leaf and stores needed values in retain, treehash or authpath.boolean
wasFinished()
Method to check whether the instance has been finished or notboolean
wasInitialized()
Method to check whether the instance has been initialized or not
-
-
-
Constructor Detail
-
GMSSRootCalc
public GMSSRootCalc(int heightOfTree, int K, GMSSDigestProvider digestProvider)
Constructor- Parameters:
heightOfTree
- maximal height of the treedigestProvider
- an array of strings, containing the name of the used hash function and PRNG and the name of the corresponding provider
-
-
Method Detail
-
initialize
public void initialize(java.util.Vector sharedStack)
Initializes the calculation of a new root- Parameters:
sharedStack
- the stack shared by all treehash instances of this tree
-
update
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
- the initial seed for treehash: seedNextleaf
- the height of the treehash
-
update
public void update(byte[] leaf)
Updates the root with one leaf and stores the needed values in retain, treehash or authpath
-
initializeTreehashSeed
public void initializeTreehashSeed(byte[] seed, int index)
initializes the seeds for the treehashs of the tree precomputed by this class- Parameters:
seed
- the initial seed for treehash: seedNextindex
- the height of the treehash
-
wasInitialized
public boolean wasInitialized()
Method to check whether the instance has been initialized or not- Returns:
- true if treehash was already initialized
-
wasFinished
public boolean wasFinished()
Method to check whether the instance has been finished or not- Returns:
- true if tree has reached its maximum height
-
getAuthPath
public byte[][] getAuthPath()
returns the authentication path of the first leaf of the tree- Returns:
- the authentication path of the first leaf of the tree
-
getTreehash
public Treehash[] getTreehash()
returns the initial treehash instances, storing value y_3(i)- Returns:
- the initial treehash instances, storing value y_3(i)
-
getRetain
public java.util.Vector[] getRetain()
returns the retain stacks storing all right nodes near to the root- Returns:
- the retain stacks storing all right nodes near to the root
-
getRoot
public byte[] getRoot()
returns the finished root value- Returns:
- the finished root value
-
getStack
public java.util.Vector getStack()
returns the shared stack- Returns:
- the shared stack
-
getStatByte
public byte[][] getStatByte()
Returns the status byte array used by the GMSSPrivateKeyASN.1 class- Returns:
- The status bytes
-
getStatInt
public int[] getStatInt()
Returns the status int array used by the GMSSPrivateKeyASN.1 class- Returns:
- The status ints
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- a human readable version of the structure
-
-