The Electronic Journal of Ma<strong>the</strong>matics and Technology, Volume 6, Number 1, ISSN 1933-2823(%i22) rsa_<strong>de</strong>crypt_ds("/root/hysteria-signed.txt",20,public_keyA,private_keyB,"hysteria-signed-<strong>de</strong>crypted.txt");(%o22) /root/hysteria − signed − <strong>de</strong>crypted.txtNote that in or<strong>de</strong>r to get <strong>the</strong> text in <strong>the</strong> file /root/hysteria-signed-<strong>de</strong>crypted.txtnicely formatted, one has to write <strong>the</strong> co<strong>de</strong> above for rsa encrypt ds <strong>with</strong> <strong>the</strong> appropriate newline breaks and long line expressions, as it contains some string arguments in simplo<strong>de</strong> that willbe written “as <strong>the</strong>y are”; <strong>the</strong> version appearing here does not have <strong>the</strong>se features to fit <strong>with</strong>in <strong>the</strong> pagewidth.5 Working at <strong>the</strong> classroomWhen working out examples <strong>with</strong> <strong>the</strong> stu<strong>de</strong>nts at <strong>the</strong> classroom, <strong>the</strong> teacher can produce a message,sign it and send it encrypted to <strong>the</strong> stu<strong>de</strong>nts for <strong>de</strong>crypting it. To do this efficiently, it is a goodi<strong>de</strong>a to have a file <strong>with</strong> <strong>the</strong> names of <strong>the</strong> stu<strong>de</strong>nts or<strong>de</strong>red (following any criteria), and ano<strong>the</strong>r onewhere <strong>the</strong>ir public keys are stored <strong>with</strong> <strong>the</strong> same or<strong>de</strong>ring. In this way, <strong>the</strong> teacher can send <strong>the</strong> samemessage to different stu<strong>de</strong>nts, digitally signed <strong>with</strong> his own private key, but encrypted <strong>with</strong> <strong>the</strong> publickey corresponding to each stu<strong>de</strong>nt.Suppose for example that we have seven stu<strong>de</strong>nts: Cor<strong>de</strong>lia, Curan, Edmund, Fool, Goneril, Lear,and Regan. We create a text file <strong>with</strong> each name in one line, alphabetically or<strong>de</strong>red, and store it at/root/stu<strong>de</strong>nts.txt. Also, we let <strong>the</strong> stu<strong>de</strong>nts create <strong>the</strong>ir own public-private keys, and ask<strong>the</strong>m to hand us <strong>the</strong> public pairs. All <strong>the</strong>se public pairs are written on ano<strong>the</strong>r text file, each pair e, nin one line (separated by commas). For instance, we could have:1119871,3560093623521,2735539745231,25439871321063,3038941140759,19812111019747,2155823609043,2827757We store <strong>the</strong> file at /root/public-keys.txt. For later use, note that <strong>the</strong> public key of <strong>the</strong>fourth stu<strong>de</strong>nt, Fool, is [1321063, 3038941]. Actually, his private one is [734395, 3038941] (both weregenerated <strong>with</strong> generate random key(10)).The teacher wants to send an encrypted message, contained in <strong>the</strong> file /root/KingLear.txt.His own digital signature:The teacherWilliam ShakespeareKing Learis contained in ano<strong>the</strong>r file, /root/digsig.txt. Finally, <strong>the</strong> public-private keys of <strong>the</strong> teacherare:51
The Electronic Journal of Ma<strong>the</strong>matics and Technology, Volume 6, Number 1, ISSN 1933-2823(%i23) teacher_public;(%o23) [429881, 2294543](%i24) teacher_private;(%o24) [872729, 2294543]With <strong>the</strong>se data, <strong>the</strong> following function rsa encrypt group signs <strong>the</strong> message <strong>with</strong> <strong>the</strong> teacher’ssignature, encrypts <strong>the</strong> signature <strong>with</strong> <strong>the</strong> teacher’s private key, <strong>the</strong> whole message <strong>with</strong> each stu<strong>de</strong>nt’spublic key and generates a file <strong>with</strong> <strong>the</strong> name of <strong>the</strong> stu<strong>de</strong>nt containing <strong>the</strong> encrypted message, storedin a path given by <strong>the</strong> user (in <strong>the</strong> example, /root/messages/). Note also <strong>the</strong> k value for <strong>the</strong> textchunks (k = 3 in <strong>the</strong> example).(load(numericalio));Beginning of co<strong>de</strong>rsa_encrypt_group(s,k,t,u,r,Q,q):=block([stu<strong>de</strong>nts,publickeys,name,path],stu<strong>de</strong>nts:read_list(t),publickeys:read_nested_list(u,comma),for j:1 thru length(stu<strong>de</strong>nts) do(name:stu<strong>de</strong>nts[j],path:simplo<strong>de</strong>([r,string(name),".txt"]),rsa_encrypt_ds(s,k,publickeys[j],Q,q,path)));End of co<strong>de</strong>(%i25) rsa_encrypt_group("/root/KingLear.txt",3,"/root/stu<strong>de</strong>nts.txt","/root/public-keys.txt","/root/messages/",teacher_private,"/root/digsig.txt");(%o25) doneNow, we have seven files in /root/messages/. These are: Cor<strong>de</strong>lia.txt, Curan.txt,Edmund.txt, Fool.txt, Goneril.txt, Lear.txt, and Regan.txt. Suppose that <strong>the</strong>teacher sends each one to its corresponding recipient. When Fool receives his message, he can <strong>de</strong>cryptit using <strong>the</strong> function rsa <strong>de</strong>crypt ds of <strong>the</strong> preceding section, as he knows <strong>the</strong> teacher’s publickey (to <strong>de</strong>cipher <strong>the</strong> signature) and his own private key (to <strong>de</strong>cipher <strong>the</strong> message):(%i26) rsa_<strong>de</strong>crypt_ds("/root/messages/Fool.txt",3,teacher_public,[734395,3038941]);52