-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new hashing functions (SHA & Keccak) #999
Conversation
… to the Snarky type definition file to support SHA hashing and conversion from hex to field bytes.
…ccak256 hash functions
…on, default and Keccack256
…nstead of a Field array
… to UInt8 array using Snarky.sha library
…ray of UInt8 to a hex string
…ersion for SHA224, SHA256, SHA384, SHA512, and Keccack256 hash functions. Add helper functions to check the conversion and compare the digests.
…thods to UInt8 class for better usability and serialization
Co-authored-by: jackryanservia <[email protected]>
Co-authored-by: jackryanservia <[email protected]>
Co-authored-by: jackryanservia <[email protected]>
Co-authored-by: jackryanservia <[email protected]>
Co-authored-by: jackryanservia <[email protected]>
Co-authored-by: jackryanservia <[email protected]>
Co-authored-by: jackryanservia <[email protected]>
new bindings: o1-labs/o1js-bindings#220 |
Another idea for |
@@ -2150,4 +2137,897 @@ describe('int', () => { | |||
}); | |||
}); | |||
}); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one day i will refactor this file to save us 3k of lines :D
@@ -525,6 +525,7 @@ declare const Snarky: { | |||
}; | |||
}; | |||
|
|||
// TODO: implement in TS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be fun 👀
Description
Implements o1-labs/rfcs#9
This PR adds support for hashing using various SHA algorithms and Keccak. The OCaml bindings expose the base functionality, which calls into Kimchi.
To see example usage, see the following tests:
Unit tests: https://github.com/o1-labs/snarkyjs/pull/999/files#diff-772a0ee5ba611c22e73c36051c7139a50869713a53c357d2f6abb49abfbfa497
Integration test: https://github.com/o1-labs/snarkyjs/pull/999/files#diff-1f506bf5891efbbfba747df80700012d212be51e402f9f406e21155992858664
Note: Hashing only works for Field variables. No hashing is implemented for constant fields, which can lead to errors if users try to hash outside of a provable method. We can add a lightweight JS dependency that implements SHA/Keccak hashing and convert our constant Field values into something the JS dependency expects.
Currently waiting on 🔗 MinaProtocol/mina#12524 to be merged for proving to be enabled.
🔗 Bindings o1-labs/o1js-bindings#53