-
Notifications
You must be signed in to change notification settings - Fork 8
Ed25519 Signatures
Philipp Lay edited this page Nov 3, 2017
·
1 revision
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);
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);
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);
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 */
}