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.

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

The SHA256 implementation using the O1JS SDK will help pave the way to the use of more cryptographic schemes and protoco...Read More

O(1)Labs

Chewing Glass

I tried to use a complex and important cryptographic primitive using a new SDK. O1JS is good and I can see it refined mo...Read More

Discussion