Hi,
I tried to implement an small example sheet for using the RSA algorithmen with small numbers. Unfortunatly, I get confused by my own program and have difficulties to figure out what I am doing wrong. My message can be decoded with both keys, the public and private key what is obviously not correct.
below is my code with some comments:
restart: with (numtheory):
p := 13; # my first prime number
q := 23; # my second one
n := p*q;
Phi:=(p-1)*(q-1);
kpub:=5; # my randomly choosen number which is a relatively prime to Phi
igcdex(kpub,Phi,'alpha','beta');
'alpha' = alpha; # the inverse to my kpub => my kpriv
kpriv:= alpha mod Phi;
x:=298; #Message as plain text
y:=x&^kpub mod n; # y is the now encoded message with X being smaller than n, it should be fine?
#Decoding y with public and private key results in the original message x, I do not get it? At least for the public key that should not work. What am I doing wrong?
y&^kpriv mod n;
y&^kpub mod n;
Thanks for feedback