Initial commit
This commit is contained in:
commit
00d68d5165
13 changed files with 1129 additions and 0 deletions
39
test.sage
Normal file
39
test.sage
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
q = 50177
|
||||
|
||||
Fq.<yq> = PolynomialRing(ZZ.quotient(q))
|
||||
Rq = Fq.quotient(yq**256+1, "xq")
|
||||
xq = Rq.gen()
|
||||
|
||||
F2q.<y2q> = PolynomialRing(ZZ.quotient(q*2))
|
||||
R2q = F2q.quotient(y2q**256+1, "x2q")
|
||||
x2q = R2q.gen()
|
||||
|
||||
F2.<y2> = PolynomialRing(ZZ.quotient(2))
|
||||
R2 = F2.quotient(y2**256+1, "x2")
|
||||
x2 = R2.gen()
|
||||
|
||||
def center(x, m):
|
||||
x = x % m
|
||||
if x < m/2:
|
||||
return x
|
||||
else:
|
||||
return x - m
|
||||
|
||||
def f(x):
|
||||
return (R2([int(i)%2 for i in x.list()]), Rq([int(i)%q for i in x.list()]))
|
||||
|
||||
def g(a, b):
|
||||
al = a.list()
|
||||
bl = b.list()
|
||||
return R2q([int(al[i])*q-int(bl[i])*2*(q//2) for i in range(len(al))])
|
||||
|
||||
def add(ab, cd):
|
||||
return (ab[0]+cd[0], ab[1]+cd[1])
|
||||
|
||||
def mul(ab, cd):
|
||||
return (ab[0]*cd[0], ab[1]*cd[1])
|
||||
|
||||
a = -x2q**2 + 3*x2q + 2
|
||||
b = 4*x2q + x2q**4
|
||||
print(g(*mul(f(a), f(b))))
|
||||
print(a*b)
|
||||
Loading…
Add table
Add a link
Reference in a new issue