iden3/circom

Why does generated cpp never use return values

tim-hoffman opened this issue · 0 comments

Instead of using the return value directly, there is a pre-allocated array (passed into the function via a pointer) where the return value is stored. What is the purpose of generating code in this way?

Sample Circom:

function identity(n) {
   return n;
}

Generated cpp:

void identity_2(Circom_CalcWit *ctx, FrElement *lvar, uint componentFather,
                FrElement *destination, int destination_size) {
  FrElement *circuitConstants = ctx->circuitConstants;
  FrElement expaux[1];
  std::string myTemplateName = "identity";
  u64 myId = componentFather;
  // return bucket
  Fr_copy(destination, &lvar[0]);
  return;
}