Skip to content
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

arithmetic internals: Clarify memory safety of calls to bn_mul_mont. #2252

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

briansmith
Copy link
Owner

Replace debug_asesrt!-based checking with proper error checking. The error cases will never be reached because the callers already ensured that the slices are the correct lengths, but this is more clearly correct.

The previous step defining the InOut type didn't work out so well, so replace InOut with AliasingSlices that does the same thing. The cost is more monomorphization, but that will become moot soon, and it already isn't too bad since there are only three cases to consider. It does help reduce the number of length checks that end up getting generated.

@briansmith briansmith self-assigned this Jan 19, 2025
Replace `debug_asesrt!`-based checking with proper error checking. The
error cases will never be reached because the callers already ensured
that the slices are the correct lengths, but this is more clearly
correct.

The previous step defining the `InOut` type didn't work out so well,
so replace `InOut` with `AliasingSlices` that does the same thing. The
cost is more monomorphization, but that will become moot soon, and it
already isn't too bad since there are only three cases to consider.
It does help reduce the number of length checks that end up getting
generated.
@briansmith briansmith force-pushed the b/bn_mul_mont-conversion branch from aac8f1e to d4cc88d Compare January 19, 2025 23:49
Copy link

codecov bot commented Jan 19, 2025

Codecov Report

Attention: Patch coverage is 81.25000% with 21 lines in your changes missing coverage. Please review.

Project coverage is 96.81%. Comparing base (18495f7) to head (d4cc88d).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/arithmetic/inout.rs 71.42% 6 Missing and 6 partials ⚠️
src/arithmetic/bigint.rs 76.19% 5 Missing ⚠️
src/arithmetic/ffi.rs 87.87% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2252      +/-   ##
==========================================
- Coverage   96.91%   96.81%   -0.10%     
==========================================
  Files         166      168       +2     
  Lines       20651    20720      +69     
  Branches      475      483       +8     
==========================================
+ Hits        20013    20061      +48     
- Misses        541      554      +13     
- Partials       97      105       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@briansmith briansmith merged commit b794f56 into main Jan 20, 2025
167 of 169 checks passed
@briansmith briansmith deleted the b/bn_mul_mont-conversion branch January 20, 2025 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant