Question: Show in sage please Question 3 . Bob's public key is q 2 , h 2 ( given in Sage as q 2 , h

Show in sage please Question 3. Bob's public key is q2,h2(given in Sage as q2,h2). Alice has
sent Bob a message encrypted as e2. Recall that we discussed in lecture that
if we can find integers RF*(1,h2)-R*(0,q2)=(F,G)(f2,g2)=(F,G)(F,G)L=Z(1,h2)+Z(0,q2)(1,h2)(0,q2)q2(F,G)q22$7.12(F,G)L=Z(1,h2)+Z(0,q2)e20 and R satisfying
F*(1,h2)-R*(0,q2)=(F,G)
then we will be likely to have recovered Bob's private key in the form (f2,g2)=
(F,G). The vector (F,G) lies in the lattice L=Z(1,h2)+Z(0,q2), and aswe
mentioned in lecture, itis a short vector relative to the basis vectors (1,h2)
and (0,q2), both of which have length roughly q2, whereas (F,G) will have
length on the order ofq22. Implement Gauss' method of lattice reduction
from lecture (see also $7.12in the textbook, and the helpful Sage code in
hw9-data.txt)to find the smallest vector (F,G)in the lattice L=Z(1,h2)+
Z(0,q2) and find Bob's private key. Use this to decrypt the message e2 that
Alice has sent to Bob.
def encode(s):
s = str(s)
if len(s)>71:
print 'Error, string too long.'
return
return sum(ord(s[i])*128^i for i in range(len(s)))
def decode(n):
n = Integer(n)
v =[]
while n !=0:
v.append(chr(n %128))
n //=128
return ''.join(v)
q =2227931092922619159088137825860917778654908962259364260724799634482871993679344024477214037820250089114550582112658547035427887568025339234287716719310475274676925427488455341264359399933469547884104546673995772201433027461094946187102932478528326005620630416132860562672779096576947422455142739470761
f =626346493922296891962453123852828762226840739369641575566811218944994465423391699556882442728756781708398121951194799184723646669035568862933089972532
g =977000403491994460922837866629768065514748480840502199588478427171542192931318741506250139746005024832848394512867819725451407771971457631489150320807
h = mod(f,q)^(-1)*mod(g,q)
e =78718410001068529677588572614497505845736983903998613145157719609579915026054651042742971468860259386790104756141288441579114641145660779208031511331352898518118466155496980362017676866087191935146013866713673612565156506113920877930874410944039265560871107404980288749922814814885918909569495979623042532040822272019812413569842170256723818746065909730713382503129868557825346347038766126043524590160376367091553994881762361291104351498414443598243
q2=1227182889694546672385266772170943236816561807917967033563259284790533365147889304764034689408538624438744399079411125593580586814

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!