Commit f5bf9925 authored by MASSON Simon's avatar MASSON Simon

merge

parents f23ab0d8 3fcdf24b
......@@ -143,6 +143,8 @@ class BLS12(EllipticCurve_finite_field):
def u(self):
return self._u
def T(self):
return self._u
def p(self):
return self._p
def r(self):
......@@ -153,6 +155,8 @@ class BLS12(EllipticCurve_finite_field):
return self._tr
def y(self):
return self._y
def D(self):
return self._D
def a(self):
return self._a # 0
def ap(self):
......
......@@ -144,6 +144,8 @@ class BN(EllipticCurve_finite_field):
def u(self):
return self._u
def T(self):
return self._u
def p(self):
return self._p
def r(self):
......@@ -154,6 +156,8 @@ class BN(EllipticCurve_finite_field):
return self._tr
def y(self):
return self._y
def D(self):
return self._D
def a(self):
return self._a # 0
def ap(self):
......
......@@ -256,6 +256,8 @@ class CocksPinch6(EllipticCurve_finite_field):
def u(self):
return self._u
def T(self):
return self._u
def p(self):
return self._p
def r(self):
......@@ -266,6 +268,8 @@ class CocksPinch6(EllipticCurve_finite_field):
return self._tr
def y(self):
return self._y
def D(self):
return self._D
def a(self):
return self._a # 0
def ap(self):
......
......@@ -262,6 +262,8 @@ class CocksPinch8(EllipticCurve_finite_field):
return self._tr
def y(self):
return self._y
def D(self):
return self._D
def a(self):
return self._a # 0
def ap(self):
......
......@@ -623,6 +623,11 @@ class CocksPinchVariantResult(object):
if pre:
print "C=%s" % repr(self)
def u(self):
return self.T
def T(self):
return self.T
def _prepare_E2(self):
if self._E2 is not None:
return
......
......@@ -124,6 +124,8 @@ class CocksPinch_k(EllipticCurve_finite_field):
def u(self):
return self._u
def T(self):
return self._u
def p(self):
return self._p
def r(self):
......@@ -134,6 +136,8 @@ class CocksPinch_k(EllipticCurve_finite_field):
return self._tr
def y(self):
return self._y
def D(self):
return self._D
def a(self):
return self._a # 0
def ap(self):
......
......@@ -148,6 +148,8 @@ class KSS16(EllipticCurve_finite_field):
def u(self):
return self._u
def T(self):
return self._u
def p(self):
return self._p
def r(self):
......@@ -158,6 +160,8 @@ class KSS16(EllipticCurve_finite_field):
return self._tr
def y(self):
return self._y
def D(self):
return self._D
def a(self):
return self._a # Integer
def ap(self):
......
......@@ -130,6 +130,8 @@ class MNT6(EllipticCurve_finite_field):
def u(self):
return self._u
def T(self):
return self._u
def p(self):
return self._p
def r(self):
......@@ -140,6 +142,8 @@ class MNT6(EllipticCurve_finite_field):
return self._tr
def y(self):
return self._y
def D(self):
return self._D
def a(self):
return self._a # 0
def ap(self):
......
......@@ -8,12 +8,13 @@ from KSS16 import *
from BN import *
from MNT6 import *
from final_expo_k57 import *
from enumerate_sparse_T import bit_positions_2naf, bit_positions
mystery_201903151748_simon_a_raison=False
# TODO: take into account h_t not always being 0 in the k=6 or k=8
# cases... [WIP for k=8 -- want to automate a bit]
mystery_201903151748_simon_a_raison=False
Qmsi = QQ['m,s,inv']
m,s,inv = Qmsi.gens()
......@@ -171,6 +172,8 @@ C6=CocksPinchVariantResult(6,3,0xefffffffffffffe00000000000000000,1,ht=-1,hy=0xf
C7=CocksPinchVariantResult(7,20,0x5fffb820248,6,ht=-2,allowed_cofactor=1232,allowed_size_cofactor=10,max_B1=600)
C8=CocksPinchVariantResult(8,4,0xffffffffeff7c200,5,ht=5,hy=-0xd700,allowed_cofactor=420,allowed_size_cofactor=10,max_B1=600)
CMNT6=MNT6(u=873723667900031396506414143162332159382674816702805606206979732381600254701804231398281169537138620,a=209307816050232262803672282154940341360062431838092388077917610639183322072827259682607127795420474686833003315766797546568469776750651773087882545447646552119008299040167030969895802846139484415144,b=2319663192174958547181026340141410918530227127674793888869119262391240421488942353013995765010333162065568990954578077256489549792305772041454141172011940607053889955897003759289947924385489341215143,D=8317003,c=1)
CBN12=BN(eval(preparse("2^114+2^101-2^14-1")))
CBLS12=BLS12(eval(preparse("-2^77+2^50+2^33")))
CKSS16=KSS16(eval(preparse("2^35-2^32-2^18+2^8+1")))
......@@ -250,12 +253,11 @@ def polymorphic_get_miller_loop_length(C):
elif isinstance(C, BN):
return 6*C.u()+2
elif isinstance(C, BLS12): # or isinstance(C, BLS24):
return C.tr() - 1
return C.u()
elif isinstance(C, KSS16): # or isinstance(C, KSS18):
return C.u()
elif isinstance(C, MNT6):
# lazy me
raise ValueError("not implemented")
return C.tr() - 1
elif isinstance(C, Integer):
raise ValueError("not implemented")
else:
......@@ -275,8 +277,7 @@ def polymorphic_get_fD(C):
if isinstance(C, CocksPinchVariantResult):
return C.fD
elif is_one_of_our_known_pairing_friendly_curves(C):
# no public accessor :-(
return C._D
return C.D()
elif isinstance(C, Integer):
return 1
else:
......@@ -381,11 +382,17 @@ def finalExpoCost(C):
tot_expo = 4100 * cost_m(1)
return tot_expo(m=1,s=1,inv=25)
elif name == 'BN':
T = C.u()
logT = T.nbits()
HwT = Hw(T)
BN_expo_z = 4*(114 - 1)*cost_m(2) + (6*3 - 3)*cost_m(2) + 3*cost_m(12) + 3*3*cost_s(2) + cost_i(2)
#BarDuq says 114*compr_s12 + 3* cost_m(12) + (i + (24*4 - 5)*cost_m(1))
tot_expo = cost_i(12) + 12*cost_m(12) + 3*cyclo_s12 + 4* cost_f(12) + 3*BN_expo_z
return tot_expo(m=1,s=1,inv=25)
elif name == 'BLS12':
T = C.u()
logT = T.nbits()
HwT = Hw(T)
BLS_expo_z = 4*(77 - 1)*cost_m(2)+ (6*2 - 3)*cost_m(2) + 2*cost_m(12) + 3*2*cost_s(2) + cost_i(2)
#BarDuq says 77*compr_s12 + 2*cost_m(12) + (i + (24*3 - 5)*cost_m(1))
tot_expo = cost_i(12) + 12*cost_m(12) + 2*cyclo_s12 + 4*cost_f(12) + 5*BLS_expo_z
......@@ -526,9 +533,9 @@ def pairingCost(C):
time_m = finite_field_cost(logp)
tot_miller = costMiller[-1]
time_miller = round(tot_miller * time_m/1000000, 1)
time_miller = round(tot_miller * time_m/1000000, 2)
tot_expo = costFinalExp
time_expo = round(tot_expo * time_m/1000000, 1)
time_expo = round(tot_expo * time_m/1000000, 2)
return dict(
k=polymorphic_get_embedding_degree(C),
D=polymorphic_get_fD(C),
......@@ -540,7 +547,7 @@ def pairingCost(C):
tot_expo=tot_expo,
time_expo=time_expo,
tot_pairing = tot_miller + tot_expo,
time_pairing = round(time_miller+time_expo, 1),
time_pairing = round(time_miller+time_expo, 2),
)
def table_cost_pairing() :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment