25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.0 KiB

  1. #include <stdio.h>
  2. #include "../wots.h"
  3. #include "../randombytes.h"
  4. static void hexdump(unsigned char *a, size_t len)
  5. {
  6. size_t i;
  7. for (i = 0; i < len; i++)
  8. printf("%02x", a[i]);
  9. }
  10. int main()
  11. {
  12. unsigned char seed[32];
  13. unsigned char pub_seed[32];
  14. wots_params params;
  15. wots_set_params(&params, 32, 32, 16);
  16. int sig_len = params.len*params.n;
  17. unsigned char pk1[sig_len];
  18. unsigned char pk2[sig_len];
  19. unsigned char sig[sig_len];
  20. unsigned char addr[16] = {1,2,3,4};
  21. unsigned char msg[32];
  22. int i;
  23. randombytes(seed, 32);
  24. randombytes(pub_seed, 32);
  25. randombytes(msg, 32);
  26. //randombytes(addr, 16);
  27. wots_pkgen(pk1, seed, &params, pub_seed, addr);
  28. wots_sign(sig, msg, seed, &params, pub_seed, addr);
  29. wots_pkFromSig(pk2, sig, msg, &params, pub_seed, addr);
  30. for(i=0;i<sig_len;i++)
  31. if(pk1[i] != pk2[i])
  32. {
  33. printf("pk1 != pk2 %d\n",i);
  34. return -1;
  35. }
  36. printf("worked great!\npk1: ");
  37. hexdump(pk1, sig_len);
  38. printf("\npk2: ");
  39. hexdump(pk2, sig_len);
  40. printf("\nsig: ");
  41. hexdump(sig, sig_len);
  42. printf("\n");
  43. return 0;
  44. }