#OK to post homework #Ramesh Balaji,4/21/2024,hw24 # Part 1: dinnerRB := proc(): return [6]; end: # Part 2 AliceToBob:=proc(M,Nbob,eBob,Nalice,dAlice,H) local x,M1,S: M1:=M&^eBob mod Nbob: x:=M&^3 mod H: S:=x&^dAlice mod Nalice: [M1,S]: end: BobReadAlice:=proc(MS,Nbob,dBob,Nalice,eAlice,H) local M1,S,M,X,X1: M1:=MS[1]: S:=MS[2]: M:=M1&^dBob mod Nbob: X:=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: AliceToBobG := proc(ListM,Nbob,eBob,Nalice,dAlice,H): oatM := []; sumSiggy := 0; for M in ListM do: MS := AliceToBob(M, Nbob,eBob,Nalice,dAlice,H): oatM := [op(oatM), M[1]]; sumSiggy += M[2]; end: return [oatM, sumSiggy]; end: BobReadAliceG := proc(MS,Nbob,dBob,Nalice,eAlice,H): decM := []; for M in MS do: M1:=MS[1]: S:=MS[2]: M:=M1&^dBob mod Nbob: decM := [op(decM), M]; od: sumSiggy := 0; for dM in decM do: X1:=S&^eAlice mod Nalice: sumSiggy += X1; od: X:=M&^3 mod H: if X<>sumSiggy then print(`You are not Alice, I will call the police`): fi: return decM; end: # Part 3 # Not everyone has sent me their messages! # I ran MakeRSAkey(80, 20) which yielded # [492998771032216348012303910671315588317812474007825405259893840187936917019208744525628423093275302629340858968060126701236677019747851721692549675609518259263189, # 410475808323463169303547359992192929450458850845412813816825646639530714768290252935518703659865743519504898128486163377063373918586974714316556294146251100364661, # 189549137892900072835241977431361809037855915963647387053640625262703886378822493318302776424229658452007323912207050664573425893370488027503512023627659555645941] N := 492998771032216348012303910671315588317812474007825405259893840187936917019208744525628423093275302629340858968060126701236677019747851721692549675609518259263189; e := 410475808323463169303547359992192929450458850845412813816825646639530714768290252935518703659865743519504898128486163377063373918586974714316556294146251100364661; d := 189549137892900072835241977431361809037855915963647387053640625262703886378822493318302776424229658452007323912207050664573425893370488027503512023627659555645941; H := 7375128527775940; # H(M) := M^3 mod 7375128527775940; M := 11102004; # Receiving message from: Alex Nalex := 127711530576913131575822837202695013403663973620035921837879420367037214508135409563566908342874207064840127385407221751352663779327696096399630613900936616858959749861340170876488836082629813856249120005724484735689838811034360372512307576472640677385363361607178937414342488091713518463212893445678420981681836444012003107363190609806803250295744593107767353636904574968104745778336591373948331356757; eAlex := 119355774480941089068182500865657768029894607347642880120545383004726786851010456573815590351368205648404734577585495922417424364163563086225199220958858935794581522185774723052024382414153458927245099731963599373227019468645772411467935611447961466163613435976492179213526206037862087594104175657308096047213419047678857605794783582772159597837949854191484531513184753882102313617780747286231266988359; Malex := 389593594106218059695031631198633639149383428551282129657546146819332478859246814718509308771282595402974694377358953428959173519046166567274755532977894618412556; sigAlex := 41609026479294837627479040188604183676706517652713839057652443887342692678954624305700318979296270980927726623549771140445052057937492271849641146238280090203244127976822264355785360677605339066707010492776280361313633030101445841691117063079012558329841541755025176338600638857796823113475423963217106573127434668503031109280218558061636941883972776171843938002201889898764993236191090615358517167695; Halex := 314159265358979; # You are not Alice, I will call the police # Birthdate was revealed, but... might not be correct. # Birthday: 7/26/2004 BobReadAlice([Malex, sigAlex], N, d, Nalex, eAlex, Halex); # Receiving message from: Kaylee Nkaylee:= 67691666664530921435211598693239937131522585260806907687694995053273907664003653369: eKaylee:= 34495631854907652833027495015895242338065521961439740870909035352538732145820229699; Hkaylee := 1112621112853; Mkaylee := 21109146914854672751686504775736472389525146196203948969445961546398515070289597893015285790881301607343432682356255499852811682182418491868859047156325077503384; sigKaylee := 2553918223772008722599605284622997569637924568133455467205804172580657836818386040560331391453425270796682875345071761170228217733083288042055930320131372090610366540097737427290290292236414244615850958; # You are not Alice, I will call the police # 6/23/2001 BobReadAlice([Mkaylee, sigKaylee], N, d, Nkaylee, eKaylee, Hkaylee); # I did not receive a message from anyone else. # Sending messages to: Shaurya Nshaurya := 741722208453803540319268247178773400187219540755637048600837667643712077137100784815902032907627202684725052133657977388430721940565969634497741991891629104756024347555919826922991511673210444430067957; eShaurya := 468739773739813145043673147966921765247165617762303145800598594443673848897972709733443148896181442846999006871294294927232006568386142154050238811213459916690546269900022300085480318862425218862758487; # Correctly verified bdate + the signature was wrong. AliceToBob(M,Nshaurya,eShaurya,N,d,H - 212); # Sending messages to: Himanshu Nhimanshu := 4598331726953191; eHimanshu := 1048370117368963; # Correctly verified signature + bdate. AliceToBob(M,Nhimanshu,eHimanshu,N,d,H); # Sending messages to Robert Nrobert := 781031698217883042398890730588167007882753212312082463232625329429118308310700557226161167257864287497112646594083423739642856291713565876625980189273341617453296899265578536263772290719418809181289833873674466243735227170670747623731988888385475296513452691261296092088186595847190487484931619714612529041666895402387685839287384762848588078447029927783219111285572597724398689074360810786955072555913196849206252722952514822675486809906466904331236284216176894185287595913548875533977388179481458323646315143278086824654932577425491784595310574742954469002750038852791885437112141385501497033688351168039005975648776602234669602153777671309634931623194197525489751480366060594189076267130414967739155316040950648115500963210117071811910989047225658621754476375166781416632894855243464523714749416318518825790970384344337623363487021750848634301101882030448509042252397897612215439718705285976714636648986158554927938016438511288092137337703354586413203223814977591982788320753945520522155052965844593510495432059323088820333396387922533145400849774252574298970423764475804862809053455077077794767512417798804364205337309645960443188549312321332618576197481427323910025987316528972695113429854135692596148192594644555765051759291023; eRobert := 65537; Hrobert := 65700862949; AliceToBob(M,Nrobert,eRobert,N,d,H); # Receive from Robert Mrobert := 60046500954587538732935883597003387305908885286300582879266297462831794267655772093429094456672947556873075462194796032500568574947864167405995573472818413802842; sRobert := 64838092585; BobReadAlice([Mrobert, sRobert], N, d, Nkaylee, eRobert, Hrobert);