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.

64 lines
1.4 KiB

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <assert.h>
  4. #include "fr.h"
  5. int main() {
  6. Fr_init();
  7. /*
  8. FrElement a = { 0, Fr_LONGMONTGOMERY, {1,1,1,1}};
  9. FrElement b = { 0, Fr_LONGMONTGOMERY, {2,2,2,2}};
  10. FrElement a={0x43e1f593f0000000ULL,0x2833e84879b97091ULL,0xb85045b68181585dULL,0x30644e72e131a029ULL};
  11. FrElement b = {3,0,0,0};
  12. FrElement c;
  13. */
  14. // Fr_add(&(c[0]), a, a);
  15. // Fr_add(&(c[0]), c, b);
  16. /*
  17. for (int i=0; i<1000000000; i++) {
  18. Fr_mul(&c, &a, &b);
  19. }
  20. Fr_mul(&c,&a, &b);
  21. */
  22. /*
  23. FrElement a1[10];
  24. FrElement a2[10];
  25. for (int i=0; i<10; i++) {
  26. a1[i].type = Fr_LONGMONTGOMERY;
  27. a1[i].shortVal =0;
  28. for (int j=0; j<Fr_N64; j++) {
  29. a2[i].longVal[j] = i;
  30. }
  31. }
  32. Fr_copyn(a2, a1, 10);
  33. for (int i=0; i<10; i++) {
  34. char *c1 = Fr_element2str(&a1[i]);
  35. char *c2 = Fr_element2str(&a2[i]);
  36. printf("%s\n%s\n\n", c1, c2);
  37. free(c1);
  38. free(c2);
  39. }
  40. */
  41. int tests[7] = { 0, 1, 2, -1, -2, 0x7FFFFFFF, (int)0x80000000};
  42. for (int i=0; i<7;i++) {
  43. FrElement a = { tests[i], Fr_SHORT, {0,0,0,0}};
  44. Fr_toLongNormal(&a);
  45. int b = Fr_toInt(&a);
  46. int c = Fr_isTrue(&a);
  47. printf("%d, %d, %d\n", tests[i], b, c);
  48. }
  49. FrElement err = { 0, Fr_LONGMONTGOMERY, {1,1,1,1}};
  50. Fr_toInt(&err);
  51. // printf("%llu, %llu, %llu, %llu\n", c.longVal[0], c.longVal[1], c.longVal[2], c.longVal[3]);
  52. }