O
O1JS SHA256 Hash Function Circuit
This project uses the o1js SDK 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.
Created on 12th November 2023
•
O
O1JS SHA256 Hash Function Circuit
This project uses the o1js SDK 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 problem O1JS SHA256 Hash Function Circuit solves
Using efficient binary hash function inside zk circuits
Challenges I ran into
- The native binary gadgets in O1JS are hard-coded to operate on 64-bit Field elements which made it not practical to develop SHA256 swiftly.
- The rotate, shift, and rangeCheck functions in o1js are not flexible and only operate on 64-bit field elements.
- I tried to simulate the bitwise functions as in sha256 circuit in circomlib but I hadn't enough time to debug and make things work correctly.
- The library is quite rich but I sometimes spend a lot of time trying to find documentation for certain API.
- Working with a DSL used a TS framework made practical and flexible to implement logic and have a development experience similar to normal TS language, but sometimes I feel that I am a bit lost distinguishing circuit logic from the normal TS logic, Other DSL having kind of different language helped me before to have a clearer mental model.
- It would have been better to have a better documentation in general to save time from reading and looking at the source code intensively.
Tracks Applied (2)
O(1)Labs - Crypto Primitive
O(1)Labs
Chewing Glass
Technologies used
Cheer Project
Cheering for a project means supporting a project you like with as little as 0.0025 ETH. Right now, you can Cheer using ETH on Arbitrum, Optimism and Base.
Discussion
Builders also viewed
See more projects on Devfolio