-
Notifications
You must be signed in to change notification settings - Fork 486
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
batch verification: add ed25519 batch verification implementation #3031
batch verification: add ed25519 batch verification implementation #3031
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3031 +/- ##
==========================================
+ Coverage 47.57% 47.60% +0.02%
==========================================
Files 370 370
Lines 60060 60109 +49
==========================================
+ Hits 28572 28612 +40
- Misses 28178 28186 +8
- Partials 3310 3311 +1
Continue to review full report at Codecov.
|
crypto/libsodium-fork/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c
Show resolved
Hide resolved
crypto/libsodium-fork/src/libsodium/crypto_sign/ed25519/ref10/batch.c
Outdated
Show resolved
Hide resolved
crypto/libsodium-fork/src/libsodium/crypto_sign/ed25519/ref10/batch.c
Outdated
Show resolved
Hide resolved
crypto/libsodium-fork/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c
Outdated
Show resolved
Hide resolved
crypto/libsodium-fork/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c
Outdated
Show resolved
Hide resolved
crypto/libsodium-fork/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c
Show resolved
Hide resolved
I tried running |
0d714f2
to
8a7a4e3
Compare
it looks like the batch verification interface uses unsigned long long *. |
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.
generally LGTM, with some questions & suggestions for changes
crypto/libsodium-fork/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10_sc.c
Outdated
Show resolved
Hide resolved
crypto/libsodium-fork/src/libsodium/crypto_sign/ed25519/ref10/open.c
Outdated
Show resolved
Hide resolved
crypto/libsodium-fork/src/libsodium/crypto_sign/ed25519/ref10/batch.c
Outdated
Show resolved
Hide resolved
b4c8f30
to
c1c0b76
Compare
crypto/libsodium-fork/src/libsodium/crypto_sign/ed25519/ref10/batch.c
Outdated
Show resolved
Hide resolved
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.
it looks like the batch verification interface uses unsigned long long *. @cce @tsachiherman, do you think we should change it to size_t?
It looks like they use unsigned long long for message lengths throughout most of the libsodium API (and size_t for some memory limits and some hashing APIs) so LGTM to keep mlen as unsigned long long to match the rest of the crypto_sign API.
Also, I noticed it should be const unsigned long long *
to match the strict const usage in the exported API functions for input args, submitted suggested changes
crypto/libsodium-fork/src/libsodium/crypto_sign/ed25519/ref10/sign_ed25519_ref10.h
Outdated
Show resolved
Hide resolved
crypto/libsodium-fork/src/libsodium/include/sodium/crypto_sign.h
Outdated
Show resolved
Hide resolved
crypto/libsodium-fork/src/libsodium/include/sodium/crypto_sign.h
Outdated
Show resolved
Hide resolved
crypto/libsodium-fork/src/libsodium/crypto_sign/ed25519/ref10/sign_ed25519_ref10.h
Outdated
Show resolved
Hide resolved
c1c0b76
to
a70c996
Compare
…nt.iacr.org/2020/1244.pdf. we now reject non canonical R and accept signatures with a mixed group order (in order to impl a batch verification)
… and use it in the batch verification
… result to one of the small order points.
Would it be addressed with the UINT64_C macro? |
could be.. x86 is using little endian, arm is using big endian. |
ARM is little endian too ... we would need to use qemu or something to run on big endian |
@algoidan you also have the U8TO64_LE macro you introduced elsewhere that converts from 8 unsigned chars to uint64 |
96e5029
to
a449a4b
Compare
a449a4b
to
1ba1843
Compare
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.
looks good to me.
Summary The ed25519 batch verification implementation in #3031 provides a performance improvement for validating multiple signatures (such as multiple transaction signatures). Since each OneTimeSignature used by agreement votes is actually 3 ed25519 signatures, this hooks up the verifier to the batch verification implementation, yielding a ~12% performance improvement in the included benchmark on my computer. Test Plan Added benchmark, existing tests should pass.
…rand#3759) Summary The ed25519 batch verification implementation in algorand#3031 provides a performance improvement for validating multiple signatures (such as multiple transaction signatures). Since each OneTimeSignature used by agreement votes is actually 3 ed25519 signatures, this hooks up the verifier to the batch verification implementation, yielding a ~12% performance improvement in the included benchmark on my computer. Test Plan Added benchmark, existing tests should pass.
Summary
In this change, we plan to integrate the ed25519 batch verification algorithm. This will speed up the process of verifying the digital signature of several transactions by roughly 2.4X.
This PR implements the algorithm according to the following paper:
https://eprint.iacr.org/2020/1244.pdf
This PR fixes a bug in the paper (Listing 1.2) that didn't reject the points (-0,-1) and (-0,1)
Another blog article with similar background: https://hdevalence.ca/blog/2020-10-04-its-25519am
Changes Overview
Changes made on the single ed255519 verification :
Add the batch verification implementation from https://github.com/floodyberry/ed25519-donna to our fork of libsodium.
Changes made on the batch verification (to match the single verification):
Test Plan
The following tests were added to the libsodium's test suite.