/* ------------------------------------------------------------- Encryption Process of HFE Encryption Scheme loads public key from public_key.txt and encrypts a random message ciphertext is stored in ciphertext.txt ---------------------------------------------------------------*/ clear ; SetSeed(0,0); printf "****************************************** \n"; printf "*** HFE Encryption Scheme - Encryption *** \n"; printf "****************************************** \n \n"; timet:= Cputime(); load "public_key.txt"; message:=Random(messagespace); printf"message:= %o\n\n", message; for i:=1 to n do for j:=1 to n do Pk[i]:=Evaluate(Pk[i],Pol.j,message[j]); end for; end for; ciphertext:=messagespace!(Pk); printf "time for encryption: %o\n\n",Cputime(timet); printf"ciphertext:= %o \n\n", ciphertext; printf"Write ciphertext.txt \n\n"; SetOutputFile("ciphertext.txt":Overwrite:=true); printf "ciphertext:= %o ;\n\n", Eltseq(ciphertext); printf "original := %o;\n",Eltseq(message) ; UnsetOutputFile();