Skip to content
Philipp Lay edited this page Nov 3, 2017 · 1 revision

Ed25519 Signatures

libeddsa has three functions for dealing with ed25519 signatures:

#include <eddsa.h>

void ed25519_genpub(uint8_t pub[32],
                  const uint8_t sec[32]);

void ed25519_sign(uint8_t sig[64],
                const uint8_t sec[32],
                const uint8_t pub[32],
                const uint8_t *data, size_t len);

bool ed25519_verify(const uint8_t sig[64],
                  const uint8_t pub[32],
                  const uint8_t *data, size_t len);

Key generation

Secret-key as well as public-keys are 32 byte arrays. You generate a secret key sec by simply filling it with random data, just make sure it is of cryptographic quality!

The corresponding public-key pub is than derived from sec by calling eddsa_genpub:

ed25519_genpub(pub, sec);

Signing

A ed25519 signature is encoded into a 64 byte array. Given the secret key sec as well as the corresponding public-key pub the message msg of length len is signed by:

ed25519_sign(sig, sec, pub, msg, len);

Verification

For verification of a message msg of length len the signature sig and the public-key used for signing pub are needed:

if (ed25519_verify(sig, pub, msg, len)) {
    /* signature is good */
} else {
    /* signature is bad */
}
Clone this wiki locally