Skip to content

jonas089/circom-sha256

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prove a SHA256 Hash in Circom

Prove a SHA256 hash computation in circom zk learn more

Draft article

Latest draft

Prerequisites

  1. install circom
  2. study the circom getting started
  3. add circom lib to the working dir

Verify the proof

cd ./ptau
./verify.sh

The circuit

pragma circom 2.0.0;
include "./circomlib/circuits/sha256/sha256.circom";
template Birthday(){
  component SHA = Sha256(16);
  signal input d[16];
  SHA.in <== d;

  signal output d_out[256];
  d_out <== SHA.out;
}

component main = Birthday();

Recompile and reproduce

  1. compile:
circom bday.circom --r1cs --wasm --sym --c
  1. compute the witness:
cd ./bday_js
node generate_witness.js bday.wasm ../input.json witness.wtns
  1. Powersoftau
cd ./ptau
snarkjs groth16 setup ../bday.r1cs powersOfTau28_hez_final_15.ptau bday_0000.zkey

Contribute to the ceremony

snarkjs zkey contribute bday_0000.zkey bday_0001.zkey --name="1st Contributor Name" -v
snarkjs zkey export verificationkey bday_0001.zkey verification_key.json
  1. Generate a proof
snarkjs groth16 prove bday_0001.zkey ../bday_js/witness.wtns proof.json public.json
  1. Verify the proof
snarkjs groth16 verify verification_key.json public.json proof.json

Releases

No releases published

Packages

No packages published

Languages