Files
hpcore/src/crypto.hpp
Ravin Perera cb364cc420 Compilation time improvements. (#52)
* Precompiled header for all common library headers (with cmake 3.16rc3).
* Divided cmake build into shared libraries.
* Added gold linker support.
* Separated websockets lambda expressions to an independent file.
2019-11-02 14:46:21 +05:30

36 lines
1.0 KiB
C++

#ifndef _HP_CRYPTO_
#define _HP_CRYPTO_
#include "pchheader.hpp"
/**
* Offers convenience functions for cryptographic operations wrapping libsodium.
* These functions are used for contract config and user/peer message authentication.
*/
namespace crypto
{
// Prefix byte to append to ed25519 keys.
static unsigned char KEYPFX_ed25519 = 0xED;
// Prefixed public key bytes.
static size_t PFXD_PUBKEY_BYTES = crypto_sign_ed25519_PUBLICKEYBYTES + 1;
// Prefixed secret key bytes.
static size_t PFXD_SECKEY_BYTES = crypto_sign_ed25519_SECRETKEYBYTES + 1;
int init();
void generate_signing_keys(std::string &pubkey, std::string &seckey);
std::string sign(std::string_view msg, std::string_view seckey);
std::string sign_hex(std::string_view msg, std::string_view seckeyhex);
int verify(std::string_view msg, std::string_view sig, std::string_view pubkey);
int verify_hex(std::string_view msg, std::string_view sighex, std::string_view pubkeyhex);
std::string get_hash(std::string_view data);
} // namespace crypto
#endif