Skip to content

File syn_ed25519.h

FileList > crypto > syn_ed25519.h

Go to the source code of this file

Pure C99 Ed25519 Key Generation, Signing & Verification (RFC 8032).

  • #include "syn_sha512.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Public Types

Type Name
typedef SYN_SHA512 SYN_SHA512_Ctx
Alias for SHA-512 context.

Public Functions

Type Name
bool syn_ed25519_create_keypair (uint8_t public_key, uint8_t secret_key, const uint8_t seed)
Create an Ed25519 keypair from a 32-byte random seed (RFC 8032).
bool syn_ed25519_publickey (const uint8_t secret_key, uint8_t public_key)
Derive a 32-byte Ed25519 public key from a 32-byte secret key (RFC 8032 Section 5.1.5).
bool syn_ed25519_sign (const uint8_t * msg, size_t msg_len, const uint8_t secret_key, const uint8_t public_key, uint8_t sig)
Generate an Ed25519 signature (RFC 8032 Section 5.1.6).
bool syn_ed25519_verify (const uint8_t sig, const uint8_t * msg, size_t msg_len, const uint8_t public_key)
Verify an Ed25519 signature (RFC 8032 Section 5.1.7).
bool syn_ed25519_verify_hash (const uint8_t sig, const uint8_t h, const uint8_t public_key)
Verify an Ed25519 signature from a precomputed 64-byte challenge digest H(R || A || M).

Macros

Type Name
define SYN_ED25519_PUBLIC_KEY_SIZE 32U
Size of Ed25519 public key in bytes (32).
define SYN_ED25519_SECRET_KEY_SIZE 32U
Size of Ed25519 secret key (seed) in bytes (32).
define SYN_ED25519_SEED_SIZE 32U
Size of Ed25519 seed in bytes (32).
define SYN_ED25519_SIGNATURE_SIZE 64U
Size of Ed25519 signature in bytes (64).

Public Types Documentation

typedef SYN_SHA512_Ctx

Alias for SHA-512 context.

typedef SYN_SHA512 SYN_SHA512_Ctx;


Public Functions Documentation

function syn_ed25519_create_keypair

Create an Ed25519 keypair from a 32-byte random seed (RFC 8032).

bool syn_ed25519_create_keypair (
    uint8_t public_key,
    uint8_t secret_key,
    const uint8_t seed
) 

Parameters:

  • public_key Output 32-byte public key.
  • secret_key Output 32-byte secret key (copies seed).
  • seed Input 32-byte random seed.

Returns:

true on success, false on invalid parameter.


function syn_ed25519_publickey

Derive a 32-byte Ed25519 public key from a 32-byte secret key (RFC 8032 Section 5.1.5).

bool syn_ed25519_publickey (
    const uint8_t secret_key,
    uint8_t public_key
) 

Parameters:

  • secret_key 32-byte private key/seed.
  • public_key Output 32-byte compressed Edwards public key.

Returns:

true on success, false on invalid parameter.


function syn_ed25519_sign

Generate an Ed25519 signature (RFC 8032 Section 5.1.6).

bool syn_ed25519_sign (
    const uint8_t * msg,
    size_t msg_len,
    const uint8_t secret_key,
    const uint8_t public_key,
    uint8_t sig
) 

Parameters:

  • msg Message to sign.
  • msg_len Length of message in bytes.
  • secret_key 32-byte private key.
  • public_key 32-byte public key (optional; if NULL, derived internally from secret_key).
  • sig Output 64-byte signature (R || S).

Returns:

true on success, false on invalid parameter.


function syn_ed25519_verify

Verify an Ed25519 signature (RFC 8032 Section 5.1.7).

bool syn_ed25519_verify (
    const uint8_t sig,
    const uint8_t * msg,
    size_t msg_len,
    const uint8_t public_key
) 

Parameters:

  • sig 64-byte signature (R || S).
  • msg Message bytes.
  • msg_len Message length in bytes.
  • public_key 32-byte Ed25519 public key.

Returns:

true if valid signature, false otherwise.


function syn_ed25519_verify_hash

Verify an Ed25519 signature from a precomputed 64-byte challenge digest H(R || A || M).

bool syn_ed25519_verify_hash (
    const uint8_t sig,
    const uint8_t h,
    const uint8_t public_key
) 

Parameters:

  • sig 64-byte signature (R || S).
  • h 64-byte SHA-512 digest.
  • public_key 32-byte Ed25519 public key.

Returns:

true if valid signature, false otherwise.


Macro Definition Documentation

define SYN_ED25519_PUBLIC_KEY_SIZE

Size of Ed25519 public key in bytes (32).

#define SYN_ED25519_PUBLIC_KEY_SIZE `32U`


define SYN_ED25519_SECRET_KEY_SIZE

Size of Ed25519 secret key (seed) in bytes (32).

#define SYN_ED25519_SECRET_KEY_SIZE `32U`


define SYN_ED25519_SEED_SIZE

Size of Ed25519 seed in bytes (32).

#define SYN_ED25519_SEED_SIZE `32U`


define SYN_ED25519_SIGNATURE_SIZE

Size of Ed25519 signature in bytes (64).

#define SYN_ED25519_SIGNATURE_SIZE `64U`



The documentation for this class was generated from the following file src/syntropic/crypto/syn_ed25519.h