diff --git a/example/support/calcwit.cpp b/example/support/calcwit.cpp index a8e2d48..a0828de 100644 --- a/example/support/calcwit.cpp +++ b/example/support/calcwit.cpp @@ -3,7 +3,7 @@ #include #include "calcwit.hpp" -namespace CIRCUIT_NAME { +// namespace CIRCUIT_NAME { extern void run(Circom_CalcWit* ctx); @@ -126,4 +126,4 @@ std::string Circom_CalcWit::generate_position_array(uint* dimensions, uint size_ return positions; } -} //namespace +// } //namespace diff --git a/example/support/calcwit.hpp b/example/support/calcwit.hpp index b9028ed..7f877b8 100644 --- a/example/support/calcwit.hpp +++ b/example/support/calcwit.hpp @@ -12,7 +12,7 @@ #define NMUTEXES 12 //512 -namespace CIRCUIT_NAME { +// namespace CIRCUIT_NAME { u64 fnv1a(std::string s); @@ -68,6 +68,6 @@ private: typedef void (*Circom_TemplateFunction)(uint __cIdx, Circom_CalcWit* __ctx); -} //namespace +// } //namespace #endif // CIRCOM_CALCWIT_H diff --git a/example/support/circom.hpp b/example/support/circom.hpp new file mode 100644 index 0000000..eabc686 --- /dev/null +++ b/example/support/circom.hpp @@ -0,0 +1,85 @@ +#ifndef __CIRCOM_H +#define __CIRCOM_H + +#include +#include +#include +#include +#include + +#include "fr.hpp" + +typedef unsigned long long u64; +typedef uint32_t u32; +typedef uint8_t u8; + +//only for the main inputs +struct __attribute__((__packed__)) HashSignalInfo { + u64 hash; + u64 signalid; + u64 signalsize; +}; + +struct IODef { + u32 offset; + u32 len; + u32 *lengths; +}; + +struct IODefPair { + u32 len; + IODef* defs; +}; + +struct Circom_Circuit { + // const char *P; + HashSignalInfo* InputHashMap; + u64* witness2SignalList; + FrElement* circuitConstants; + std::map templateInsId2IOSignalInfo; +}; + + +struct Circom_Component { + u32 templateId; + u64 signalStart; + u32 inputCounter; + std::string templateName; + std::string componentName; + u64 idFather; + u32* subcomponents = NULL; + bool* subcomponentsParallel = NULL; + bool *outputIsSet = NULL; //one for each output + std::mutex *mutexes = NULL; //one for each output + std::condition_variable *cvs = NULL; + std::thread *sbct = NULL;//subcomponent threads +}; + +/* +For every template instantiation create two functions: +- name_create +- name_run + +//PFrElement: pointer to FrElement + +Every name_run or circom_function has: +===================================== + +//array of PFrElements for auxiliars in expression computation (known size); +PFrElements expaux[]; + +//array of PFrElements for local vars (known size) +PFrElements lvar[]; + +*/ + +uint get_main_input_signal_start(); +uint get_main_input_signal_no(); +uint get_total_signal_no(); +uint get_number_of_components(); +uint get_size_of_input_hashmap(); +uint get_size_of_witness(); +uint get_size_of_constants(); +uint get_size_of_io_map(); + +#endif // __CIRCOM_H diff --git a/example/support/product b/example/support/product new file mode 100755 index 0000000..3438287 Binary files /dev/null and b/example/support/product differ diff --git a/example/support/product.nim b/example/support/product.nim index 0ac7ec3..887b9fb 100644 --- a/example/support/product.nim +++ b/example/support/product.nim @@ -13,6 +13,8 @@ else: {.compile: "fr.cpp".} {.compile: "calcwit.cpp".} {.compile: "witnesscalc.cpp".} -{.compile: "circuits_incl.cpp".} -# {.compile: "product.cpp".} -{.compile: "main.cpp".} + +# {.compile: "main.cpp".} + +{.compile: "../build/product_cpp/product.cpp".} +{.compile: "../build/product_cpp/main.cpp".} diff --git a/example/support/witnesscalc.cpp b/example/support/witnesscalc.cpp index 4d6d810..d5d7587 100644 --- a/example/support/witnesscalc.cpp +++ b/example/support/witnesscalc.cpp @@ -6,7 +6,7 @@ #include #include -namespace CIRCUIT_NAME { +// namespace CIRCUIT_NAME { using json = nlohmann::json; @@ -75,6 +75,14 @@ Circom_Circuit* loadCircuit(const void *buffer, unsigned long buffer_size) { return circuit; } +#ifndef WITNESS_CALC_JSON_INTERNAL + +extern bool check_valid_number(std::string & s, uint base); + +extern void json2FrElements (json val, std::vector & vval); + +#else + bool check_valid_number(std::string & s, uint base){ bool is_valid = true; if (base == 16){ @@ -136,6 +144,7 @@ void json2FrElements (json val, std::vector & vval){ } } } +#endif void loadJson(Circom_CalcWit *ctx, const char *json_buffer, unsigned long buffer_size) { @@ -306,4 +315,4 @@ int witnesscalc( return WITNESSCALC_OK; } -} // namespace +// } // namespace diff --git a/example/support/witnesscalc.h b/example/support/witnesscalc.h index 86c1124..fe29e56 100644 --- a/example/support/witnesscalc.h +++ b/example/support/witnesscalc.h @@ -1,7 +1,7 @@ #ifndef WITNESSCALC_H #define WITNESSCALC_H -namespace CIRCUIT_NAME { +// namespace CIRCUIT_NAME { #define WITNESSCALC_OK 0x0 #define WITNESSCALC_ERROR 0x1 @@ -28,6 +28,6 @@ witnesscalc( char *wtns_buffer, unsigned long *wtns_size, char *error_msg, unsigned long error_msg_maxsize); -} // namespace +// } // namespace #endif // WITNESSCALC_H