public class MLKEMPrivateKey
extends iaik.pkcs.pkcs8.PrivateKeyInfo
Modifier and Type | Class and Description |
---|---|
static class |
MLKEMPrivateKey.PrivateKeyEncoding
This enumeration is only applied for the needed encoding as an ASN.1 object.
|
Constructor and Description |
---|
MLKEMPrivateKey(byte[] encoded)
Create private key from an ASN.1 encoded byte sequence
|
MLKEMPrivateKey(byte[] byteDk,
byte[] byteEk,
byte[] byteHashedEk,
byte[] z,
MLKEMParameterSpec parameterSpec)
Create private key from private key byte array, public key byte array, public key hash and seed z.
|
MLKEMPrivateKey(byte[] arr,
MLKEMParameterSpec parameterSpec)
Create private key from a byte array, where
arr is either the seed,
which is 64 bytes long, or the expandedKey, which is long as for the specific parameter defined. |
Modifier and Type | Method and Description |
---|---|
protected void |
decode(byte[] bytes) |
protected byte[] |
encode() |
boolean |
equals(Object o) |
String |
getAlgorithm() |
byte[] |
getExpandedKey()
Returns a copy of the private key as a byte array (raw data).
|
MLKEMPrivateKey.PrivateKeyEncoding |
getPrivateKeyEncodingDefault()
Get the
privateKeyEncodingDefault variable |
MLKEMPublicKey |
getPublicKey()
Returns the MLKEMPublicKey
|
byte[] |
getSeed()
Returns a copy of the seed as a byte array.
|
int |
hashCode() |
void |
setPrivateKeyEncodingDefault(MLKEMPrivateKey.PrivateKeyEncoding privateKeyEncoding)
Set the
privateKeyEncodingDefault variable |
String |
toString() |
clone, createPrivateKeyInfo, decode, getAlgorithmID, getAttributes, getEncoded, getFormat, getPrivateKey, getPrivateKey, getPrivateKey, getPrivateKey, getPrivateKey, getPrivateKey, getPubKey, setAttributes, setPubKey, toASN1Object, writeTo
finalize, getClass, notify, notifyAll, wait, wait, wait
destroy, isDestroyed
public MLKEMPrivateKey(byte[] byteDk, byte[] byteEk, byte[] byteHashedEk, byte[] z, MLKEMParameterSpec parameterSpec) throws InvalidKeyException
expandedKey
is build internally by concatenating byteDk
, byteEk
,
byteHashedEk
and z
. The seed cannot be recreated, therefore seed is null.byteDk
- private key (KEM decaps key) as a byte sequencebyteEk
- public key (KEM encaps key) as a byte sequencebyteHashedEk
- public key hashz
- seedparameterSpec
- the given specification of the parametersInvalidKeyException
- throws an error if failing to create the encoding of the private keypublic MLKEMPrivateKey(byte[] arr, MLKEMParameterSpec parameterSpec) throws InvalidKeyException
arr
is either the seed,
which is 64 bytes long, or the expandedKey, which is long as for the specific parameter defined.
According to NIST FIPS203:
For ML-KEM-512 expandedKey is 1632 bytes
For ML-KEM-768 expandedKey is 2400 bytes
For ML-KEM-1024 expandedKey is 3168 bytesarr
- raw byte arrayparameterSpec
- the given specification of the parametersInvalidKeyException
- throws an error if failing to create the encoding of the private keypublic MLKEMPrivateKey(byte[] encoded) throws InvalidKeyException
encoded
- private key encoded as ASN.1 byte sequenceInvalidKeyException
- if the encoding is not validpublic void setPrivateKeyEncodingDefault(MLKEMPrivateKey.PrivateKeyEncoding privateKeyEncoding)
privateKeyEncodingDefault
variableprivateKeyEncoding
- public MLKEMPrivateKey.PrivateKeyEncoding getPrivateKeyEncodingDefault()
privateKeyEncodingDefault
variableprotected void decode(byte[] bytes) throws InvalidKeyException
decode
in class iaik.pkcs.pkcs8.PrivateKeyInfo
InvalidKeyException
protected byte[] encode()
encode
in class iaik.pkcs.pkcs8.PrivateKeyInfo
public String getAlgorithm()
getAlgorithm
in interface Key
getAlgorithm
in class iaik.pkcs.pkcs8.PrivateKeyInfo
public boolean equals(Object o)
equals
in class iaik.pkcs.pkcs8.PrivateKeyInfo
public int hashCode()
hashCode
in class iaik.pkcs.pkcs8.PrivateKeyInfo
public String toString()
toString
in class iaik.pkcs.pkcs8.PrivateKeyInfo
public MLKEMPublicKey getPublicKey() throws InvalidKeyException
InvalidKeyException
public byte[] getExpandedKey()
expandedKey
== (byteDk
||byteEk
||byteHashedEk
||z
)public byte[] getSeed()
Copyright © 2020–2025 Stiftung SIC. All rights reserved.