Skip to content

Instantly share code, notes, and snippets.

@vivianjeng
Created March 7, 2024 09:29
Show Gist options
  • Save vivianjeng/cffb387d63ad3735414960369ee29fc8 to your computer and use it in GitHub Desktop.
Save vivianjeng/cffb387d63ad3735414960369ee29fc8 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <iostream>
#include <assert.h>
#include "circom.hpp"
#include "calcwit.hpp"
void IsZero_0_create(uint soffset,uint coffset,Circom_CalcWit* ctx,std::string componentName,uint componentFather);
void IsZero_0_run(uint ctx_index,Circom_CalcWit* ctx);
Circom_TemplateFunction _functionTable[1] = {
IsZero_0_run };
Circom_TemplateFunction _functionTableParallel[1] = {
NULL };
uint get_main_input_signal_start() {return 2;}
uint get_main_input_signal_no() {return 1;}
uint get_total_signal_no() {return 5;}
uint get_number_of_components() {return 1;}
uint get_size_of_input_hashmap() {return 256;}
uint get_size_of_witness() {return 4;}
uint get_size_of_constants() {return 2;}
uint get_size_of_io_map() {return 0;}
void release_memory_component(Circom_CalcWit* ctx, uint pos) {{
if (pos != 0){{
if(ctx->componentMemory[pos].subcomponents)
delete []ctx->componentMemory[pos].subcomponents;
if(ctx->componentMemory[pos].subcomponentsParallel)
delete []ctx->componentMemory[pos].subcomponentsParallel;
if(ctx->componentMemory[pos].outputIsSet)
delete []ctx->componentMemory[pos].outputIsSet;
if(ctx->componentMemory[pos].mutexes)
delete []ctx->componentMemory[pos].mutexes;
if(ctx->componentMemory[pos].cvs)
delete []ctx->componentMemory[pos].cvs;
if(ctx->componentMemory[pos].sbct)
delete []ctx->componentMemory[pos].sbct;
}}
}}
// function declarations
// template declarations
void IsZero_0_create(uint soffset,uint coffset,Circom_CalcWit* ctx,std::string componentName,uint componentFather){
ctx->componentMemory[coffset].templateId = 0;
ctx->componentMemory[coffset].templateName = "IsZero";
ctx->componentMemory[coffset].signalStart = soffset;
ctx->componentMemory[coffset].inputCounter = 1;
ctx->componentMemory[coffset].componentName = componentName;
ctx->componentMemory[coffset].idFather = componentFather;
ctx->componentMemory[coffset].subcomponents = new uint[0];
}
void IsZero_0_run(uint ctx_index,Circom_CalcWit* ctx){
FrElement* signalValues = ctx->signalValues;
u64 mySignalStart = ctx->componentMemory[ctx_index].signalStart;
std::string myTemplateName = ctx->componentMemory[ctx_index].templateName;
std::string myComponentName = ctx->componentMemory[ctx_index].componentName;
u64 myFather = ctx->componentMemory[ctx_index].idFather;
u64 myId = ctx_index;
u32* mySubcomponents = ctx->componentMemory[ctx_index].subcomponents;
bool* mySubcomponentsParallel = ctx->componentMemory[ctx_index].subcomponentsParallel;
FrElement* circuitConstants = ctx->circuitConstants;
std::string* listOfTemplateMessages = ctx->listOfTemplateMessages;
FrElement expaux[4];
FrElement lvar[0];
uint sub_component_aux;
uint index_multiple_eq;
{
PFrElement aux_dest = &signalValues[mySignalStart + 3];
// load src
Fr_sub(&expaux[0],&circuitConstants[0],&signalValues[mySignalStart + 1]); // line circom 29
// end load src
Fr_copy(aux_dest,&expaux[0]);
}
Fr_neq(&expaux[0],&signalValues[mySignalStart + 1],&circuitConstants[0]); // line circom 31
if(Fr_isTrue(&expaux[0])){
{
PFrElement aux_dest = &signalValues[mySignalStart + 2];
// load src
Fr_div(&expaux[0],&circuitConstants[1],&signalValues[mySignalStart + 1]); // line circom 31
// end load src
Fr_copy(aux_dest,&expaux[0]);
}
}else{
{
PFrElement aux_dest = &signalValues[mySignalStart + 2];
// load src
// end load src
Fr_copy(aux_dest,&circuitConstants[0]);
}
}
{
PFrElement aux_dest = &signalValues[mySignalStart + 0];
// load src
Fr_mul(&expaux[1],&signalValues[mySignalStart + 3],&signalValues[mySignalStart + 2]); // line circom 33
Fr_add(&expaux[0],&expaux[1],&circuitConstants[1]); // line circom 33
// end load src
Fr_copy(aux_dest,&expaux[0]);
}
Fr_mul(&expaux[1],&signalValues[mySignalStart + 1],&signalValues[mySignalStart + 0]); // line circom 34
Fr_eq(&expaux[0],&expaux[1],&circuitConstants[0]); // line circom 34
if (!Fr_isTrue(&expaux[0])) std::cout << "Failed assert in template/function " << myTemplateName << " line 34. " << "Followed trace of components: " << ctx->getTrace(myId) << std::endl;
assert(Fr_isTrue(&expaux[0]));
for (uint i = 0; i < 0; i++){
uint index_subc = ctx->componentMemory[ctx_index].subcomponents[i];
if (index_subc != 0)release_memory_component(ctx,index_subc);
}
}
void run(Circom_CalcWit* ctx){
IsZero_0_create(1,0,ctx,"main",0);
IsZero_0_run(0,ctx);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment