wrapper-sign.cpp 553 B

1234567891011121314151617181920212223
  1. #include <string>
  2. using std::string;
  3. #include "crypto_sign.h"
  4. string crypto_sign(const string &m_string, const string &sk_string)
  5. {
  6. if (sk_string.size() != crypto_sign_SECRETKEYBYTES) throw "incorrect secret-key length";
  7. size_t mlen = m_string.size();
  8. unsigned char m[mlen+crypto_sign_BYTES];
  9. unsigned long long smlen;
  10. for (int i = 0;i < mlen;++i) m[i] = m_string[i];
  11. crypto_sign(
  12. m,
  13. &smlen,
  14. m,
  15. mlen,
  16. (const unsigned char *) sk_string.c_str()
  17. );
  18. return string(
  19. (char *) m,
  20. smlen
  21. );
  22. }