Class SntruPrimeAlgorithm


public final class SntruPrimeAlgorithm extends AbstractCryptoAlgorithm
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 a KemContext bound to a recipient public key.
  • AlgorithmFamily.KEM / KeyUsage.DECAPSULATE - creates a KemContext bound to a holder's private key.
  • AlgorithmFamily.AGREEMENT / KeyUsage.AGREEMENT - provides a MessageAgreementContext that delegates to a KemContext for initiator and responder roles.

Key material

A default asymmetric key builder is registered for SntruPrimeKeyGenSpec 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 on BouncyCastlePQCProvider. 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:
  • 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 SntruPrimeKeyGenSpec including the default sntrup1277 variant.
      • Registers import builders for X.509 public keys and PKCS#8 private keys.