-
Notifications
You must be signed in to change notification settings - Fork 6
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
Use starkware/crypto-cpp for starknet verify/pedersen #3
Conversation
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.
Will I be able to install the lib on an M1?
@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 |
Same idea as #2 but using https://github.com/starkware-libs/crypto-cpp which is audited and has existing JS bindings.
Problem
sign
/verify
/pedersen
functions are CPU intensive and the current implementation uses https://github.com/indutny/elliptic which is very slow in JS.Solution
Use crypto-cpp for
pedersen
andverify
functions that are called most of the time in our backend.sign
is mostly called by client browsers and ak
variable 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=true
to make crypto functions use the C++ dynamic library and speed things up.Results ⚡
(on my machine, without C++
sign
)Before:
After: