Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ring LWE KE
from random import randint
def generate_matrix(dimention, modulus):
array = []
upper_limit = modulus * dimention
for i in range(0, dimention):
f = 0
for j in range(0, dimention):
f = f + (randrange(modulus, upper_limit) * x^j)
array.append(f)
return Matrix(array)
dimention = 8
modulus = 65537
R = PolynomialRing(GF(65537), "X")
X = R.gen()
S = R.quotient(X^1024 + 1, "x")
x = S.gen()
A = generate_matrix(dimention, modulus)
S = generate_matrix(dimention, modulus)
S_ = generate_matrix(dimention, modulus)
B = A.transpose()*S
B_ = A.transpose()*S_
alice = S*B_
bob = S_*B
print alice == bob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.