I've been looking for a simple which signs a number with some randomly generated key and then verified(decrypts the original number) with the public key, which is generated by the private.

All the examples I've found does not feature an example with real numbers, and all the keys/numbers described with a single letter, which is not really that clear.


1 Answer 1


I'll give a simple example with (textbook) RSA signing. I'm going to assume you understand RSA.

First key gen: $p\gets 7,q\gets 13,n\gets pq=91, e\gets 5, d\gets 29$

Thus your public key is $(e,n)$ and your private key is $d$.

Say we want to sign the message $m=35$, we compute $s=m^d\bmod{n}$ which is $s\gets 42\equiv 35^{29}\bmod{n}$.

The message and signature get sent to the other party $(m,s)=(35,42)$. Who takes the signature and raises it to the $e$ modulo $n$, or $42^{5}\equiv 35 \bmod{n}$. Then makes sure that this value is equal to the message that was received, which it is, so the message is valid.

  • $\begingroup$ Would you mind adding a short explanation for each letter? (p,q,n,e,d,s,n,d) that would be great! $\endgroup$ Commented Oct 17, 2013 at 15:59
  • $\begingroup$ @KirillKulakov See en.wikipedia.org/wiki/RSA_(algorithm) $\endgroup$
    – mikeazo
    Commented Oct 17, 2013 at 16:35
  • $\begingroup$ I've found it to be really confusing, It seems like there is quite a complex logic for choosing 'e', how did you choose yours? secondly and most important: If 'e' is the public exponent why do we use it to create our private key? $\endgroup$ Commented Oct 17, 2013 at 17:58
  • $\begingroup$ If you let $\phi(n)=(p-1)(q-1)$ then we need an $e$ such that $gcd(\phi(n), e)=1$. In this case I just checked 5 and the gcd was 1, so I used it. You could pick $d$ instead and compute $e$ from it, but it is easy to mess things up and make RSA insecure if you do this and aren't careful. $\endgroup$
    – mikeazo
    Commented Oct 17, 2013 at 18:08
  • 1
    $\begingroup$ The choice of $p=7$, $q=13$, $e=5$ is not ideal as an RSA example: the numbers are such that $e$ is both the public exponent and a working private exponent (using $d=29$ or $d=5$ as private exponent always give the exact same result). Also, it is questionable to even illustrate any use of RSA (except enciphering or signing a random number) without padding. $\endgroup$
    – fgrieu
    Commented Feb 28, 2016 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.