Skip to content

Add signature functionality to RSA#24

Merged
LordofGhost merged 3 commits into
mainfrom
feature/signature
Jul 12, 2026
Merged

Add signature functionality to RSA#24
LordofGhost merged 3 commits into
mainfrom
feature/signature

Conversation

@LordofGhost

Copy link
Copy Markdown
Member

Describe your changes

Add signature functionality to RSA

Issue ticket number if there is one

Copilot AI review requested due to automatic review settings July 12, 2026 17:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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::signDigest and core::signature::verifyDigest APIs.
  • Adds unit tests validating signature verification success/failure scenarios.
  • Registers signature.cpp in 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 thread src/signature.cpp Outdated
Comment on lines +9 to +12
[[nodiscard]] operations::BigInt digestToInteger(
const std::vector<std::uint8_t>& digest) {
return operations::BigInt(bytesToByteArray(digest));
}
Comment thread src/signature.h Outdated
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 thread tests/test_rsa.cpp
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));
}
Comment thread src/signature.cpp
namespace core::signature {
namespace {

[[nodiscard]] operations::BigInt digestToInteger(const std::vector<std::uint8_t>& digest) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this helper necessary? Isn't this just a wrapper for a helper class?

@LordofGhost LordofGhost merged commit 0350bb7 into main Jul 12, 2026
7 checks passed
@LordofGhost LordofGhost deleted the feature/signature branch July 12, 2026 18:02
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.

3 participants