pragma circom 2.0.0;
function x(inp)
{
var t[4];
t = [1, 2, 3, 4];
return t[inp];
}
template Main()
{
signal input in;
signal s;
signal output out;
s <-- x(in);
out <== 2*s;
}
component main = Main();
For the above circuit, I am able to generate witness using wasm.
But when I try to compile the C++ witness generator for the same, I get the following errors:
g++ -c main.cpp -std=c++11 -O3 -I.
main.cpp:116:2: error: expected declaration before ‘}’ token
116 | }
| ^
main.cpp:117:20: error: expected constructor, destructor, or type conversion before ‘(’ token
117 | Fr_str2element (&v, s.c_str());
| ^
main.cpp:118:5: error: ‘vval’ does not name a type
118 | vval.push_back(v);
| ^~~~
main.cpp:119:3: error: expected declaration before ‘}’ token
119 | } else {
| ^
main.cpp:119:5: error: expected unqualified-id before ‘else’
119 | } else {
| ^~~~
main.cpp:124:1: error: expected declaration before ‘}’ token
124 | }
| ^
main.cpp: In function ‘void loadJson(Circom_CalcWit*, std::string)’:
main.cpp:128:34: error: variable ‘std::ifstream inStream’ has initializer but incomplete type
128 | std::ifstream inStream(filename);
| ^
main.cpp:129:3: error: ‘json’ was not declared in this scope
129 | json j;
| ^~~~
main.cpp:130:15: error: ‘j’ was not declared in this scope
130 | inStream >> j;
| ^
main.cpp:134:8: error: ‘json’ is not a class, namespace, or enumeration
134 | for (json::iterator it = j.begin(); it != j.end(); ++it) {
| ^~~~
main.cpp:134:39: error: ‘it’ was not declared in this scope; did you mean ‘int’?
134 | for (json::iterator it = j.begin(); it != j.end(); ++it) {
| ^~
| int
main.cpp:137:10: error: ‘vector’ is not a member of ‘std’
137 | std::vector<FrElement> v;
| ^~~~~~
main.cpp:6:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
5 | #include "calcwit.hpp"
+++ |+#include <vector>
6 | void Main_0_create(uint soffset,uint coffset,Circom_CalcWit* ctx,std::string componentName,uint componentFather);
main.cpp:137:26: error: expected primary-expression before ‘>’ token
137 | std::vector<FrElement> v;
| ^
main.cpp:137:28: error: ‘v’ was not declared in this scope
137 | std::vector<FrElement> v;
| ^
main.cpp:138:5: error: ‘json2FrElements’ was not declared in this scope
138 | json2FrElements(it.value(),v);
| ^~~~~~~~~~~~~~~
main.cpp:141:21: error: aggregate ‘std::ostringstream errStrStream’ has incomplete type and cannot be defined
141 | std::ostringstream errStrStream;
| ^~~~~~~~~~~~
main.cpp:146:21: error: aggregate ‘std::ostringstream errStrStream’ has incomplete type and cannot be defined
146 | std::ostringstream errStrStream;
| ^~~~~~~~~~~~
main.cpp:155:21: error: aggregate ‘std::ostringstream errStrStream’ has incomplete type and cannot be defined
155 | std::ostringstream errStrStream;
| ^~~~~~~~~~~~
main.cpp: In function ‘int main(int, char**)’:
main.cpp:222:30: error: ‘loadCircuit’ was not declared in this scope
222 | Circom_Circuit *circuit = loadCircuit(datfile);
| ^~~~~~~~~~~
make: *** [Makefile:16: main.o] Error 1
For the above circuit, I am able to generate witness using wasm. But when I try to compile the C++ witness generator for the same, I get the following errors: