Use starkware/crypto-cpp for starknet verify/pedersen#3
Merged
Conversation
added 8 commits
May 22, 2022 22:07
added 2 commits
May 23, 2022 17:51
utay
commented
May 23, 2022
piedup
approved these changes
May 26, 2022
Collaborator
piedup
left a comment
There was a problem hiding this comment.
Will I be able to install the lib on an M1?
Contributor
Author
@piedup As discussed we should make some tests about compiling the lib on M1/ARM, I'm not sure it will work as-is. starkware-libs/crypto-cpp#4 is open on starkware's repo for this and can certainly help |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Same idea as #2 but using https://github.com/starkware-libs/crypto-cpp which is audited and has existing JS bindings.
Problem
sign/verify/pedersenfunctions are CPU intensive and the current implementation uses https://github.com/indutny/elliptic which is very slow in JS.Solution
Use crypto-cpp for
pedersenandverifyfunctions that are called most of the time in our backend.signis mostly called by client browsers and akvariable has to be computed which isn't trivial (https://github.com/starkware-libs/crypto-cpp/blob/master/src/starkware/crypto/ffi/js/crypto.js#L64-L65) so we decided to skip using it for now.crypto-cpp is audited and hasn't changed since Dec 2021 so I copy/pasted the C++ code directly in this repo. I've made a few changes in CMakeLists.txt and removed presubmit.sh and Go bindings as we don't use them. To review this MR I suggest pulling the code and running
git diff origin/master ':!src/crypto-cpp'to hide crypto-cpp additions.The idea is to keep this library full JS compatible (for browsers especially) but set
USE_STARKWARE_CRYPTO_CPP=trueto make crypto functions use the C++ dynamic library and speed things up.Results ⚡
(on my machine, without C++
sign)Before:
After: