Class FrodoAlgorithm
Frodo Key Encapsulation Mechanism (KEM)
Implementation of the FrodoKEM post-quantum algorithm, registered as aCryptoAlgorithm within ZeroEcho.
FrodoKEM is a lattice-based key encapsulation mechanism designed to resist quantum adversaries. It is based on the hardness of the Learning With Errors (LWE) problem, avoiding reliance on structured lattices. This provides conservative security at the cost of relatively large key sizes compared to schemes such as Kyber.
Capabilities
AlgorithmFamily.KEM:KeyUsage.ENCAPSULATEwith aPublicKeyto create aKemContext.KeyUsage.DECAPSULATEwith aPrivateKeyto recover the shared secret.
AlgorithmFamily.AGREEMENT:- As initiator (Alice) using a recipient
PublicKey, the KEM encapsulation is adapted into aMessageAgreementContext. - As responder (Bob) using his
PrivateKey, the decapsulation is similarly adapted into aMessageAgreementContext.
- As initiator (Alice) using a recipient
Key Management
- Key generation is parameterized by
FrodoKeyGenSpec, which selects a concrete variant such asFRODO_976_AESorFRODO_1344_SHAKE. - Public keys may be imported from
FrodoPublicKeySpecusing an X.509 encoding. - Private keys may be imported from
FrodoPrivateKeySpecusing a PKCS#8 encoding. - Generation and public/private import are registered as independent exact capabilities.
Provider requirements
FrodoKEM operations are delegated to the BouncyCastle provider
(BC). The static method ensureProvider() verifies that
the provider is installed; otherwise, a
NoSuchProviderException is thrown.
Example usage
// Generate a Frodo keypair
CryptoAlgorithm frodo = CryptoAlgorithms.require("Frodo");
KeyPair kp = frodo.asymmetricKeyPairGenerator(FrodoKeyGenSpec.class)
.generateKeyPair(FrodoKeyGenSpec.frodo1344aes());
// Encapsulate using the recipient's public key
KemContext enc = frodo.createContext(KeyUsage.ENCAPSULATE, kp.getPublic(), VoidSpec.INSTANCE);
// Decapsulate using the recipient's private key
KemContext dec = frodo.createContext(KeyUsage.DECAPSULATE, kp.getPrivate(), VoidSpec.INSTANCE);
Thread-safety
Instances of FrodoAlgorithm are immutable and may be shared safely
across threads. Contexts created via capabilities are not guaranteed to be
thread-safe.
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList<ParameterSetDescriptor<? extends AlgorithmKeySpec>> Returns the discoverable parameter sets (or parameterized templates) supported by this algorithm.Methods inherited from class AbstractCryptoAlgorithm
capabilityMethods inherited from class CryptoAlgorithm
addCapability, asymmetricKeyPairGenerator, bindContext, createContext, displayName, id, keyOperations, listCapabilities, priority, privateKeyImporter, providerName, publicKeyImporter, registerAsymmetricKeyPairGenerator, registerPrivateKeyImporter, registerPublicKeyImporter, registerSymmetricKeyGenerator, registerSymmetricKeyImporter, requiresStatefulSigning, roles, supports, symmetricKeyGenerator, symmetricKeyImporter
-
Constructor Details
-
FrodoAlgorithm
public FrodoAlgorithm()Constructs and registers the Frodo post-quantum algorithm.The constructor wires all roles and key builders supported by FrodoKEM:
- Binds
AlgorithmFamily.KEMroles forKeyUsage.ENCAPSULATE(public key) andKeyUsage.DECAPSULATE(private key) toFrodoKemContext. - Binds
AlgorithmFamily.AGREEMENTroles for initiator and responder, adapting the KEM context to aMessageAgreementContextviaKemMessageAgreementAdapter. - Registers asymmetric key builders for:
FrodoKeyGenSpec- key pair generation with a selectable Frodo variant.FrodoPublicKeySpec- importing X.509-encoded public keys.FrodoPrivateKeySpec- importing PKCS#8-encoded private keys.
The default algorithm identifier is
"Frodo"with display name"FrodoKEM", bound to theBCprovider.- Throws:
IllegalStateException- if registration of capabilities or builders fails
- Binds
-
-
Method Details
-
parameterSets
Description copied from class:CryptoAlgorithmReturns the discoverable parameter sets (or parameterized templates) supported by this algorithm.Callers (UIs, provisioning tools, policy engines) use this list to present users with valid, named key-generation options without prior knowledge of the concrete algorithm. Each entry is either a pre-built
ParameterSetDescriptor.Concrete(ready spec) or aParameterSetDescriptor.Template(user-supplied arguments produce the spec).The default implementation returns an empty list. Algorithms with finite, enumerable parameter sets should override this method. Overrides must return immutable lists in stable order, with unique nonblank descriptor identifiers. Registry loading validates a snapshot; external providers remain responsible for maintaining the contract on subsequent calls. Implementations may use
ParameterSetDescriptor.snapshot(List)to validate and copy their list.- Overrides:
parameterSetsin classCryptoAlgorithm- Returns:
- immutable list of parameter set descriptors; never
null
-