-
Hi, I'm trying to read public fields in a Public Witness, but I couldn't find much documentation on this and #941 wasn't clear enough. I see that Vector() returns a Public Witness' underlying fr.Vector,
However I am unable to access a specific field like this: Consider that my circuit looks like this:
After reading #941, I am assuming that the most efficient way to read public fields for comparison-purposes is by recreating another Public_Witness_2 with the known values (i.e. ImgBytes in above circuit), and once we are able to access the specific fields from the Vector, we can then compare the known fields with public fields in the Public_Witness_1. Thanks in advance for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I figured it out! When we run public_witness.MarshallBinary(), we get the public witness's binary representation of all its public values. MarshallBinary() only returns binaries associated with public values, so the known values and recreated witness are sufficient to compare with the public values in the public witness. Here's my comparison function:
Once I realized this, I wondered if I could just use the recreated witness (with the known values) to run groth16.Verify(), and it worked! So you don't even need to compare witnesses, just use the recreated witness with the groth16.Proof and groth16.VerifyingKey to verify if your known values are valid. |
Beta Was this translation helpful? Give feedback.
I figured it out!
When we run public_witness.MarshallBinary(), we get the public witness's binary representation of all its public values. MarshallBinary() only returns binaries associated with public values, so the known values and recreated witness are sufficient to compare with the public values in the public witness.
Here's my comparison function:
Once I realized this, I wondered if I could just use the recre…