Prob #1 {} Prob #2 AliceToBobG:=proc(ListM,Nbob,eBob,Nalice,dAlice,H) local i,m,x,M1,S: M1:=[seq(ListM[i] &^ eBob mod Nbob, i=1..nops(ListM))]: x:=add(m, m in M) &^3 mod H: S:=x&^dAlice mod Nalice: [M1,S]: end: BobReadAliceG:=proc(MS,Nbob,dBob,Nalice,eAlice,H) local i,m,M1,S,M,X,X1: M1:=MS[1]: S:=MS[2]: M:=[seq(M1[i] &^ dBob mod Nbob,i=1..nops(M1))]: X:=add(m, m in M) &^3 mod H: X1:=S&^eAlice mod Nalice: if X<>X1 then print(`You are not Alice, I will call the police`): fi: M: end: K:=7: n:=20: Nbob,eBob,dBob:=op(MakeRSAkey(K,n)); Nbob, eBob, dBob := 4598331726953191, 1048370117368963, 3118161455777515 Nalice,eAlice,dAlice:=op(MakeRSAkey(K-1,n)); Nalice, eAlice, dAlice := 1431161847919, 843714878713, 80518252009 ra:=rand(1..10^7): M:=[ra(),ra()]; M := [5085342, 4125651] H:=ra(); H := 3126633 MS:=AliceToBobG(M,Nbob,eBob,Nalice,dAlice,H); MS := [[1697944740215910, 1158344296086683], 934942703567] BobReadAliceG(MS,Nbob,dBob,Nalice,eAlice,H); [5085342, 4125651] Prob #3 Apparently due to some reason I am not on the mailing list, so I chose 3 people after and before where I should have been and exchanged emails with them. But I could only manage 4 exchanges. #1 Ryan’s birthday is 1222004 Nbob, eBob, dBob := 4598331726953191, 1048370117368963, 3118161455777515; Nbob, eBob, dBob := 4598331726953191, 1048370117368963, 3118161455777515 H := 3126633: Nalice:=71075675902377020867458486197834203818749099293106257635637664688979622728755658292668116928895566370183153059718888171923894963673493553436521783142977732724427348832679774391141885808373604669573610029; eAlice:=57135392383946585035396659334376779157093039942779214635683508412193771507019915775196000164640784831899150576752401249031618093414217219064633915664630766389233024519643408835667218028587592316709567855; Nalice := 710756759023770208674584861978342038187490992931062576\ 35637664688979622728755658292668116928895566370183153059718888\ 17192389496367349355343652178314297773272442734883267977439114\ 1885808373604669573610029 eAlice := 571353923839465850353966593343767791570930399427792146\ 35683508412193771507019915775196000164640784831899150576752401\ 24903161809341421721906463391566463076638923302451964340883566\ 7218028587592316709567855 H:=2718281828459045; H := 2718281828459045 MS:=[28399787628629, 17446608407616664764899764648068871814893607287671953339317673297928377604542531679977091620402573536178526284575285394780909040045634557514981308682783726871860991517809967212033664611118987003780211783]; MS := [28399787628629, 17446608407616664764899764648068871814893\ 60728767195333931767329792837760454253167997709162040257353617\ 85262845752853947809090400456345575149813086827837268718609915\ 17809967212033664611118987003780211783] BobReadAlice(MS,Nbob,dBob,Nalice,eAlice,H); 1222004 #I sent my public RSA keys: Nbob and eBob and H values to Ryan and he sent his Nalice, eAlice and H values along with the encrypted message and signature tuple, which he encrypted using my public keys. I decrypted them using my private key dBob and also hashed the message using his H value and decrypted his signature using his public key eAlice and found them to match. So indeed Ryan has used his private key dAlice to create this signature. I noticed that I chose a small Nbob, while Ryan had a bigger Nalice, as a result the encrypted message was much smaller than the signature. Ideally the signature should be much smaller than the message. How can we ensure this, since N values are typically very large. Also e values should be much smaller than d, so that it's easier to encrypt and very difficult to decrypt if the d value is not known. Also, usually the message and signature are concatenated to a single message. How can we ascertain their exact sizes, considering they are created using mod Nbob and Nalice and as such we can only know their upper bounds. #2 Robert’s birthday is 10151997 eAlice:=65537: Nalice:= 781031698217883042398890730588167007882753212312082463232625329429118308310700557226161167257864287497112646594083423739642856291713565876625980189273341617453296899265578536263772290719418809181289833873674466243735227170670747623731988888385475296513452691261296092088186595847190487484931619714612529041666895402387685839287384762848588078447029927783219111285572597724398689074360810786955072555913196849206252722952514822675486809906466904331236284216176894185287595913548875533977388179481458323646315143278086824654932577425491784595310574742954469002750038852791885437112141385501497033688351168039005975648776602234669602153777671309634931623194197525489751480366060594189076267130414967739155316040950648115500963210117071811910989047225658621754476375166781416632894855243464523714749416318518825790970384344337623363487021750848634301101882030448509042252397897612215439718705285976714636648986158554927938016438511288092137337703354586413203223814977591982788320753945520522155052965844593510495432059323088820333396387922533145400849774252574298970423764475804862809053455077077794767512417798804364205337309645960443188549312321332618576197481427323910025987316528972695113429854135692596148192594644555765051759291023: H:=65700862949: Nbob, eBob, dBob := 4598331726953191, 1048370117368963, 3118161455777515: MS:=[4223721990543027,103285230894794943057212399803176399946470785340236529668721156380000196638077149216589329827310147812488861459340439137102873419302609697032340308135332079374875457809918573780636715892328745418192853764706107686498974692900398751706246633529495388721271612750905828556883930919633646433924238193273024217037988350602957759140254775468372037944372358683629196138070623938345087042684047671803946914539808841499063783184562678540924442774936354910033133633513405998888788056513763592461102206920714463905835077637610890357176871287770140231911651389622179760897762600829657301483080723116719638275640983813044441813796454266334457170309393035111846614014649714932593112263478945037035558552873642387362073366311851281588046051183769540533568096623819527833767360176257209925806346264059938289397471757119368369829926699836205902603743169844698809195551144213383350456215049801968192435754995332714445103799069001697408045970579449209439197548673516374883714107354964252440709145788990964415312211792536439736882446151937685705038256616250836957917031828341425126683992624322087790534788322804511051929385677238374410540325969341728978630485176184068868784111688457226921543425207355078587086386477073548108080776542956649006360867171]: BobReadAlice(MS,Nbob,dBob,Nalice,eAlice,H); 10151997 #3 Ramesh’s birthday is 11102004 Nalice := 492998771032216348012303910671315588317812474007825405259893840187936917019208744525628423093275302629340858968060126701236677019747851721692549675609518259263189: eAlice := 410475808323463169303547359992192929450458850845412813816825646639530714768290252935518703659865743519504898128486163377063373918586974714316556294146251100364661: H := 7375128527775940: Nbob, eBob, dBob := 4598331726953191, 1048370117368963, 3118161455777515: MS:= [1927328334676874,437441081135873202536464292164679592898639290757458792063611361859372603800168736021417111291438665267233465352938589884758431137093385066962754143209072505731249]: BobReadAlice(MS,Nbob,dBob,Nalice,eAlice,H); 11102004 #4 My birthday to Robert eBob:=65537: Nbob:= 781031698217883042398890730588167007882753212312082463232625329429118308310700557226161167257864287497112646594083423739642856291713565876625980189273341617453296899265578536263772290719418809181289833873674466243735227170670747623731988888385475296513452691261296092088186595847190487484931619714612529041666895402387685839287384762848588078447029927783219111285572597724398689074360810786955072555913196849206252722952514822675486809906466904331236284216176894185287595913548875533977388179481458323646315143278086824654932577425491784595310574742954469002750038852791885437112141385501497033688351168039005975648776602234669602153777671309634931623194197525489751480366060594189076267130414967739155316040950648115500963210117071811910989047225658621754476375166781416632894855243464523714749416318518825790970384344337623363487021750848634301101882030448509042252397897612215439718705285976714636648986158554927938016438511288092137337703354586413203223814977591982788320753945520522155052965844593510495432059323088820333396387922533145400849774252574298970423764475804862809053455077077794767512417798804364205337309645960443188549312321332618576197481427323910025987316528972695113429854135692596148192594644555765051759291023: Nalice, eAlice, dAlice := 4598331726953191, 1048370117368963, 3118161455777515: H := 3126633: M:=11301974: MS:=AliceToBob(M,Nbob,eBob,Nalice,dAlice,H); MS := [255791605856748680739388783418420527343824726251114228926130125559522781821750104532051566211907767326077960998855616918305514760861323930678224151798946349369299729320024018119062071562328710654122649601798415772300581743470637933858676356689806981593279552944940535038615806217709752877485632095000981757845311044869802543506781754475291720896941945394263768620645967774921239875597145314127742963281767697943432215766291608253418302363774924316991633036649521548518158661879814130501706298289053861568536563232220549871418628110096508191205103311712957260588294549420976071070635539757066295576973047786457446911362473445943250575251462342592676108279817975117840880084493145371751597797933502656798917993997799132299235459855148447325448649247314630950794256532652167887691504395465400398156899189892724804898189355911888738920835902838962742505443250169270075055265943846146972513886629337998132480378056897908629667542868865126193610509936467038025036676555370863936816467945077051650330923813474604448532529075538966834099107287830494916444165436973123203520205677033210376234960750614836303480061266337789054842555818247472121117036979872557199899199301442360917585792651095515252485230612027860763945450741533113100073216804, 107911912603165] He successfully decrypted it to be 11301974