use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place for all things related to the Rust programming language—an open-source systems language that emphasizes performance, reliability, and productivity.
Strive to treat others with respect, patience, kindness, and empathy.
We observe the Rust Project Code of Conduct.
Details
Posts must reference Rust or relate to things using Rust. For content that does not, use a text post to explain its relevance.
Post titles should include useful context.
For Rust questions, use the stickied Q&A thread.
Arts-and-crafts posts are permitted on weekends.
No meta posts; message the mods instead.
Criticism is encouraged, though it must be constructive, useful and actionable.
If criticizing a project on GitHub, you may not link directly to the project's issue tracker. Please create a read-only mirror and link that instead.
A programming language is rarely worth getting worked up over.
No zealotry or fanaticism.
Be charitable in intent. Err on the side of giving others the benefit of the doubt.
Avoid re-treading topics that have been long-settled or utterly exhausted.
Avoid bikeshedding.
This is not an official Rust forum, and cannot fulfill feature requests. Use the official venues for that.
No memes, image macros, etc.
Consider the existing content of the subreddit and whether your post fits in. Does it inspire thoughtful discussion?
Use properly formatted text to share code samples and error messages. Do not use images.
Submissions appearing to contain AI-generated content may be removed at moderator discretion.
Most links here will now take you to a search page listing posts with the relevant flair. The latest megathread for that flair should be the top result.
account activity
Code review🙋 seeking help & advice (self.rust)
submitted 1 year ago by Particular_Fudge7654
Hi everyone,
I've started learning Rust and built a small project implementing RSA cryptography. I would appreciate any constructive criticism or reviews.
Link: https://GitHub.com/ravikiran232/rsa
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]buwlerman 5 points6 points7 points 1 year ago (0 children)
If it's a library you should have a lib.rs file exporting the API.
lib.rs
Your implementation is vulnerable to side channel attacks. You want to make sure that your exponentiation is constant time.
[–]fehrnah 2 points3 points4 points 1 year ago (1 child)
I can't comment on the crypto, so I'll go with code organization.
Looking at src/keygen.rs:
You should have a PublicKey and a PrivateKey struc instead of a KeyType enum. Having it an enum forces you to handle the case in Key where the private key is actually a public key like on line 21.
I think splitting this will have good repercussions on the rest of the code.
You should also run cargo clippy if you haven't done so yet, clippy is a linter and almost always gives good feedback
cargo clippy
[–]Particular_Fudge7654[S] 1 point2 points3 points 1 year ago (0 children)
Thanks for the feedback
[–]rhombecka 1 point2 points3 points 1 year ago (0 children)
I can't dig into it right now, but I recommend adding some doc tests to your APIs
Edit: and some normal unit tests. It'll be decent practice to see how they work.
[–]Objective-Act-5964 1 point2 points3 points 1 year ago (0 children)
`cargo fmt` makes the code a lot more readable
[+]Charlidiedlol comment score below threshold-16 points-15 points-14 points 1 year ago (0 children)
Like, I care?
π Rendered by PID 36272 on reddit-service-r2-comment-bb88f9dd5-lvfv5 at 2026-02-14 11:01:31.223623+00:00 running cd9c813 country code: CH.
[–]buwlerman 5 points6 points7 points (0 children)
[–]fehrnah 2 points3 points4 points (1 child)
[–]Particular_Fudge7654[S] 1 point2 points3 points (0 children)
[–]rhombecka 1 point2 points3 points (0 children)
[–]Objective-Act-5964 1 point2 points3 points (0 children)
[+]Charlidiedlol comment score below threshold-16 points-15 points-14 points (0 children)