Class Ed25519SignatureContext
java.lang.Object
zeroecho.core.alg.common.eddsa.CommonEdDSASignatureContext
zeroecho.core.alg.ed25519.Ed25519SignatureContext
- All Implemented Interfaces:
Closeable, AutoCloseable, CryptoContext, SignatureContext, TagEngine<Signature>
Signature context for Ed25519 with a fixed 64-byte tag length.
This implementation binds the Ed25519 algorithm to SignatureContext
via CommonEdDSASignatureContext. Internally it configures a JCA
Signature with the "Ed25519" name and delegates all streaming
and verification behavior to the common adapter.
Algorithm characteristics
- JCA signature name:
"Ed25519". - Fixed signature length: 64 bytes (reported by
CommonEdDSASignatureContext.tagLength()).
Usage
One-shot API
// Signing
PrivateKey priv = ...;
SignatureContext signer =
new Ed25519SignatureContext(CryptoAlgorithms.require("Ed25519"), priv);
signer.update(message);
byte[] sig = signer.sign();
// Verifying
PublicKey pub = ...;
SignatureContext verifier =
new Ed25519SignatureContext(CryptoAlgorithms.require("Ed25519"), pub);
verifier.update(message);
boolean ok = verifier.verify(sig);
Streaming pipeline (wrap)
// SIGN mode: body bytes followed by 64-byte signature trailer
try (SignatureContext ctx =
new Ed25519SignatureContext(CryptoAlgorithms.require("Ed25519"), priv);
InputStream in = ctx.wrap(upstream)) {
in.transferTo(out);
}
// VERIFY mode: supply expected signature; verification occurs at EOF
try (SignatureContext ctx =
new Ed25519SignatureContext(CryptoAlgorithms.require("Ed25519"), pub)) {
ctx.setExpectedTag(expectedSig);
try (InputStream in = ctx.wrap(bodyWithoutTrailer)) {
in.transferTo(java.io.OutputStream.nullOutputStream());
}
}
Thread-safety
Instances are stateful and not thread-safe. Use one context per signing or
verification operation, and call wrap(...) at most once per instance.
- Since:
- 1.0
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionEd25519SignatureContext(CryptoAlgorithm algorithm, PrivateKey privateKey) Constructs a signing context bound to the given private key.Ed25519SignatureContext(CryptoAlgorithm algorithm, PublicKey publicKey) Constructs a verification context bound to the given public key. -
Method Summary
Methods inherited from class CommonEdDSASignatureContext
algorithm, close, getVerificationCore, key, setExpectedTag, setVerificationApproach, tagLength, wrap
-
Constructor Details
-
Ed25519SignatureContext
public Ed25519SignatureContext(CryptoAlgorithm algorithm, PrivateKey privateKey) throws GeneralSecurityException Constructs a signing context bound to the given private key.- Parameters:
algorithm- parent algorithm descriptor; must not benullprivateKey- Ed25519 private key; must not benull- Throws:
GeneralSecurityException- if the underlying JCA engine cannot be initializedNullPointerException- if any argument isnull
-
Ed25519SignatureContext
public Ed25519SignatureContext(CryptoAlgorithm algorithm, PublicKey publicKey) throws GeneralSecurityException Constructs a verification context bound to the given public key.- Parameters:
algorithm- parent algorithm descriptor; must not benullpublicKey- Ed25519 public key; must not benull- Throws:
GeneralSecurityException- if the underlying JCA engine cannot be initializedNullPointerException- if any argument isnull
-