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.

57 lines
1.1 KiB

5 years ago
5 years ago
5 years ago
  1. #ifndef __CIRCOM_H
  2. #define __CIRCOM_H
  3. #include <gmp.h>
  4. #include <stdint.h>
  5. class Circom_CalcWit;
  6. typedef unsigned long long u64;
  7. typedef uint32_t u32;
  8. typedef uint8_t u8;
  9. typedef mpz_t BigInt;
  10. typedef BigInt *PBigInt;
  11. typedef int Circom_Size;
  12. typedef Circom_Size *Circom_Sizes;
  13. struct Circom_HashEntry {
  14. u64 hash;
  15. int pos;
  16. };
  17. typedef Circom_HashEntry *Circom_HashTable;
  18. typedef enum { _typeSignal, _typeComponent} Circom_EntryType;
  19. struct Circom_ComponentEntry {
  20. int offset;
  21. Circom_Sizes sizes;
  22. Circom_EntryType type;
  23. };
  24. typedef Circom_ComponentEntry *Circom_ComponentEntries;
  25. typedef void (*Circom_ComponentFunction)(Circom_CalcWit *ctx);
  26. struct Circom_Component {
  27. Circom_HashTable hashTable;
  28. Circom_ComponentEntries entries;
  29. Circom_ComponentFunction fn;
  30. int inputSignals;
  31. };
  32. class Circom_Circuit {
  33. public:
  34. int NSignals;
  35. int NComponents;
  36. int NInputs;
  37. int NOutputs;
  38. int NVars;
  39. int *wit2sig;
  40. Circom_Component *components;
  41. u32 *mapIsInput;
  42. const char *P;
  43. };
  44. #define BITMAP_ISSET(m, b) (m[b>>5] & (1 << (b&0x1F)))
  45. extern struct Circom_Circuit _circuit;
  46. #endif