Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p = 23
- a_L = [0, 1, 0, 1]
- a_R = [-1, 0, -1, 0]
- n_2 = [1, 2, 4, 8]
- n_1 = [1, 1, 1, 1]
- y = 15
- z = 13
- def expo(a, n_1, p) :
- tmp = [1]
- for i in range(0, len(n_1)) :
- tmp.append((a * tmp[i]) % p)
- return tmp
- def inner_product(a, b, p) :
- tmp = 0
- for i in range(0, len(a)) :
- tmp += ( a[i] * b[i] ) % p
- tmp = tmp % p
- return tmp
- def vector_minus(a, b, p) :
- tmp = []
- for i in range(0, len(a)) :
- tmp.append( (a[i] - b[i]) % p)
- return tmp
- def vector_add(a, b, p) :
- tmp = 0
- for i in range(0, len(a)) :
- tmp.append( (a[i] + b[i]) % p)
- return tmp
- def hadamard(a, b, p) :
- tmp = []
- for i in range(0, len(a)) :
- #print(str(i))
- tmp.append( (a[i] * b[i]) % p )
- return tmp
- print(str(inner_product(a_L, a_R, p)))
- print(str(inner_product(a_L, n_2, p)))
- print(str(hadamard(a_L, a_R, p)))
- v = inner_product(a_L, n_2, p)
- print(expo(y, n_1, p))
- n_y = expo(y, n_1, p)
- print("n_y : ")
- print(n_y)
- print("and the value is : " + str(v))
- left_side = (pow(z, 2, p) * v) % p
- R_1 = (pow(z, 2, p) * inner_product(a_L, n_2, p)) % p
- R_2 = (z * inner_product(vector_minus(vector_minus(a_L, n_1, p), a_R, p), n_y, p)) % p
- R_3 = inner_product(a_L, hadamard(a_R, n_y, p), p)
- print(R_2)
- print(R_3)
- right_side = (R_1 + R_2 + R_3)%p
- print("left_side : " + str(left_side))
- print("right_side : " + str(right_side))
Advertisement
Add Comment
Please, Sign In to add comment