Add signature functionality to RSA#24
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds RSA “digest signature” functionality to the library, enabling signing a provided digest with a private key and verifying it with the corresponding public key.
Changes:
- Introduces
core::signature::signDigestandcore::signature::verifyDigestAPIs. - Adds unit tests validating signature verification success/failure scenarios.
- Registers
signature.cppin the RSA library build.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/test_rsa.cpp | Adds signature-focused test coverage (valid signature + negative cases). |
| src/signature.h | Declares the new signature API. |
| src/signature.cpp | Implements digest signing/verification using RSA modular exponentiation. |
| src/CMakeLists.txt | Adds signature.cpp to the RSA target sources. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+9
to
+12
| [[nodiscard]] operations::BigInt digestToInteger( | ||
| const std::vector<std::uint8_t>& digest) { | ||
| return operations::BigInt(bytesToByteArray(digest)); | ||
| } |
Comment on lines
+9
to
+13
| namespace core::signature { | ||
|
|
||
| [[nodiscard]] std::vector<std::uint8_t> signDigest( | ||
| const PrivateKey& privateKey, | ||
| const std::vector<std::uint8_t>& digest); |
Comment on lines
+148
to
+153
| SECTION("A modified digest does not verify the signature") { | ||
| auto modifiedDigest = digest; | ||
| modifiedDigest.front() ^= 0x01; | ||
| REQUIRE_FALSE(core::signature::verifyDigest( | ||
| pairA.getPublicKey(), modifiedDigest, signature)); | ||
| } |
Jochengehtab
approved these changes
Jul 12, 2026
| namespace core::signature { | ||
| namespace { | ||
|
|
||
| [[nodiscard]] operations::BigInt digestToInteger(const std::vector<std::uint8_t>& digest) { |
Member
There was a problem hiding this comment.
Why is this helper necessary? Isn't this just a wrapper for a helper class?
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
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.
Describe your changes
Add signature functionality to RSA
Issue ticket number if there is one