Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jack4818
GitHub Repository: jack4818/Castryck-Decru-SageMath
Path: blob/main/richelot_test.sage
323 views
1
from richelot_aux import *
2
load('speedup.sage')
3
4
def test_FromProdToJac():
5
# Choose some supersingular curves and 2^a torsion generators.
6
p = 2**61 - 1
7
assert p.is_prime()
8
k = GF(p^2)
9
E = EllipticCurve(k, [-1, 0])
10
assert E.is_supersingular()
11
assert E.order() == 2**122
12
C = EllipticCurve(k, [1, 0])
13
assert C.is_supersingular()
14
assert C.order() == 2**122
15
a = 61
16
Pc, Qc = C.gens()
17
P, Q = E.gens()
18
wc = Pc.weil_pairing(Qc, 2^a)
19
we = P.weil_pairing(Q, 2^a)
20
# make it an anti-isometry
21
k = we.log(wc)
22
Q = -pow(k, -1, 2^a) * Q
23
assert P.weil_pairing(Q, 2^a) * Pc.weil_pairing(Qc, 2^a) == 1
24
return FromProdToJac(C, E, Pc, Qc, P, Q, a)
25
26
test_FromProdToJac()
27
28
29
def test_FromJacToJac():
30
print("test_FromJacToJac")
31
h, D11, D12, D21, D22, _ = test_FromProdToJac()
32
for e in FromJacToJac(h, D11, D12, D21, D22, 60):
33
print(e)
34
35
test_FromJacToJac()
36
37
def test_ChainSplit():
38
print("test_ChainSplit")
39
p = 2**61 - 1
40
k = GF(p^2)
41
E = EllipticCurve(k, [-1, 0])
42
C = EllipticCurve(k, [1, 0])
43
a = 61
44
Pc, Qc = C.gens()
45
P, Q = E.gens()
46
wc = Pc.weil_pairing(Qc, 2^a)
47
we = P.weil_pairing(Q, 2^a)
48
# make it an anti-isometry
49
k = we.log(wc)
50
Q = -pow(k, -1, 2^a) * Q
51
assert P.weil_pairing(Q, 2^a) * Pc.weil_pairing(Qc, 2^a) == 1
52
assert not Does22ChainSplit(C, E, Pc, Qc, P, Q, 61)
53
54
test_ChainSplit()
55
56