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

NFC: Move low-level Montgomery arithmetic out of bigint. #1652

Merged
merged 1 commit into from
Sep 27, 2023

Conversation

briansmith
Copy link
Owner

@briansmith briansmith commented Sep 26, 2023

When the alloc feature is disabled, on lesser-used targets we don't build bigint but we still need some of the Montgomery arithmetic.

git diff \
   HEAD^1:src/arithmetic/bigint/bn_mul_mont_fallback.rs \
   src/arithmetic/montgomery.rs
git diff \
   HEAD^1:src/arithmetic/bigint.rs \
   src/arithmetic/montgomery.rs

@briansmith briansmith self-assigned this Sep 26, 2023
@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

Merging #1652 (ee24519) into main (b04bed1) will decrease coverage by 0.02%.
The diff coverage is 97.43%.

@@            Coverage Diff             @@
##             main    #1652      +/-   ##
==========================================
- Coverage   92.10%   92.09%   -0.02%     
==========================================
  Files         132      132              
  Lines       18869    18869              
  Branches      196      196              
==========================================
- Hits        17379    17377       -2     
- Misses       1453     1455       +2     
  Partials       37       37              
Files Coverage Δ
src/arithmetic/bigint.rs 99.31% <100.00%> (+0.09%) ⬆️
src/arithmetic/bigint/modulus.rs 99.35% <100.00%> (ø)
src/arithmetic/n0.rs 100.00% <100.00%> (ø)
src/arithmetic/montgomery.rs 87.50% <97.22%> (+87.50%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@briansmith
Copy link
Owner Author

@uweigand @erickt Could you please try this PR to see if it fixes the --no-default-features build problem for you? The two git diff commands in the summary can be used (probably git difftool is better) to verify that the actual code that was moved is not changed.

@briansmith
Copy link
Owner Author

I just pushed a new version to fix the #[cfg(...)] logic.

@briansmith briansmith force-pushed the b/move-bn_mul_mont branch 2 times, most recently from fc59e1e to 1f4998d Compare September 26, 2023 23:28
// Nothing aliases `n`
let n = unsafe { core::slice::from_raw_parts(n, num_limbs) };

let mut tmp = [0; 2 * MODULUS_MAX_LIMBS];
Copy link
Contributor

@erichte-ibm erichte-ibm Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be BIGINT_MODULUS_MAX_LIMBS, with this tweak it successfully builds and passes tests with --no-default-features for powerpc64le-unknown-linux-gnu.

When the `alloc` feature is disabled, on lesser-used targets we don't
build `bigint` but we still need some of the Montgomery arithmetic.

```
 git diff \
    HEAD^1:src/arithmetic/bigint/bn_mul_mont_fallback.rs \
    src/arithmetic/montgomery.rs
```

```
 git diff \
    HEAD^1:src/arithmetic/bigint.rs \
    src/arithmetic/montgomery.rs
```
@briansmith briansmith merged commit f9378e8 into main Sep 27, 2023
266 of 267 checks passed
@briansmith briansmith deleted the b/move-bn_mul_mont branch September 27, 2023 00:46
@erickt
Copy link
Contributor

erickt commented Sep 27, 2023

@briansmith - I don't remember having an issue with --no-default-features, but it's been a while since I looked into how ring integrates with the fuchsia build system. Did you mean to ping someone else?

In the meantime, I'll ask around with the other fuchsia people in case they remember something.

@briansmith
Copy link
Owner Author

@erickt Sorry, it was a typo. I meant to ping erichte-ibm.

@uweigand
Copy link
Contributor

@uweigand @erickt Could you please try this PR to see if it fixes the --no-default-features build problem for you?

Yes, it does. Thanks!

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.

4 participants