# This script untangles the Scientific American 1977 challenge # load power_mod read(`RSA.mpl`); # factors of RSA-129 found in 1994 P := 3490529510847650949147849619903898133417764638493387843990820577; Q := 32769132993266709549961988190834461413177642967992942539798288533; # RSA-129 K := P*Q; # encode(m) = m^s mod K s := 9007; # decode(e) = e^t mod K, where t = s^(-1) mod phi(K) t := s^(-1) mod ((P-1)*(Q-1)); # this procedure does the special number to text conversion used sciamer_unpack := proc(int) local ctrlstring, text, pos, code; ctrlstring := ` ABCDEFGHIJKLMNOPQRSTUVWXYZ`; code := int; text := ``; while(code > 0) do pos := code mod 100; code := iquo(code, 100); text := cat(substring(ctrlstring, pos+1..pos+1), text); od; RETURN(text); end; # test sciamer_unpack on example p. 123 sciamer_unpack(09201900011212000718050511002015001305); # this was the secret text on p. 121 challenge := 9686961375462206; challenge := challenge*10^16 + 1477140922254355; challenge := challenge*10^16 + 8829057599911245; challenge := challenge*10^16 + 7431987469512093; challenge := challenge*10^16 + 0816298225145708; challenge := challenge*10^16 + 3569314766228839; challenge := challenge*10^16 + 8962801339199055; challenge := challenge*10^16 + 1829945157815154; power_mod(challenge, t, K); sciamer_unpack(");