org.bouncycastle.pqc.crypto.xmss.XMSSMTParameters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk15on Show documentation
Show all versions of bcprov-jdk15on Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 and up.
package org.bouncycastle.pqc.crypto.xmss;
import org.bouncycastle.crypto.Digest;
/**
* XMSS^MT Parameters.
*/
public final class XMSSMTParameters
{
private final XMSSOid oid;
private final XMSSParameters xmssParams;
private final int height;
private final int layers;
/**
* XMSSMT constructor...
*
* @param height Height of tree.
* @param layers Amount of layers.
* @param digest Digest to use.
*/
public XMSSMTParameters(int height, int layers, Digest digest)
{
super();
this.height = height;
this.layers = layers;
this.xmssParams = new XMSSParameters(xmssTreeHeight(height, layers), digest);
oid = DefaultXMSSMTOid.lookup(getTreeDigest(), getTreeDigestSize(), getWinternitzParameter(),
getLen(), getHeight(), layers);
/*
* if (oid == null) { throw new InvalidParameterException(); }
*/
}
private static int xmssTreeHeight(int height, int layers)
throws IllegalArgumentException
{
if (height < 2)
{
throw new IllegalArgumentException("totalHeight must be > 1");
}
if (height % layers != 0)
{
throw new IllegalArgumentException("layers must divide totalHeight without remainder");
}
if (height / layers == 1)
{
throw new IllegalArgumentException("height / layers must be greater than 1");
}
return height / layers;
}
/**
* Getter height.
*
* @return XMSSMT height.
*/
public int getHeight()
{
return height;
}
/**
* Getter layers.
*
* @return XMSSMT layers.
*/
public int getLayers()
{
return layers;
}
protected XMSSParameters getXMSSParameters()
{
return xmssParams;
}
protected WOTSPlus getWOTSPlus()
{
return xmssParams.getWOTSPlus();
}
protected String getTreeDigest()
{
return xmssParams.getTreeDigest();
}
/**
* Getter digest size.
*
* @return Digest size.
*/
public int getTreeDigestSize()
{
return xmssParams.getTreeDigestSize();
}
/**
* Getter Winternitz parameter.
*
* @return Winternitz parameter.
*/
int getWinternitzParameter()
{
return xmssParams.getWinternitzParameter();
}
protected int getLen()
{
return xmssParams.getLen();
}
protected XMSSOid getOid()
{
return oid;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy