Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

add header to witness bin #51

Open
wants to merge 1 commit into
base: c_build
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions c/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ void writeOutBin(Circom_CalcWit *ctx, std::string filename) {

write_ptr = fopen(filename.c_str(),"wb");

// Add header
// 4 bytes --> total number of constraints
uint32_t witnessLength = _circuit.NVars;
// 4 bytes --> witness element size (measured in number of 32bit words)
uint32_t witnessSize = 8; // witness size = 8*32 = 256 bits
// 8bytes --> empty
uint64_t otherField = 0;

fwrite(&witnessLength, 4, 1, write_ptr);
fwrite(&witnessSize, 4, 1, write_ptr);
fwrite(&otherField, 8, 1, write_ptr);

FrElement v;

u8 buffOut[256];
Expand Down