o1js SHA - zkHack Nov23

You need to login in order to like this zkApp. Click Here

o1js SHA - zkHack Nov23

You need to login in order to like this zkApp. Click Here

Uses o1js’s newly released bitwise operations gadgets to optimize the SHA256 circuit implementation by operating on the 32-bit words (32 field elements) as a single field element utilizing native binary gadgets. The repository serves as a proof of concept for the development of the SHA256 hashing algorithm using the o1js SDK during ZK-HACK Istanbul. The o1js SDK provides robust native binary functions, facilitating the construction of an efficient SHA2 circuit for zero-knowledge applications on the Mina blockchain. Optimizations: In general, SHA2 circuits face inefficiencies as binaries (0 or 1) consume the space of a complete field element. Performing multiple binary operations on binaries represented as field elements makes the SHA2 algorithm a constraint-heavy circuit. To address this, the o1js SDK aims to optimize the circuit implementation by treating 32-bit words (32 field elements) as a single field element, especially given that SHA256 construction (Merkle–Damgård) operates on 32-bit words. How SHA-256 Works: SHA-2 algorithms can be delineated into two stages: preprocessing and hash computation. During preprocessing, the process involves padding a message, parsing the padded message into m-bit blocks, and establishing initialization values for use in the subsequent hash computation. The hash computation generates a message schedule from the padded message, utilizing this schedule along with functions, constants, and word operations to iteratively produce a series of hash values. The final hash value, derived through the hash computation, determines the message digest. ‘Chewing Glass’ Prize Winner ZK Hack Istanbul Further information here > Github https://github.com/Shigoto-dev19/sha256-o1js