Open vvc-git opened 3 months ago
@vvc-git had exact problem solved it by recognizing sha256.circom works on bit array
convert date to binary array, in typescript following will do
function buffer2bitArray(b: string | any[]) { const res = []; for (let i=0; i<b.length; i++) { for (let j=0; j<8; j++) { res.push((b[i] >> (7-j) &1)); } } return res; } put date in and get bit array out
put array bit in input.json for witness
{ "in":[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] }
simplify circuit a bit
pragma circom 2.0.0; include "../../node_modules/circomlib/circuits/sha256/sha256.circom";
component main = Sha256(48);
recompile circuit, rebuild proof
this is also useful is where I got idea from (test suite for circuit)
https://github.com/iden3/circomlib/blob/master/test/sha256.js
While practicing my first snarkjs exercises, I aimed to verify if the proof I possess regarding the pre-image hash of a person's birth date aligns with the hash of this specific date. My approach involved comparing the contents of the 'public.json' file with the hash I computed in Python. However, the values do not match. Could I be making a mistake in my approach? Is it accurate to assume that the computed hash should also be present in the 'public.json' file?
circom circuit
Python code
input.json
public.json