Skip to content

Instantly share code, notes, and snippets.

@Jesse-V
Created August 24, 2015 20:19
Show Gist options
  • Save Jesse-V/476bd3e38d43ae78c665 to your computer and use it in GitHub Desktop.
Save Jesse-V/476bd3e38d43ae78c665 to your computer and use it in GitHub Desktop.
floodberry/ed25519-donna under Botan
#include "ed25519.h"
ed25519_secret_key sk;
Botan::AutoSeeded_RNG rng;
rng.randomize(sk, sizeof(ed25519_secret_key));
ed25519_public_key pk;
ed25519_publickey(sk, pk);
std::string msg("hello world");
const uint8_t* msgData = reinterpret_cast<const uint8_t*>(msg.c_str());
ed25519_signature sig;
ed25519_sign(msgData, msg.size(), sk, pk, sig);
int check = ed25519_sign_open(msgData, msg.size(), pk, sig);
if (check == 0)
std::cout << "Signature is valid." << std::endl;
else if (check == 1)
std::cout << "Signature failed." << std::endl;
else if (check == -1)
std::cerr << "Ed25519 failure!" << std::endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment