Skip to content

Commit

Permalink
tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
iAmMichaelConnor committed Nov 6, 2024
1 parent 974eb7a commit 6b9588e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
7 changes: 2 additions & 5 deletions example/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use dep::bignum::params::BigNumParams;
use dep::bignum::RuntimeBigNum;

use dep::rsa::rsa::verify_sha256_pkcs1v15;
use dep::rsa::types::RBN2048;
use dep::bignum::{params::BigNumParams, RuntimeBigNum};
use dep::rsa::{rsa::verify_sha256_pkcs1v15, types::RBN2048};

fn main(hash: [u8; 32], signature: RBN2048) {
assert(verify_sha256_pkcs1v15(hash, signature, 65537));
Expand Down
8 changes: 2 additions & 6 deletions lib/src/rsa.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use dep::bignum::{RuntimeBigNum, params::BigNumParams};
use dep::bignum::{params::BigNumParams, RuntimeBigNum};

/**
* @brief Compare a recovered byte hash from an RSA signature to the original message hash
Expand Down Expand Up @@ -44,11 +44,7 @@ fn compare_signature_sha256<let N: u32>(padded_sha256_hash: [u8; N], msg_hash: [

/**
* @brief Verify an RSA signature generated via the pkcs1v15 signature scheme.
* @details The fourth function parameter is required to define the value of `NBytes`
* when converting a BigNum into a byte array, the number of bytes is required and currently cannot be inferred.
* Once numeric generics can be derived by applying operations to other numeric generics the need for this will go away.
*
* @note The exponent `e` can be either 65537 or 3 (i.e. the most common values in use for RSA)
* @note The `exponent` can be either 65537 or 3 (i.e. the most common values in use for RSA)
* Rough cost: 2,048 bit RSA: 26,888 gates per verification
* 1,024 bit RSA: 11,983 gates per verification
* A circuit that verifies 1 signature (and does nothing else) will cost ~32k due to initialization costs of lookup tables
Expand Down

0 comments on commit 6b9588e

Please sign in to comment.