# Simple digital signature example with number

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.

-

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.

-
Would you mind adding a short explanation for each letter? (p,q,n,e,d,s,n,d) that would be great! –  Kirill Kulakov Oct 17 '13 at 15:59
@KirillKulakov See en.wikipedia.org/wiki/RSA_(algorithm) –  mikeazo Oct 17 '13 at 16:35
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? –  Kirill Kulakov Oct 17 '13 at 17:58
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. –  mikeazo Oct 17 '13 at 18:08
Which part did you correct? The only difference I see is that you're using mod n as an operator and mike uses congruence mod n. –  CodesInChaos Apr 21 at 9:12