Question: Question 7 . Bob's actual private key looked like: f = - x 4 9 - x 4 7 + x 4 6 - x
Question Bob's actual private key looked like:
dots
dots
Did Eve's key f g give the same polynomials? If not, why did they still
work?
####################### FUNCTIONS #######################
### You can safely run this entire block at any point ###
### until you see the next block begin below. ###
def TddN:
Returns a random ternary polynomial in ZZz with:
d coefficients that equal
d coefficients that equal
if d d N:
raiseValueErrord d cannot exceed N
R PolynomialRingZZ
S SetrangeN
pos Ssubsetssizedrandomelement
S S pos
neg Ssubsetssizedrandomelement
v for i in rangeN
for i in pos:
vi
for i in neg:
vi
return Rv
def centerliftf:
R PolynomialRingZZ
P fparentbaseringcardinality
return R modt Pliftcentered for t in f
def encodes:
Encode the message ASCII string s as a polynomial mx in Rp
Uses environment variables p and N
s strs
k Nlogp
if lens k:
raiseValueError "String too long. Max length in Rp is strfloork
t sumordsii for i in rangelens
return Rptdigitsbasep
def decodem:
Decode the polynomial mx in Rp
mc listm
# Remember, mci belongs to GFp Lift to integers!
c sumIntegermcipi for i in rangelenmc
v join chrx for x in Integercdigitsbase
return v
def circulantmatrixa:
Returns the matrix whose ROWS are the rotations of the vector a:
a a an
an a an
a a a
n lena
R rangen
return matrix ajk n for j in R for k in R
def NTRUmatrixh:
Returns the NTRU lattice matrix associated to the public key
Npqd and hy in Rq in row form.
This matrix is in ROW form, the N x N block matrix:
I H
qI
where H is the circulant matrix generated by the coefficients of h
as a vector.
hv listcenterlifth
H circulantmatrixhv
I identitymatrixZZ N
O zeromatrixZZ N
return blockmatrixI HO qI
### End of functions block ###
###################################################
#################### PROBLEMS onwards ####################
#################### Alice's public key ####################
p
q
N
d
R PolynomialRingZZ
Sp PolynomialRingGFp
Rp SpquotientYN
Sq PolynomialRingGFq
Rq SqquotientZN
h zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
