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.

61 lines
1.4 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. #ifndef CIRCOM_CALCWIT_H
  2. #define CIRCOM_CALCWIT_H
  3. #include "circom.h"
  4. #include "zqfield.h"
  5. class Circom_CalcWit {
  6. #ifdef SANITY_CHECK
  7. bool *signalAssigned;
  8. #endif
  9. // componentStatus -> For each component
  10. // >0 Signals required to trigger
  11. // == 0 Component triggered
  12. int *inputSignalsToTrigger;
  13. BigInt *signalValues;
  14. Circom_Circuit *circuit;
  15. void triggerComponent(int newCIdx);
  16. void calculateWitness(void *input, void *output);
  17. public:
  18. ZqField *field;
  19. int cIdx;
  20. // Functions called by the circuit
  21. Circom_CalcWit(Circom_Circuit *aCircuit);
  22. ~Circom_CalcWit();
  23. int getSubComponentOffset(int cIdx, u64 hash);
  24. Circom_Sizes getSubComponentSizes(int cIdx, u64 hash);
  25. int getSignalOffset(int cIdx, u64 hash);
  26. Circom_Sizes getSignalSizes(int cIdx, u64 hash);
  27. PBigInt allocBigInts(int n);
  28. void freeBigInts(PBigInt bi, int n);
  29. void getSignal(int cIdx, int sIdx, PBigInt value);
  30. void setSignal(int cIdx, int sIdx, PBigInt value);
  31. void checkConstraint(PBigInt value1, PBigInt value2, char const *err);
  32. // Public functions
  33. inline void setInput(int idx, PBigInt val) {
  34. setSignal(0, circuit->wit2sig[idx], val);
  35. }
  36. inline void getWitness(int idx, PBigInt val) {
  37. mpz_set(*val, signalValues[circuit->wit2sig[idx]]);
  38. }
  39. void reset();
  40. };
  41. #endif // CIRCOM_CALCWIT_H