Esempio n. 1
0
    def __init__(self,PPATCpp,g1,g2,h1):
        self.PPATCpp = PPATCpp
        self.g1 = g1 # in G1
        self.g2 = g2 # in G1
        self.h1 = h1 # in G2'
        #psi = self.PPATCpp.psi
        #self.hashf = None # Hash function to be implemented

        #assert g1.ECG == self.PPATCpp.Pair.ECG
        #assert g2.ECG == self.PPATCpp.Pair.ECG
        Jcoord = self.PPATCpp.Jcoord
        if Jcoord :
            self.g1.toJcoord()
            self.g2.toJcoord()
            self.h1.toJcoord()
        #assert psi(h1).ECG == self.PPATCpp.Pairing.EFqp

        w = 10
        m = len(utils.binn(self.PPATCpp.order))
        #m = 160
        d = int(math.ceil(float(m)/w))
        e = int(math.ceil(float(d)/2))

        # Precomputed tables to fasten the scalr multiplication with the generators
        self.precomp_g = oEC.prec_comb2_EFp2(w,m,self.PPATCpp.g,Jcoord),w,m,d,e
        self.precomp_h = oEC.prec_comb2_EFp(w,m,self.PPATCpp.h,Jcoord),w,m,d,e
        self.precomp_g1 = oEC.prec_comb2_EFp2(w,m,self.g1,Jcoord),w,m,d,e
        self.precomp_g2 = oEC.prec_comb2_EFp2(w,m,self.g2,Jcoord),w,m,d,e
        self.precomp_h1 = oEC.prec_comb2_EFp(w,m,self.h1,Jcoord),w,m,d,e


        self.to_fingerprint = ["PPATCpp","g1","g2","h1"]
        self.to_export = {"fingerprint": [],"value": ["PPATCpp","g1","g2","h1"]}
Esempio n. 2
0
    def __init__(self,PPATSpp,g1,h1,maxexp=16):
        self.PPATSpp = PPATSpp
        self.g1 = g1 # in G2'
        self.h1 = h1 # in G1
        self.maxexp = maxexp
        Jcoord = self.PPATSpp.Jcoord
        if Jcoord :
            self.g1.toJcoord()
            self.h1.toJcoord()

        self.ehg = self.PPATSpp.e(self.PPATSpp.h,self.PPATSpp.psi(self.PPATSpp.g),self.PPATSpp.Pair,Jcoord)
        self.ehgt = oEC.toTupleFp12(self.ehg) # tuple version of egh1

        #self.tripletsList = []

        #lkq = len(bin(self.h1.EFq.F.q))
        w = 10
        m = len(utils.binn(self.PPATSpp.order))
        #m = 160
        d = int(math.ceil(float(m)/w))
        e = int(math.ceil(float(d)/2))

        # Precomputed tables to fasten the scalr multiplication with the generators
        self.precomp_g = oEC.prec_comb2_EFp2(w,m,self.PPATSpp.g,Jcoord),w,m,d,e
        self.precomp_h = oEC.prec_comb2_EFp(w,m,self.PPATSpp.h,Jcoord),w,m,d,e
        self.precomp_g1 = oEC.prec_comb2_EFp2(w,m,self.g1,Jcoord),w,m,d,e
        self.precomp_h1 = oEC.prec_comb2_EFp(w,m,self.h1,Jcoord),w,m,d,e

        self.to_fingerprint = ["PPATSpp","g1","h1"]
        self.to_export = {"fingerprint": [],"value": ["PPATSpp","g1","h1"]}
Esempio n. 3
0
    def __init__(self, PPATCpp, g1, g2, h1):
        self.PPATCpp = PPATCpp
        self.g1 = g1  # in G1
        self.g2 = g2  # in G1
        self.h1 = h1  # in G2'
        #psi = self.PPATCpp.psi
        #self.hashf = None # Hash function to be implemented

        #assert g1.ECG == self.PPATCpp.Pair.ECG
        #assert g2.ECG == self.PPATCpp.Pair.ECG
        Jcoord = self.PPATCpp.Jcoord
        if Jcoord:
            self.g1.toJcoord()
            self.g2.toJcoord()
            self.h1.toJcoord()
        #assert psi(h1).ECG == self.PPATCpp.Pairing.EFqp

        w = 10
        m = len(utils.binn(self.PPATCpp.order))
        #m = 160
        d = int(math.ceil(float(m) / w))
        e = int(math.ceil(float(d) / 2))

        # Precomputed tables to fasten the scalr multiplication with the generators
        self.precomp_g = oEC.prec_comb2_EFp2(w, m, self.PPATCpp.g,
                                             Jcoord), w, m, d, e
        self.precomp_h = oEC.prec_comb2_EFp(w, m, self.PPATCpp.h,
                                            Jcoord), w, m, d, e
        self.precomp_g1 = oEC.prec_comb2_EFp2(w, m, self.g1,
                                              Jcoord), w, m, d, e
        self.precomp_g2 = oEC.prec_comb2_EFp2(w, m, self.g2,
                                              Jcoord), w, m, d, e
        self.precomp_h1 = oEC.prec_comb2_EFp(w, m, self.h1, Jcoord), w, m, d, e

        self.to_fingerprint = ["PPATCpp", "g1", "g2", "h1"]
        self.to_export = {
            "fingerprint": [],
            "value": ["PPATCpp", "g1", "g2", "h1"]
        }
Esempio n. 4
0
 def setup(self,g,h,gp,SK_PC):
     '''
     generates the public key from generators g,h and the secret key SK_PC
     the method (re-)initialize self.gVec and self.hVec
     '''
     """
     if self.Jcoord :
         g.toJcoord()
         h.toJcoord()
         gp.toJcoord()
     """
     alpha = SK_PC.alpha
     gVec = [g]
     hVec = [h]
     gprimeVec = [gp]
     for i in range(1,self.deg_pol+1):
         g_prev = gVec[-1]
         h_prev = hVec[-1]
         gp_prev = gprimeVec[-1]
         g_i = alpha*g_prev
         h_i = alpha*h_prev
         gp_i = alpha*gp_prev
         gVec.append(g_i)
         hVec.append(h_i)
         gprimeVec.append(gp_i)
     
     gVec.reverse()
     hVec.reverse()
     gprimeVec.reverse()
     self.gVec = gVec
     self.hVec = hVec
     self.gprimeVec = gprimeVec
     
     for i in range(len(gVec)):
         gVec_i = gVec[i]
         hVec_i = hVec[i]
         gpVec_i = gprimeVec[i]
         tb_gVec_i = oEC.prec_comb2_EFp(self.w,self.m,gVec_i,self.Jcoord),self.w,self.m,self.d,self.e
         self.gVecTab.append(tb_gVec_i)
         tb_hVec_i = oEC.prec_comb2_EFp(self.w,self.m,hVec_i,self.Jcoord),self.w,self.m,self.d,self.e
         self.hVecTab.append(tb_hVec_i)
         tb_gpVec_i = oEC.prec_comb2_EFp2(self.w,self.m,gpVec_i,self.Jcoord),self.w,self.m,self.d,self.e
         self.gprimeVecTab.append(tb_gpVec_i)