You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.1 KiB

  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <stdint.h>
  4. #include "../wots.h"
  5. #include "../randombytes.h"
  6. #include "../params.h"
  7. static void hexdump(unsigned char *a, size_t len)
  8. {
  9. size_t i;
  10. for (i = 0; i < len; i++)
  11. printf("%02x", a[i]);
  12. }
  13. int main()
  14. {
  15. unsigned char seed[XMSS_N];
  16. unsigned char pub_seed[XMSS_N];
  17. int sig_len = XMSS_WOTS_LEN*XMSS_N;
  18. unsigned char pk1[sig_len];
  19. unsigned char pk2[sig_len];
  20. unsigned char sig[sig_len];
  21. uint32_t addr[8] = {1,2,3,4};
  22. unsigned char msg[XMSS_N];
  23. int i;
  24. randombytes(seed, XMSS_N);
  25. randombytes(pub_seed, XMSS_N);
  26. randombytes(msg, XMSS_N);
  27. //randombytes(addr, 16);
  28. wots_pkgen(pk1, seed, pub_seed, addr);
  29. wots_sign(sig, msg, seed, pub_seed, addr);
  30. wots_pkFromSig(pk2, sig, msg, pub_seed, addr);
  31. for (i = 0; i < sig_len; i++)
  32. if (pk1[i] != pk2[i]) {
  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. }