Class XdhAlgorithm


public final class XdhAlgorithm extends AbstractCryptoAlgorithm
Algorithm definition for XDH (elliptic curve Diffie-Hellman) key agreement, backed by the JCA KeyAgreement API.

This algorithm integrates the XDH family (currently X25519, optionally X448 in supporting providers) into the ZeroEcho registry. It exposes the KeyUsage.AGREEMENT role and produces AgreementContext instances using GenericJcaAgreementContext, which delegates to the standard JCA KeyAgreement primitive (e.g., "XDH", "X25519").

Behavior

Key material and builders

Example

// Discover the algorithm definition (via ServiceLoader or explicit construction)
CryptoAlgorithm xdh = new XdhAlgorithm();

// Generate key pairs
KeyPair a = xdh.asymmetricKeyPairGenerator(XdhSpec.class).generateKeyPair(XdhSpec.X25519);
KeyPair b = xdh.asymmetricKeyPairGenerator(XdhSpec.class).generateKeyPair(XdhSpec.X25519);

// Perform agreement on side A
AgreementContext ctxA = xdh.createContext(KeyUsage.AGREEMENT, a.getPrivate(), XdhSpec.X25519);
ctxA.setPeerPublic(b.getPublic());
byte[] secretA = ctxA.deriveSecret();

// Perform agreement on side B
AgreementContext ctxB = xdh.createContext(KeyUsage.AGREEMENT, b.getPrivate(), XdhSpec.X25519);
ctxB.setPeerPublic(a.getPublic());
byte[] secretB = ctxB.deriveSecret();

// secretA and secretB are equal; apply a KDF before using them
Since:
1.0
  • Constructor Details

  • Method Details

    • parameterSets

      public List<ParameterSetDescriptor<? extends AlgorithmKeySpec>> parameterSets()
      Description copied from class: CryptoAlgorithm
      Returns 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 a ParameterSetDescriptor.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:
      parameterSets in class CryptoAlgorithm
      Returns:
      immutable list of parameter set descriptors; never null