-
Notifications
You must be signed in to change notification settings - Fork 143
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
issue when implementing sha256 #328
Comments
Amazing that you got this far! Will check it out on monday |
By the way, you get more useful error traces with |
I think this may be because I implemented the not operation on Uint32, and the inversion of 1 becomes -2. Because sha256 needs to use xor and not. Please help to see if there is a problem with the implementation of these two functions, and if there is a better way to implement it |
all strace:
|
A version with simpler code implementation has just been submitted, which removes the for loop. but still has pb |
Another possibility is that my circuit is triggering some limitation of the system |
any update? |
a minimal reproducible example : sCrypt-Inc/snarkyjs-sha256@33f89d1 it just crashed when calling If you comment the following line of code, https://github.com/sCrypt-Inc/snarkyjs-sha256/blob/master/src/sha256.ts#L121 |
Update: discussion on this was continued on discord. The issue turned out to be a limitation on circuit size, uncovered by this error message from kimchi:
To uncover this error in snarkyjs, we needed to improve the stack trace, by printing error messages from Rust in the JS console: MinaProtocol/mina#11644 |
Our sha256 is finally working, thanks to your help! It has 58830 constraints. Unfortunately, we need double sha256, and it exceeded constraint limits of 2^16=65536. Any way to bump the limit or alternative to get around this limit? |
Unfortunately, bumping up the constraint limit is not as simple as changing a hardcoded number somewhere in SnarkyJS, but you could use recursion! :) Try proving the first SHA-256 evaluation, then verifying that proof inside the proof where you do the second evaluation. |
Hmm, 58k constraints is just for hashing one chunk. And a bitcoin transaction is at least 5 chunks (250 bytes: 1 input & 2 outputs). On top of that, we need to double hashing. A second recursion is gonna be very difficult, we need to break it into 5 smaller steps (5 chunks + second hashing) to fit in 2^16 constraint limit. |
closing, sha256 is now natively avaiable in o1js with roughly 5000 constrains per block hash |
i am implementing sha256:
now I have a version that validates normally
sCrypt-Inc/snarkyjs-sha256@bd52bdd
But if we make a simple modification and comment out lines 254~257, that is, run one more line of code 259, the whole circuit will crash.
see this commit :
sCrypt-Inc/snarkyjs-sha256@fcaefcc
The text was updated successfully, but these errors were encountered: