---
product: Chilkat
product_version: 11.7.0
language: c
language_label: C
class: EdDSA
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/c_CkEdDSARef.html
---
# Chilkat EdDSA — C — v11.7.0

> Chilkat 11.7.0 · language=c · class=EdDSA
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/EdDSA.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/c/guide.md`.

## Purpose

**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](https://www.chilkatsoft.com/eddsa_class_overview.asp).

## Object creation, unlocking and error handling

**Create/Dispose**

```c
HCkEdDSA instance = CkEdDSA_Create();
// ...
CkEdDSA_Dispose(instance);
```

`HCkEdDSA CkEdDSA_Create(void);`

Creates an instance of the HCkEdDSA object and returns a handle ("void \*" pointer). The handle is passed in the 1st argument for the functions listed on this page.

`void CkEdDSA_Dispose(HCkEdDSA handle);`

Objects created by calling CkEdDSA_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function. Also, any handle returned by a Chilkat "C" function must also be freed by the application by calling the appropriate Dispose method, such as CkEdDSA_Dispose.

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in C.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `void CkEdDSA_getDebugLogFilePath(HCkEdDSA cHandle, HCkString retval); void CkEdDSA_putDebugLogFilePath(HCkEdDSA cHandle, const char *newVal); const char *CkEdDSA_debugLogFilePath(HCkEdDSA cHandle);` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastErrorHtml` | `void CkEdDSA_getLastErrorHtml(HCkEdDSA cHandle, HCkString retval); const char *CkEdDSA_lastErrorHtml(HCkEdDSA cHandle);` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `void CkEdDSA_getLastErrorText(HCkEdDSA cHandle, HCkString retval); const char *CkEdDSA_lastErrorText(HCkEdDSA cHandle);` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `void CkEdDSA_getLastErrorXml(HCkEdDSA cHandle, HCkString retval); const char *CkEdDSA_lastErrorXml(HCkEdDSA cHandle);` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `BOOL CkEdDSA_getLastMethodSuccess(HCkEdDSA cHandle); void CkEdDSA_putLastMethodSuccess(HCkEdDSA cHandle, BOOL newVal);` | read/write | Indicates the success or failure of the most recent method call: `TRUE` means success, `FALSE` means failure. |
| `Utf8` | `BOOL CkEdDSA_getUtf8(HCkEdDSA cHandle); void CkEdDSA_putUtf8(HCkEdDSA cHandle, BOOL newVal);` | read/write | When set to `TRUE`, all `const char *` arguments and return values are interpreted as UTF-8 strings. |
| `VerboseLogging` | `BOOL CkEdDSA_getVerboseLogging(HCkEdDSA cHandle); void CkEdDSA_putVerboseLogging(HCkEdDSA cHandle, BOOL newVal);` | read/write | If set to `TRUE`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `void CkEdDSA_getVersion(HCkEdDSA cHandle, HCkString retval); const char *CkEdDSA_version(HCkEdDSA cHandle);` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `Algorithm` | property, read/write | `void CkEdDSA_getAlgorithm(HCkEdDSA cHandle, HCkString retval); void CkEdDSA_putAlgorithm(HCkEdDSA cHandle, const char *newVal); const char *CkEdDSA_algorithm(HCkEdDSA cHandle);` |
| `Context` | property, read/write | `void CkEdDSA_getContext(HCkEdDSA cHandle, HCkString retval); void CkEdDSA_putContext(HCkEdDSA cHandle, const char *newVal); const char *CkEdDSA_context(HCkEdDSA cHandle);` |
| `GenEd25519Key` | method | `BOOL CkEdDSA_GenEd25519Key(HCkEdDSA cHandle, HCkPrng prng, HCkPrivateKey privKey);` |
| `SharedSecretENC` | method | `BOOL CkEdDSA_SharedSecretENC(HCkEdDSA cHandle, HCkPrivateKey privkey, HCkPublicKey pubkey, const char *encoding, HCkString outStr); const char *CkEdDSA_sharedSecretENC(HCkEdDSA cHandle, HCkPrivateKey privkey, HCkPublicKey pubkey, const char *encoding);` |
| `SignBdENC` | method | `BOOL CkEdDSA_SignBdENC(HCkEdDSA cHandle, HCkBinData bd, const char *encoding, HCkPrivateKey privkey, HCkString outStr); const char *CkEdDSA_signBdENC(HCkEdDSA cHandle, HCkBinData bd, const char *encoding, HCkPrivateKey privkey);` |
| `VerifyBdENC` | method | `BOOL CkEdDSA_VerifyBdENC(HCkEdDSA cHandle, HCkBinData bd, const char *encodedSig, const char *enocding, HCkPublicKey pubkey);` |

## Properties

### EdDSA.Algorithm

`Chilkat 11.7.0 · c · EdDSA · Algorithm · property · read/write · since 9.5.0.91`

```c
void CkEdDSA_getAlgorithm(HCkEdDSA cHandle, HCkString retval);
void CkEdDSA_putAlgorithm(HCkEdDSA cHandle, const char *newVal);
const char *CkEdDSA_algorithm(HCkEdDSA cHandle);
```

Selects the Ed25519 signature variant used by `SignBdENC` and `VerifyBdENC`. The default is `Ed25519`.

| Value | Behavior | Context |
| :--- | :--- | :--- |
| `Ed25519` | The 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. |
| `Ed25519ctx` | Pure Ed25519 with domain separation supplied by a context string. | The context should normally be nonempty and must match exactly during verification. |
| `Ed25519ph` | Prehash 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 `GenEd25519Key` and does not affect `SharedSecretENC`.

### EdDSA.Context

`Chilkat 11.7.0 · c · EdDSA · Context · property · read/write · since 9.5.0.91`

```c
void CkEdDSA_getContext(HCkEdDSA cHandle, HCkString retval);
void CkEdDSA_putContext(HCkEdDSA cHandle, const char *newVal);
const char *CkEdDSA_context(HCkEdDSA cHandle);
```

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 `Algorithm` is `Ed25519ctx` or `Ed25519ph`. Standard `Ed25519` does not include a context.

## Methods

### EdDSA.GenEd25519Key

`Chilkat 11.7.0 · c · EdDSA · GenEd25519Key · method · since 9.5.0.83`

```c
BOOL CkEdDSA_GenEd25519Key(HCkEdDSA cHandle, HCkPrng prng, HCkPrivateKey privKey);
```

Generates a new Ed25519 key pair using `prng` as the source of cryptographically secure random bytes. On success, the generated private key and its corresponding public key are stored in the existing `PrivateKey` object passed in `privKey`.

Returns `TRUE` on success and `FALSE` on failure. If the method fails, inspect `LastErrorText` for 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.

Returns TRUE for success, FALSE for failure.

### EdDSA.SharedSecretENC

`Chilkat 11.7.0 · c · EdDSA · SharedSecretENC · method · since 9.5.0.83`

```c
BOOL CkEdDSA_SharedSecretENC(HCkEdDSA cHandle, HCkPrivateKey privkey, HCkPublicKey pubkey, const char *encoding, HCkString outStr);
const char *CkEdDSA_sharedSecretENC(HCkEdDSA cHandle, HCkPrivateKey privkey, HCkPublicKey pubkey, const char *encoding);
```

**Full documentation for this method (same in every language):** [Binary Encodings Supported by Chilkat](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/binary_encodings.md)

Computes a 32-byte X25519 shared secret from the private key in `privkey` and the peer's public key in `pubkey`. The resulting bytes are returned as text using the binary encoding named by `encoding`, such as `hex`, `hexlower`, or `base64`.

Each participant supplies its own private key and the other participant's public key. When Alice computes the secret from Alice's private key and Bob's public key, and Bob computes it from Bob's private key and Alice's public key, both obtain the same result.

**X25519, not an EdDSA signature operation:** This method performs Curve25519 Diffie-Hellman key agreement. It is separate from the Ed25519, Ed25519ctx, and Ed25519ph signature variants, so the `Algorithm` and `Context` properties do not apply.

**Do not normally use the raw secret directly:** A protocol should pass the shared secret through its specified key-derivation function and should authenticate the participants' public keys. Key agreement by itself does not establish the peer's identity.

This is a string-returning method. Check `LastMethodSuccess` before using the returned value; on failure, inspect `LastErrorText`.

Returns TRUE for success, FALSE for failure.

### EdDSA.SignBdENC

`Chilkat 11.7.0 · c · EdDSA · SignBdENC · method · since 9.5.0.83`

```c
BOOL CkEdDSA_SignBdENC(HCkEdDSA cHandle, HCkBinData bd, const char *encoding, HCkPrivateKey privkey, HCkString outStr);
const char *CkEdDSA_signBdENC(HCkEdDSA cHandle, HCkBinData bd, const char *encoding, HCkPrivateKey privkey);
```

**Full documentation for this method (same in every language):** [Binary Encodings Supported by Chilkat](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/binary_encodings.md)

Creates an EdDSA signature over the exact byte sequence contained in `bd`, using the Ed25519 private key in `privkey`. The 64-byte signature is returned as text using the binary encoding named by `encoding`, such as `hex`, `hexlower`, or `base64`.

The selected `Algorithm` and `Context` properties determine whether the operation uses Ed25519, Ed25519ctx, or Ed25519ph. For Ed25519ph, pass the original message bytes in `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 `LastMethodSuccess` before using the returned value; on failure, inspect `LastErrorText`.

Returns TRUE for success, FALSE for failure.

### EdDSA.VerifyBdENC

`Chilkat 11.7.0 · c · EdDSA · VerifyBdENC · method · since 9.5.0.83`

```c
BOOL CkEdDSA_VerifyBdENC(HCkEdDSA cHandle, HCkBinData bd, const char *encodedSig, const char *enocding, HCkPublicKey pubkey);
```

Verifies the encoded EdDSA signature in `encodedSig` against the exact byte sequence contained in `bd`, using the Ed25519 public key in `pubkey`. `enocding` names the binary encoding of `encodedSig`, such as `hex`, `hexlower`, or `base64`.

The verifier must use the same `Algorithm` and `Context` values that were used to create the signature. Any change to the message, signature, public key, algorithm variant, or context causes verification to fail.

Returns `TRUE` only when the signature is valid. Returns `FALSE` for an invalid signature or an operational error, such as malformed encoded input, an unsupported encoding, or an unsuitable key. Inspect `LastErrorText` for 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.

Returns TRUE for success, FALSE for failure.

## Related classes

[`BinData`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/c/classes/BinData.md), [`PrivateKey`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/c/classes/PrivateKey.md), [`Prng`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/c/classes/Prng.md), [`PublicKey`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/c/classes/PublicKey.md)

