iden3 / circom_tester

Provides tools for testing circom circuits.
56 stars 28 forks source link

Fix c tester witness file read #3

Closed arnaucube closed 3 years ago

arnaucube commented 3 years ago

c tester (c/tester.js) was using a method to read the witness file called 'readBinaryFile' that was obtaining a wrong number of witness elements, and as consequence was returning a wrong array of witness.

Changed that method to 'readBinWitnessFile', which makes use of wtnsUtils method from snarkjs to read the witness binary file, so now the c tester returns the correct witness.

Context: I was using the c tester with a circuit, and the obtained witness was much shorter than the expected size. It turns out that the witness binary file was correctly stored. But when the c tester was reading it, it was using some logic that didn't match the way how the file was generated, which was resulting in the logic getting a wrong value of 'length' of the witness. And as a result, the returned witness was not the correct one. Updated the code to make it work, but didn't find any test to update.

alrubio commented 3 years ago

Merged! Thanks