Package zeroecho.core.alg.ntruprime
Class SntruPrimeAlgorithm
java.lang.Object
zeroecho.core.CryptoAlgorithm
zeroecho.core.alg.AbstractCryptoAlgorithm
zeroecho.core.alg.ntruprime.SntruPrimeAlgorithm
Configures and exposes the SNTRU Prime post-quantum KEM and a
message-agreement adapter backed by the Bouncy Castle PQC provider.
Overview
This algorithm wrapper integrates Bouncy Castle's"SNTRUPrime" implementation into the ZeroEcho capability model. It
registers two KEM capabilities (encapsulation and decapsulation) and maps
them to an agreement-style API via a lightweight adapter so that callers can
use a single MessageAgreementContext for both initiator and responder
roles.
Capabilities
AlgorithmFamily.KEM / KeyUsage.ENCAPSULATE- creates aKemContextbound to a recipient public key.AlgorithmFamily.KEM / KeyUsage.DECAPSULATE- creates aKemContextbound to a holder's private key.AlgorithmFamily.AGREEMENT / KeyUsage.AGREEMENT- provides aMessageAgreementContextthat delegates to aKemContextfor initiator and responder roles.
Key material
A default asymmetric key builder is registered forSntruPrimeKeyGenSpec with sntrup1277 as the default variant.
Additional import builders are provided for X.509-encoded public keys and
PKCS#8-encoded private keys.
Provider requirements
All key operations rely onBouncyCastlePQCProvider. The provider must be installed in the
current JVM before use, otherwise key generation and import will fail with a
NoSuchProviderException. See ensureProvider().
Example
// Initialize the algorithm and generate a key pair
SntruPrimeAlgorithm alg = new SntruPrimeAlgorithm();
KeyPair kp = alg.keys(SntruPrimeKeyGenSpec.sntrup761())
.generateKeyPair(SntruPrimeKeyGenSpec.sntrup761());
// Initiator (Alice) encapsulates to Bob's public key
MessageAgreementContext alice = alg
.context(AlgorithmFamily.AGREEMENT, KeyUsage.AGREEMENT, MessageAgreementContext.class,
kp.getPublic(), VoidSpec.INSTANCE);
// Responder (Bob) decapsulates with his private key
MessageAgreementContext bob = alg
.context(AlgorithmFamily.AGREEMENT, KeyUsage.AGREEMENT, MessageAgreementContext.class,
kp.getPrivate(), VoidSpec.INSTANCE);
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class zeroecho.core.CryptoAlgorithm
CryptoAlgorithm.AsymBuilderInfo, CryptoAlgorithm.SymBuilderInfo -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new algorithm wrapper for SNTRU Prime and registers its KEM and agreement capabilities, together with key builders for generation and import. -
Method Summary
Methods inherited from class zeroecho.core.alg.AbstractCryptoAlgorithm
capabilityMethods inherited from class zeroecho.core.CryptoAlgorithm
addCapability, asymmetricBuildersInfo, asymmetricKeyBuilder, bind, create, displayName, generateKeyPair, generateKeyPair, generateSecret, id, importPrivate, importPublic, importSecret, listCapabilities, priority, providerName, registerAsymmetricKeyBuilder, registerSymmetricKeyBuilder, roles, supports, symmetricBuildersInfo, symmetricKeyBuilder
-
Constructor Details
-
SntruPrimeAlgorithm
public SntruPrimeAlgorithm()Creates a new algorithm wrapper for SNTRU Prime and registers its KEM and agreement capabilities, together with key builders for generation and import.The constructor:
- Declares the algorithm names used by the provider.
- Registers KEM encapsulation and decapsulation capabilities.
- Registers agreement capabilities that delegate to a KEM-based adapter.
- Registers an asymmetric key builder for
SntruPrimeKeyGenSpecincluding the defaultsntrup1277variant. - Registers import builders for X.509 public keys and PKCS#8 private keys.
-