-
Notifications
You must be signed in to change notification settings - Fork 1k
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 sage script for generating scalar_split_lambda constants #852
Add sage script for generating scalar_split_lambda constants #852
Conversation
* Move curve parameters to separate file * Rename main prover script for clarity
I recommend trying Add/replace the BETA and LAMBDA assertions with an assertion that the value is a root of |
7f2238f
to
5b316a8
Compare
I think the current one is more instructive... I don't know, I don't want to spend a lot of time on this. I added root assumptions for BETA and LAMBDA. |
5b316a8
to
0854198
Compare
I'm not really familiar with sage, and I haven't tested this PR, but it is okay by me. |
Another check to add is that (It will also be the case that all the assertions would pass if both LAMBDA and BETA were replaced with LAMBDA^2 and BETA^2, but there is no helping that because that would be a valid, but different, implementation.) |
0854198
to
4e4158e
Compare
I addressed all of your comments. |
sage/gen_split_lambda_constants.sage
Outdated
while True: | ||
if inf_norm(v2) < inf_norm(v1): | ||
v1, v2 = v2, v1 | ||
m = round( (v1[0]*v2[0] + v1[1]*v2[1]) // inf_norm(v1)**2 ) |
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.
No need to round anymore with //
.
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.
Oh, I thought /
vs //
is just a python2 compatibility thing but I think what you had in mind is to avoid floating-point arithmetic. But this changed the semantics.
The correct thing is to round
(to the nearest int) and not floor
(for a reason), so that's why I used /
and round
instead of //
. (It just happens that the output is the same for our specific input.)
So I now changed this to a version which
- rounds to the nearest integer (what the textbooks do TM [1]),
- relies integer arithmetic instead of floating-point arithmetic, and
- should work in Python 2 and Python 3 because it does not use
/
.
[1] https://en.wikipedia.org/wiki/Lattice_reduction#In_two_dimensions Ok not a book but you get the point.
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.
Just saying, you could delete the whole thing and call LLL
where all this has been worked out.
Looks good, ACK 4e4158e |
4e4158e
to
329a2e0
Compare
ACK 329a2e0 CI failure is unrelated. |
…ants Summary: Backport of [[bitcoin-core/secp256k1#852 | secp256k1#852]] Test Plan: sage gen_split_lambda_constants.sage Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D9377
…ants Summary: Backport of [[bitcoin-core/secp256k1#852 | secp256k1#852]] Test Plan: sage gen_split_lambda_constants.sage Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D9377
cc @roconnor-blockstream