forked from RustCrypto/RSA
-
Notifications
You must be signed in to change notification settings - Fork 0
Use the new RSA extern #2
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Nov 9, 2024
flaub
reviewed
Nov 12, 2024
flaub
reviewed
Nov 12, 2024
src/algorithms/rsa.rs
Outdated
Comment on lines
39
to
48
| let base: [u32; WIDTH_WORDS] = base.chunks(4) | ||
| .map(|word| u32::from_le_bytes(word.try_into().unwrap())) | ||
| .collect::<Vec<u32>>() | ||
| .try_into() | ||
| .unwrap(); | ||
| let modulus: [u32; WIDTH_WORDS] = modulus.chunks(4) | ||
| .map(|word| u32::from_le_bytes(word.try_into().unwrap())) | ||
| .collect::<Vec<u32>>() | ||
| .try_into() | ||
| .unwrap(); |
Member
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.
Suggested change
| let base: [u32; WIDTH_WORDS] = base.chunks(4) | |
| .map(|word| u32::from_le_bytes(word.try_into().unwrap())) | |
| .collect::<Vec<u32>>() | |
| .try_into() | |
| .unwrap(); | |
| let modulus: [u32; WIDTH_WORDS] = modulus.chunks(4) | |
| .map(|word| u32::from_le_bytes(word.try_into().unwrap())) | |
| .collect::<Vec<u32>>() | |
| .try_into() | |
| .unwrap(); | |
| let base = base.to_u32_digits(); | |
| let modulus = modulus.to_u32_digits(); |
Author
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.
to_u32_digits does not exist in num-bigint-dig, it's only in num-bigint
Co-authored-by: Frank Laub <github@frank.laub.io>
tzerrell
added a commit
to risc0/risc0
that referenced
this pull request
Nov 12, 2024
We discovered that the approach used in #2481 was not playing well with linking. This PR redoes the RSA acceleration wrappers to expect outside crates to interact with an `extern "C"` API utilizing pointers to `[u32; WIDTH_WORDS]` rather than pulling in Rust wrapping functions, moving the work of translating bigints into u32 words to the patched crates. Because this moves wrapping code to patched crates, the `bigint-dig-shim` feature was dropped as unused and unnecessary. See also related PRs #2488 and risc0/RustCrypto-RSA#2 which will follow this one --------- Co-authored-by: Frank Laub <flaub@risc0.com>
austinabell
added a commit
that referenced
this pull request
Dec 13, 2024
Use the new RSA extern (#2) --------- Co-authored-by: Frank Laub <github@frank.laub.io> Use risc0-bigint2 (#3) * Use risc0-bigint2 * Use num-bigint-dig feature * Update lockfile * Update ref * Update ref * Update git ref Update bigint2 impl with 4096 bit support (#4) * update acceleration to use latest version of bigint2 (with 4096 bit support) * bump version * bump to 1.2
austinabell
added a commit
that referenced
this pull request
Dec 13, 2024
* Add Zirgen-based acceleration (#1) Use the new RSA extern (#2) --------- Co-authored-by: Frank Laub <github@frank.laub.io> Use risc0-bigint2 (#3) * Use risc0-bigint2 * Use num-bigint-dig feature * Update lockfile * Update ref * Update ref * Update git ref Update bigint2 impl with 4096 bit support (#4) * update acceleration to use latest version of bigint2 (with 4096 bit support) * bump version * bump to 1.2 * gate prop tests behind cfg to enable cargo risczero test
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make the necessary updates to use the new RSA extern from risc0/risc0#2487
There's a bit of a sharp edge, where the guest crate call this needs to be sure to depend on
risc0-circuit-bigintand to make a call directly to. We should either document or fix this sharp edge.modpow_65537from thersamodule of that crate (even if only in a dead code function that's never used) so the linker doesn't optimize it away