sign.c 621 B

1234567891011121314151617181920212223242526272829
  1. /* (Modified by Tor to generate detached signatures.) */
  2. #include <string.h>
  3. #include "crypto_sign.h"
  4. #include "crypto_hash_sha512.h"
  5. #include "ge.h"
  6. #include "sc.h"
  7. int crypto_sign(
  8. unsigned char *sig,
  9. const unsigned char *m, size_t mlen,
  10. const unsigned char *sk,const unsigned char *pk
  11. )
  12. {
  13. unsigned char nonce[64];
  14. unsigned char hram[64];
  15. ge_p3 R;
  16. crypto_hash_sha512_2(nonce, sk+32, 32, m, mlen);
  17. sc_reduce(nonce);
  18. ge_scalarmult_base(&R,nonce);
  19. ge_p3_tobytes(sig,&R);
  20. crypto_hash_sha512_3(hram, sig, 32, pk, 32, m, mlen);
  21. sc_reduce(hram);
  22. sc_muladd(sig + 32,hram,sk,nonce);
  23. return 0;
  24. }