/* ========================================================================== Encryption Process of Matsumoto Imai The program loads the public key from the file public_key.txt and encrypts a randomly generated message the ciphertext is stored in ciphertext.txt ===============================================================================*/ printf "************************************************\n"; printf "*** Matsumoto-Imai Cryptosystem - Encryption *** \n"; printf "************************************************ \n \n"; timet:=Cputime(); load "public_key.txt"; Vn:=VectorSpace(GF,n); message:=Random(Vn); // random message for loop:=1 to n do for i:=1 to n do Pk[loop]:=Evaluate(Pk[loop],x[i],message[i]); end for; end for; ciphertext:=Vn!(Pk); print "MI decrypt time:",timet; PrintFile("times_encrypt",Cputime(timet)); printf "message:= %o \n \n",message; printf "ciphertext:= %o \n \n", ciphertext; printf"Write ciphertext.txt \n \n"; SetOutputFile("ciphertext.txt":Overwrite:=true); printf "Vn:=VectorSpace(GF,n); \n \n"; printf "message:= Vn!(%o); \n \n", Eltseq(message); printf "ciphertext:= Vn!(%o); \n \n", Eltseq(ciphertext); UnsetOutputFile();