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

feat: add support for public exponent 3 #8

Merged
merged 2 commits into from
Sep 12, 2024
Merged

Conversation

madztheo
Copy link
Contributor

@madztheo madztheo commented Sep 4, 2024

Description

The PKCS#1 v1.5 signature verification in the library was done assuming the exponent used for the public key is 65537. While this is the most widely used exponent, the exponent 3 is also in use, notably in some electronic passports. So this PR aims to add the support for this exponent in addition to 65537.

Problem*

Unability to verify signature using 3 as public exponent.

Summary*

The function verify_sha256_pkcs1v15 now takes in a new argument to specify the exponent. The exponent can be either 65537 or 3 if any other number the verification will fail straight away.

pub fn verify_sha256_pkcs1v15(_: Self, instance: BNInstance, msg_hash: [u8; 32], sig: BN, exponent: u32) -> bool

A test case was also added for a 2048-bit RSA signature using 3 as a public exponent.

The signature gen Rust script also takes in an exponent argument (defaulting to 65537) to generate a sample signature with a custom exponent.

Additional Context

The public exponent 3 is required to verify the signatures of some passports.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

Copy link

@michaeljklein michaeljklein left a comment

Choose a reason for hiding this comment

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

LGTM

@vezenovm vezenovm merged commit 882fcc5 into noir-lang:main Sep 12, 2024
2 of 3 checks passed
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