Class SntruPrimeAlgorithm
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.asymmetricKeyPairGenerator(SntruPrimeKeyGenSpec.class)
.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:
-
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
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
-
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.
-
-
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
-