Class EdDSA
- All Implemented Interfaces:
AutoCloseable
Generate Ed25519 keys, sign data, verify signatures, and compute shared secrets.
Chilkat.EdDSA is the Chilkat class for Ed25519-based EdDSA
operations. It can generate Ed25519 private keys, sign data contained in
BinData, verify encoded signatures with public keys, and compute
encoded shared secrets from compatible private/public key pairs. It supports
the Ed25519, Ed25519ph, and Ed25519ctx variants, with optional context bytes
supplied as a hex string when the selected variant requires them.
Generate Ed25519 keys
Create Ed25519 private keys for signing, verification, and compatible key-agreement workflows.
Sign BinData
Sign binary data directly from a Chilkat.BinData object
using an Ed25519 private key.
Verify signatures
Verify encoded EdDSA signatures using the corresponding public key and the original message data.
Ed25519 variants
Use Ed25519, Ed25519ph, or Ed25519ctx depending on the protocol or interoperability requirements.
Context support
Supply optional context bytes as a hex string for workflows that use the Ed25519ctx or related context-aware signing modes.
Shared-secret output
Compute encoded shared secrets from compatible private and public key pairs for protocols that require this operation.
Common pattern:
Generate or load an Ed25519 key, choose the required EdDSA variant, provide
context bytes when needed, then sign or verify the BinData
content. For shared-secret workflows, compute the encoded secret and pass it
through the key derivation or formatting step required by the protocol.
For an extended overview, see EdDSA Class Overview.
</section>
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgenEd25519Key(Prng prng, PrivateKey privKey)Generates a new Ed25519 key pair usingprngas the source of cryptographically secure random bytes.Selects the Ed25519 signature variant used byandsignBdENC(BinData, String, PrivateKey).verifyBdENC(BinData, String, String, PublicKey)Gets or sets the context bytes used by the Ed25519ctx and Ed25519ph signature variants.voidsetAlgorithm(String value)Sets theAlgorithmproperty; seegetAlgorithm().voidsetContext(String value)Sets theContextproperty; seegetContext().sharedSecretENC(PrivateKey privkey, PublicKey pubkey, String encoding)Computes a 32-byte X25519 shared secret from the private key inprivkeyand the peer's public key inpubkey.signBdENC(BinData bd, String encoding, PrivateKey privkey)Creates an EdDSA signature over the exact byte sequence contained inbd, using the Ed25519 private key inprivkey.voidverifyBdENC(BinData bd, String encodedSig, String enocding, PublicKey pubkey)Verifies the encoded EdDSA signature inencodedSigagainst the exact byte sequence contained inbd, using the Ed25519 public key inpubkey.Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
EdDSA
public EdDSA()Creates a newEdDSAobject.
-
-
Method Details
-
getAlgorithm
Selects the Ed25519 signature variant used byandsignBdENC(BinData, String, PrivateKey). The default isverifyBdENC(BinData, String, String, PublicKey)Ed25519.Value Behavior Context
Ed25519The standard pure Ed25519 signature scheme. The complete message is signed directly by the Ed25519 algorithm. A context is not part of this variant and should be empty.Ed25519ctxPure Ed25519 with domain separation supplied by a context string. The context should normally be nonempty and must match exactly during verification.Ed25519phPrehash Ed25519. Chilkat first hashes the message with SHA-512 as defined for this variant. May be empty or contain up to 255 context bytes; it must match exactly during verification.Interoperability requirement: The signer and verifier must select the same variant. An Ed25519ph signature cannot be verified as ordinary Ed25519, even if the same key and message are used. Scope: This property selects a signing variant; it does not change the type of key generated by
and does not affectgenEd25519Key(Prng, PrivateKey).sharedSecretENC(PrivateKey, PublicKey, String)- Returns:
- the value of the
Algorithmproperty
-
setAlgorithm
Sets theAlgorithmproperty; seegetAlgorithm().- Parameters:
value- the new value (notnull)
-
getContext
Gets or sets the context bytes used by the Ed25519ctx and Ed25519ph signature variants. Supply the bytes as a hexadecimal string. The default is an empty string.A context may contain at most 255 bytes, which corresponds to at most 510 hexadecimal characters. The same context bytes must be supplied byte-for-byte when verifying the signature. An invalid hexadecimal value or an oversized context causes the signing or verification operation to fail.
Domain separation: A context is a public protocol label that separates signatures created for different purposes, applications, or message types. It is not a password, secret key, salt, or part of the message payload. Algorithm interaction: Use this property only when
isgetAlgorithm()Ed25519ctxorEd25519ph. StandardEd25519does not include a context.- Returns:
- the value of the
Contextproperty
-
setContext
Sets theContextproperty; seegetContext().- Parameters:
value- the new value (notnull)
-
genEd25519Key
Generates a new Ed25519 key pair usingprngas the source of cryptographically secure random bytes. On success, the generated private key and its corresponding public key are stored in the existingPrivateKeyobject passed inprivKey.Returns
on success andtrueon failure. If the method fails, inspectfalseLastErrorTextfor details.Ed25519 key size: Ed25519 key generation begins with a 32-byte private-key seed from which the public key is derived. Exported PEM, DER, JWK, or other key formats may contain additional structure and metadata, so their serialized size is not necessarily 32 bytes. Protect the private key: The generated private key can create signatures on behalf of its owner. Store it securely and disclose only the corresponding public key.
- Parameters:
prng- theprngargument (notnull)privKey- theprivKeyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
signBdENC
Creates an EdDSA signature over the exact byte sequence contained inbd, using the Ed25519 private key inprivkey. The 64-byte signature is returned as text using the binary encoding named byencoding, such ashex,hexlower, orbase64.The selected
andgetAlgorithm()properties determine whether the operation uses Ed25519, Ed25519ctx, or Ed25519ph. For Ed25519ph, pass the original message bytes ingetContext()bd; Chilkat performs the required SHA-512 prehash as part of the Ed25519ph operation.Deterministic signatures: Ed25519 signatures do not require a caller-supplied per-message random number. With the same private key, message, algorithm variant, and context, the signature is deterministic. Ed25519ph is a distinct variant: It is not equivalent to hashing the message yourself and then signing that digest with ordinary Ed25519. Ed25519ph includes variant-specific domain separation.
This is a string-returning method. Check
LastMethodSuccessbefore using the returned value; on failure, inspectLastErrorText.- Parameters:
bd- thebdargument (notnull)encoding- theencodingargument (notnull)privkey- theprivkeyargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
verifyBdENC
Verifies the encoded EdDSA signature inencodedSigagainst the exact byte sequence contained inbd, using the Ed25519 public key inpubkey.enocdingnames the binary encoding ofencodedSig, such ashex,hexlower, orbase64.The verifier must use the same
andgetAlgorithm()values that were used to create the signature. Any change to the message, signature, public key, algorithm variant, or context causes verification to fail.getContext()Returns
only when the signature is valid. Returnstruefor an invalid signature or an operational error, such as malformed encoded input, an unsupported encoding, or an unsuitable key. InspectfalseLastErrorTextfor diagnostic information.Trust remains an application decision: A valid signature proves that the message matches the supplied public key. The application must still establish that the public key belongs to the expected signer.
- Parameters:
bd- thebdargument (notnull)encodedSig- theencodedSigargument (notnull)enocding- theenocdingargument (notnull)pubkey- thepubkeyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-