forked from LeastAuthority/moonmath-manual
-
Notifications
You must be signed in to change notification settings - Fork 0
/
teaser-bls6_6.sagetex.scmd.tmp
71 lines (71 loc) · 1.89 KB
/
teaser-bls6_6.sagetex.scmd.tmp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
% This file was *autogenerated* from teaser-bls6_6.sagetex.sage with
% sagetex.py version 2019/01/09 v3.2
sage: for k in range(1,42): # Fermat's little theorem
....: if (43^k-1)%13 == 0:
....: break
sage: k
6
sage: F43 = GF(43)
sage: c2 = F43(5)
....: try: # quadratic residue
....: c2.nth_root(2)
....: except ValueError: # quadratic non residue
....: c2
sage: c3 =F43(36)
....: try:
....: c3.nth_root(3)
....: except ValueError:
....: c3
sage: BLS61 = EllipticCurve(F43,[0,1])
sage: BLS61.order() == 39
False
sage: BLS62 = EllipticCurve(F43,[0,c2^3])
sage: BLS62.order() == 39
False
sage: BLS63 = EllipticCurve(F43,[0,c3^2])
sage: BLS63.order() == 39
True
sage: BLS64 = EllipticCurve(F43,[0,c3^2*c2^3])
sage: BLS64.order() == 39
False
sage: BLS65 = EllipticCurve(F43,[0,c3^(-2)])
sage: BLS65.order() == 39
False
sage: BLS66 = EllipticCurve(F43,[0,c3^(-2)*c2^3])
sage: BLS66.order() == 39
False
sage: BLS6 = BLS63 # our BLS6 curve in the book
sage: P = BLS6(9,2)
sage: Q = 3*P
sage: Q.xy()
(13, 15)
sage: BLS6_13 = []
sage: for x in range(0,13): # cyclic of order 13
....: P = x*Q
....: BLS6_13.append(P)
sage: F43 = GF(43)
sage: F43t.<t> = F43[]
sage: p = F43t(t^6+6)
sage: p.is_irreducible()
True
sage: F43_6.<v> = GF(43^6, name='v', modulus=p)
sage: BLS6 = EllipticCurve (F43_6,[0 ,6]) # curve extension
sage: INF = BLS6(0) # point at infinity
sage: for P in INF.division_points(13): # full 13-torsion
....: # PI(P) == [q]P
....: if P.order() == 13: # exclude point at infinity
....: PiP = BLS6([a.frobenius() for a in P])
....: qP = 43*P
....: if PiP == qP:
....: break
sage: P.xy()
(7*v^2, 16*v^3)
sage: Q = BLS6(7*v^2,16*v^3)
sage: BLS6_13_2 = []
sage: for x in range(0,13):
....: P = x*Q
....: BLS6_13_2.append(P)
sage: g1 = BLS6([13,15])
sage: g2 = BLS6([7*v^2, 16*v^3])
sage: g1.weil_pairing(g2,13)
5*v^5 + 16*v^4 + 16*v^3 + 15*v^2 + 3*v + 41