sanity_check.c 689 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "config.h"
  2. #include <assert.h>
  3. #include <stdio.h>
  4. #include <gmp.h>
  5. #include "ddlog.h"
  6. #include "hss.h"
  7. int main()
  8. {
  9. hss_init();
  10. mpz_t x, y, z;
  11. uint32_t xc, yc;
  12. mpz_inits(x, y, z, NULL);
  13. /* z is a uniformly random group element */
  14. mpz_urandomm(x, _rstate, q);
  15. mpz_set_ui(z, 2);
  16. mpz_powm(z, z, x, p);
  17. /* y = 2z (mod p) */
  18. mpz_mul_2exp(y, z, 1);
  19. mpz_mod(y, y, p);
  20. /* x = 2y (mod p) */
  21. mpz_mul_2exp(x, y, 1);
  22. mpz_mod(x, z, p);
  23. printf("%lx %lx\n", x->_mp_d[23], y->_mp_d[23]);
  24. xc = convert(x->_mp_d);
  25. yc = convert(y->_mp_d);
  26. printf("%d %d %d\n", xc, yc, distinguished(z));
  27. hss_clear();
  28. mpz_clears(x, y, z, NULL);
  29. return 0;
  30. }