Question: Question 6 . Since that didn't work, let's try the next smallest vector by extracting the second row of the LLL - reduced NTRU matrix.
Question Since that didn't work, let's try the next smallest vector by
extracting the second row of the LLLreduced NTRU matrix. Run
:
:
Confirm that and are the same polynomial, then use these
this key to decrypt Alice's message e to Bob.
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 zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
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
