-
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
Extra validation on top of #73 #103
Conversation
- interleave calculation of the lower and upper partial product ranges, and reduction - less registers needed, more opportunities for parallel ops
@gmaxwell Can you do frama-c analysis on the 32-bit version? |
Using the same preconditions as before (the code doesn't have dynamic checks yet), I get: S_r[0..1] ∈ [0..67108863] for secp256k1_fe_mul_inner and S_r[0..1] ∈ [0..67108863] secp256k1_fe_sqr_inner And no overflows. Can you add the dynamic checks too? After all, frame-c only proves it correct. :P At least of the input values, since those are axiomatic to this analysis. |
@peterdettman still seems to be around 4% slower when compiled with CFLAGS="-O2 -m32" --enable-endomorphism --with-field=32bit than the original version. The 64bit version is very significantly faster. |
With CFLAGS="-O3 -march=native -m32" --enable-endomorphism it's faster, and the decrease with -O2 isn't so bad, and I like having code with somewhat better assurances for correctness than we had. |
@gmaxwell Added. Can you get frama-c to also check those VERIFY_BITS assertions? Note that I needed a few more accurate limits in the 32-bit version (checked with a VERIFY_CHECK). |
Yep, line numbers don't match because I restated them as the ACSL assertions, but they all pass. For the multiply inner: |
And for the sqr: aqq.c:49:[value] Assertion got status valid. |
ACK. @sipa perhaps diff the ASM your compiler generates for O3 vs O2 and see if you can see some obvious difference that could be triggered from the source? |
VERIFY_BITS(u0, 56); | ||
// [d 0 t4+(u0<<48) t3 0 0 c] = [p8 0 0 p5 p4 p3 0 0 p0] | ||
c += (__int128)u0 * (R >> 4); | ||
VERIFY_BITS(c, 115); |
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.
ought to be VERIFY_BITS(c, 113);
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.
Can you open an issue (or submit a PR to fix it)?
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 description provided.