fix compilation with main

This commit is contained in:
Jaremy Creechley 2023-11-20 22:38:06 -07:00
parent 6f7b769e15
commit 22b684a31c
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
7 changed files with 107 additions and 11 deletions

View File

@ -3,7 +3,7 @@
#include <assert.h>
#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

View File

@ -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

View File

@ -0,0 +1,85 @@
#ifndef __CIRCOM_H
#define __CIRCOM_H
#include <map>
#include <gmp.h>
#include <mutex>
#include <condition_variable>
#include <thread>
#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<u32,IODefPair> 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

BIN
example/support/product Executable file

Binary file not shown.

View File

@ -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".}

View File

@ -6,7 +6,7 @@
#include <sstream>
#include <memory>
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<FrElement> & 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<FrElement> & 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

View File

@ -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