Skip to content

Prove *arbitrary length sha256 hashes within Noir circuits

Notifications You must be signed in to change notification settings

alpinevm/dyn-sha256-noir

Repository files navigation

Dynamic SHA256 Verification Noir

Dynamic arrays (slices) are expensive to use when computing SHA256 hashes within Noir.
By using recursive proofs and field encoding, we can design a circuit where the verification cost of a preimage for a given SHA256 hash remains constant, regardless of the preimage's length, up to a specified maximum. For example, with a fixed byte length of ~32k it costs ~430k gates to verify, with the num of gates and thus proving time increasing for larger byte lengths.

Circuit Generation and Demo

  1. Generate sub-circuit verification keys and hashes
    python scripts/generate_circuits.py <chunk_num>

  2. Create hash list
    python scripts/create_hash_list.py > ./example/src/hash_list.nr

  3. Create recursive proofs and test verification
    python scripts/full_demo.py

About

Prove *arbitrary length sha256 hashes within Noir circuits

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published