keypair.c 417 B

1234567891011121314151617181920212223
  1. #include "randombytes.h"
  2. #include "crypto_sign.h"
  3. #include "crypto_hash_sha512.h"
  4. #include "ge.h"
  5. int crypto_sign_keypair(unsigned char *pk,unsigned char *sk)
  6. {
  7. unsigned char h[64];
  8. ge_p3 A;
  9. int i;
  10. randombytes(sk,32);
  11. crypto_hash_sha512(h,sk,32);
  12. h[0] &= 248;
  13. h[31] &= 63;
  14. h[31] |= 64;
  15. ge_scalarmult_base(&A,h);
  16. ge_p3_tobytes(pk,&A);
  17. for (i = 0;i < 32;++i) sk[32 + i] = pk[i];
  18. return 0;
  19. }