Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 . Given the prime p from the data file for this homework, how many characters can we encode per message? Remember that the

Question 1. Given the prime p from the data file for this homework, how many characters can we encode per message? Remember that the ASCII encoding of k characters gives a number up to 128k in size. You can take a base b logarithm in Sage with the log(x,b) command, usinglog(x,b).n() to obtain a numerical estimate. (You must justify your answer; saying 'I saw the number in the code' is not sufficient!)Alice publishes a public El Gamal key as the elliptic curve E given in the
data file with points P and Q=kP, where k is her secret key and is given in the data file, and cannot be determined from Q without solving the elliptic curve discrete logarithm problem. Bob chooses a random ephemeral private key l sends her the message encoded using the ECencode function as Pm encrypted as C1,C2inE(Fp) using the El Gamal cipher: C1=lP,C2=lQ+Pm.
Notice Bob did not need k to send Alice the message, only her public key was used.
The Given Code is as follows
def ECencode(s):
if len(s)>46:
print('Error: Trying to encode a message too long for this
curve.')
return
s = str(s)
x0= sum(ord(s[i])*128^i for i in range(len(s)))
for i in range(1000):
x = mod(1000*x0+ i, p)
y2= x^3+a*x+b
if mod(y2,p)^((p-1)/2)==1:
return E([x,y2^((p+1)/4)])
print("Failed to encode message on curve. This should literally almost
never happen.")
return False
def ECdecode(P):
n = Integer(P[0])
n =(n-n%1000)//1000
v =[]
while n !=0:
v.append(chr(n %128))
n //=128
return ''.join(v)
def prt(x, E='E'):
if x[2]==1:
print(str(E)+"("+ str(x[0])+","+ str(x[1])+")")
else:
print("z-coordinate is not 1: z ="+ str(x[2]))
p =
32638362670776732582497808372513801812493719864404824108133552287033857635
957199184927795559383233731
F = GF(p)
a =
90512378278836473777257660031033108410833892402752231593075652989547873643
52962813346315403348732105
b =
28665754774437555325580892302508762109738382779922896285195927202693872891
275401767457645834312587697
E = EllipticCurve(F,[a, b])
P =
E(268278132953802012296849398246005163783596010323274248180132058628857942
1418379319811693951113235402,
16869619464196207647323123436161130716215971876526267889484528178341832137
087769970754771506485262113)
k =692393314595748911633019465554228277654813344994872
C1=
E(299413739257553160568862108366943816092476424772845068755458341932386557
40439996735380855114886637859,
32003099420227818150640546832697309007650221568130300846699941139732213036
162076017115716729532301717)
C2=
E(291064601356432705969854254715660765199231967182750234611260584098351755
73196974958477478261532295650,
30435888933439216927938920653853078438467857258346541361541788686605413599
620043385425557980846296696)
P2=
E(258364748741314245007334219954446196732172476842279607735675783516371649
30549015595946119362968672437,
62679560412774440900540161772057211425708091098996771445077487298455966116
46444539272330

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago