Esempio n. 1
0
def init():
    try:
        uid = until.get_mac_address()
        
        p = session.get(uid+'p')
        a = session.get(uid+'a')
        b = session.get(uid+'b')
        n = session.get(uid+'n')
        
        secp = session.get(uid+'secp')
        
        if secp == 'secp256k1':
            params = blind_demo.choose_parameters_secp256k1()
        elif secp == 'secp192k1':
            params = blind_demo.choose_parameters_secp192k1()
        
        orig_h = until.getObjFromSession(uid+'h_bytes',params.group)
        orig_g = until.getObjFromSession(uid+'g_bytes',params.group)
        
        
        orig_x = until.getObjFromSession(uid+'x_bytes',params.group)
        orig_y = until.getObjFromSession(uid+'y_bytes',params.group)
        orig_z = until.getObjFromSession(uid+'z_bytes',params.group)
        orig_gamma = until.getObjFromSession(uid+'gamma_bytes',params.group)
        orig_xi = until.getObjFromSession(uid+'xi_bytes',params.group)

        rjson = str(p) + '#' + str(a) + '#' + str(b) + '#' + str(n) + '#' + str(orig_g) + '#' + str(orig_h) \
        + '#' + str(secp) + "#" + str(orig_x) + '#' + str(orig_y) + '#' + str(orig_z) + '#' + str(orig_gamma) + '#' + str(orig_xi)

        return rjson
    except Exception:
        return '0'
Esempio n. 2
0
def issuerkey():
    try:
        uid = until.get_mac_address()
        secp = session.get(uid+'secp')
        print(session.get(uid+'secp'))
        
        if secp == 'secp256k1':
            params = blind_demo.choose_parameters_secp256k1()
        elif secp == 'secp192k1':
            params = blind_demo.choose_parameters_secp192k1()
        
        orig_h = until.getObjFromSession(uid+'h_bytes',params.group)
        orig_g = until.getObjFromSession(uid+'g_bytes',params.group)
        issuerparams = blind_demo.issuer_choose_keypair(params.group,orig_g)
        x = issuerparams.x
        y = issuerparams.y
        
        until.putBytesToSession(uid+'x_bytes', x, params.group)
        until.putBytesToSession(uid+'y_bytes', y, params.group)

        print(y)
        
        z = blind_demo.gnerate_common_z(params.group, orig_g, orig_h, y)
        until.putBytesToSession(uid+'z_bytes',z, params.group)
        
        rjson = str(x) + "#" + str(y) + "#" + str(z)
        return rjson
    except Exception:
        return '0' 
Esempio n. 3
0
def userkey():
    try:
        uid = until.get_mac_address()
        secp = session.get(uid+'secp')
        print(session.get(uid+'secp'))
        print(secp)

        if secp == 'secp256k1':
            params = blind_demo.choose_parameters_secp256k1()
        elif secp == 'secp192k1':
            params = blind_demo.choose_parameters_secp192k1()

        orig_g = until.getObjFromSession(uid+'g_bytes',params.group)

        userparams = blind_demo.user_choose_keypair(params.group,orig_g)

        xi = userparams.xi
        gamma = userparams.gamma
        
        until.putBytesToSession(uid+'gamma_bytes',gamma, params.group)
        until.putBytesToSession(uid+'xi_bytes',xi, params.group)

        rjson = str(gamma) + '#' + str(xi)
        
        print(rjson)

        return rjson
    except Exception:
        return '0'
def getCred():
    try:

        uid = until.get_mac_address()
        print("-----------------")
        print(uid)
        print("-----------------")
        secp = session.get(uid + 'secp')

        if secp == 'secp256k1':
            params = blind_demo.choose_parameters_secp256k1()
        elif secp == 'secp192k1':
            params = blind_demo.choose_parameters_secp192k1()

        orig_y = until.getObjFromSession(uid + 'y_bytes', params.group)
        orig_zeta1 = until.getObjFromSession(uid + 'zeta1_bytes', params.group)
        orig_omega = until.getObjFromSession(uid + 'omega_bytes', params.group)
        orig_sigma1 = until.getObjFromSession(uid + 'sigma1_bytes',
                                              params.group)
        orig_sigma2 = until.getObjFromSession(uid + 'sigma2_bytes',
                                              params.group)
        orig_delta = until.getObjFromSession(uid + 'delta_bytes', params.group)
        orig_rho = until.getObjFromSession(uid + 'rho_bytes', params.group)

        m = session.get(uid + 'm')

        rjson = str(orig_y) + '#' + str(orig_zeta1) + '#' + str(
            orig_rho) + '#' + str(orig_omega) + '#' + str(
                orig_sigma1) + '#' + str(orig_sigma2) + '#' + str(
                    orig_delta) + '#' + str(m)

        return rjson
    except Exception as e:
        return "0"
def setParamsUser():
    try:
            
            secp = session.get('secp')
        
            if secp == 'secp256k1':
                params = blind_demo.choose_parameters_secp256k1()
            elif secp == 'secp192k1':
                params = blind_demo.choose_parameters_secp192k1()
            elif secp == 'secp160k1':
                params = blind_demo.choose_parameters_secp160k1()
           
            t1, t2, t3, t4, t5 = blind_demo.get_random_ZR(params.group),blind_demo.get_random_ZR(params.group),blind_demo.get_random_ZR(params.group),blind_demo.get_random_ZR(params.group),blind_demo.get_random_ZR(params.group)
            
            blind_demo.putBytesToSession('t1_bytes',t1, params.group)
            blind_demo.putBytesToSession('t2_bytes',t2, params.group)
            blind_demo.putBytesToSession('t3_bytes',t3, params.group)
            blind_demo.putBytesToSession('t4_bytes',t4, params.group)
            blind_demo.putBytesToSession('t5_bytes',t5, params.group)
            
            rjson = str(t1) + '#' + str(t2) + '#' + str(t3) + '#' + str(t4) + '#' + str(t5)
            
            return rjson
    except Exception as e:
        print(e)
        return "0"
def setParamsIssuer():
    try:
            
            secp = session.get('secp')
        
            if secp == 'secp256k1':
                params = blind_demo.choose_parameters_secp256k1()
            elif secp == 'secp192k1':
                params = blind_demo.choose_parameters_secp192k1()
            elif secp == 'secp160k1':
                params = blind_demo.choose_parameters_secp160k1()
           
            upsilon, mu, s1, s2, d = blind_demo.get_random_ZR(params.group),blind_demo.get_random_ZR(params.group),blind_demo.get_random_ZR(params.group),blind_demo.get_random_ZR(params.group),blind_demo.get_random_ZR(params.group)
            
            blind_demo.putBytesToSession('upsilon_bytes',upsilon, params.group)
            blind_demo.putBytesToSession('mu_bytes',mu, params.group)
            blind_demo.putBytesToSession('s1_bytes',s1, params.group)
            blind_demo.putBytesToSession('s2_bytes',s2, params.group)
            blind_demo.putBytesToSession('d_bytes',d, params.group)
            
            rjson = str(upsilon) + '#' + str(mu) + '#' + str(s1) + '#' + str(s2) + '#' + str(d)
            
            return rjson
    except Exception as e:
        print(e)
        return "0"
def getUserObj():
    try:
            
            secp = session.get('secp')
        
            if secp == 'secp256k1':
                params = blind_demo.choose_parameters_secp256k1()
            elif secp == 'secp192k1':
                params = blind_demo.choose_parameters_secp192k1()
            elif secp == 'secp160k1':
                params = blind_demo.choose_parameters_secp160k1()
            
            
            if session.get('g_bytes')!=None:
                orig_g = blind_demo.getObjFromSession('g_bytes',params.group)
            if session.get('h_bytes')!=None:
                orig_h = blind_demo.getObjFromSession('h_bytes',params.group)
            if session.get('z_bytes')!=None:
                orig_z = blind_demo.getObjFromSession('z_bytes',params.group)
            if session.get('gamma_bytes')!=None:
                orig_gamma = blind_demo.getObjFromSession('gamma_bytes',params.group)
            if session.get('xi_bytes')!=None:
                orig_xi = blind_demo.getObjFromSession('xi_bytes',params.group)
            
            if session.get('t1_bytes')!=None:
                orig_t1 = blind_demo.getObjFromSession('t1_bytes',params.group)
            if session.get('t2_bytes')!=None:
                orig_t2 = blind_demo.getObjFromSession('t2_bytes',params.group)
            if session.get('t3_bytes')!=None:
                orig_t3 = blind_demo.getObjFromSession('t3_bytes',params.group)
            if session.get('t4_bytes')!=None:
                orig_t4 = blind_demo.getObjFromSession('t4_bytes',params.group)
            if session.get('t5_bytes')!=None:
                orig_t5 = blind_demo.getObjFromSession('t5_bytes',params.group)
            if session.get('y_bytes')!=None:
                orig_y = blind_demo.getObjFromSession('y_bytes',params.group)
                
            print(4444444)
            
            
            user = blind_demo.User(orig_g,orig_h,orig_gamma,orig_xi,params)
            
            print(user)
            
            print(2222)
            
            print(orig_t1)
            print(orig_t2)
            print(orig_t3)
            print(orig_t4)
            print(orig_t5)
            print(orig_z)
            print(orig_y)
            
            user.start(orig_t1, orig_t2, orig_t3, orig_t4, orig_t5, orig_z, orig_y)
            
            return user
    except Exception:
        return None
Esempio n. 8
0
def setup():
    try:
        uid = until.get_mac_address()

        secp = str(request.form['secp'])

        (
            p,
            a,
            b,
            n,
            g,
            h
            ) = (
            0,
            0,
            0,
            0,
            None,
            None
            )

        if secp == 'secp256k1':
            params = blind_demo.choose_parameters_secp256k1()
            p = 115792089237316195423570985008687907853269984665640564039457584007908834671663
            a = 0
            b = 7
            n = 115792089237316195423570985008687907852837564279074904382605163141518161494337
            g = params.g
            h = params.h

        elif secp == 'secp192k1':

            params = blind_demo.choose_parameters_secp192k1()
            p = 6277101735386680763835789423207666416102355444459739541047
            a = 0
            b = 3
            n = 6277101735386680763835789423061264271957123915200845512077
            g = params.g
            h = params.h
            
        until.putBytesToSession(uid+'g_bytes', g, params.group)
        until.putBytesToSession(uid+'h_bytes', h, params.group)
        
        session[uid+'p'] = p
        session[uid+'a'] = a
        session[uid+'b'] = b
        session[uid+'n'] = n
        
        session[uid+'secp'] = secp
        print(session.get(uid+'secp'))

        rjson = str(p) + '#' + str(a) + '#' + str(b) + '#' + str(n) + '#' + str(g) + '#' + str(h)
        return rjson
    except Exception:
        return '0'
def verifyCred():
    try:
        uid = until.get_mac_address()
        secp = session.get(uid + 'secp')

        if secp == 'secp256k1':
            params = blind_demo.choose_parameters_secp256k1()
        elif secp == 'secp192k1':
            params = blind_demo.choose_parameters_secp192k1()

        m = session.get(uid + 'm')

        orig_y = until.getObjFromSession(uid + 'y_bytes', params.group)
        orig_zeta1 = until.getObjFromSession(uid + 'zeta1_bytes', params.group)
        orig_zeta2 = until.getObjFromSession(uid + 'zeta2_bytes', params.group)
        orig_omega = until.getObjFromSession(uid + 'omega_bytes', params.group)
        orig_sigma1 = until.getObjFromSession(uid + 'sigma1_bytes',
                                              params.group)
        orig_sigma2 = until.getObjFromSession(uid + 'sigma2_bytes',
                                              params.group)
        orig_delta = until.getObjFromSession(uid + 'delta_bytes', params.group)
        orig_rho = until.getObjFromSession(uid + 'rho_bytes', params.group)
        orig_z = until.getObjFromSession(uid + 'z_bytes', params.group)
        orig_g = until.getObjFromSession(uid + 'g_bytes', params.group)
        orig_h = until.getObjFromSession(uid + 'h_bytes', params.group)

        alpha_bytes = until.getObjFromSession(uid + 'alpha_bytes',
                                              params.group)
        beta1_bytes = until.getObjFromSession(uid + 'beta1_bytes',
                                              params.group)
        beta2_bytes = until.getObjFromSession(uid + 'beta2_bytes',
                                              params.group)
        print("alpha_bytes", alpha_bytes)
        print("beta1_bytes", beta1_bytes)
        print("beta2_bytes", beta2_bytes)

        lhs, rhs = blind_demo.verify(orig_rho, orig_omega, orig_delta,
                                     orig_sigma1, orig_sigma2, orig_h, orig_g,
                                     m, orig_y, orig_zeta1, orig_zeta2, orig_z,
                                     params)

        rjson = str(lhs) + ',' + str(rhs)

        return rjson
    except Exception as e:
        print(e)
        return "0"
Esempio n. 10
0
def issuing():
    uid = until.get_mac_address()
    secp = session.get(uid + 'secp')

    if secp == 'secp256k1':
        params = blind_demo.choose_parameters_secp256k1()
    elif secp == 'secp192k1':
        params = blind_demo.choose_parameters_secp192k1()

    yt = str(request.args.get('pk'))
    orig_y = until.point2Obj(int(yt), params.group)

    contractAddress = str(request.args.get('contractAddress'))
    until.putBytesToSession(uid + 'yt_bytes', orig_y, params.group)
    session[uid + 'cas'] = contractAddress

    return render_template('issuing.html')
Esempio n. 11
0
def getIssuerObj():
    try:
        uid = until.get_mac_address()
        secp = session.get(uid + 'secp')

        if secp == 'secp256k1':
            params = blind_demo.choose_parameters_secp256k1()
        elif secp == 'secp192k1':
            params = blind_demo.choose_parameters_secp192k1()

        orig_h = until.getObjFromSession(uid + 'h_bytes', params.group)
        orig_g = until.getObjFromSession(uid + 'g_bytes', params.group)
        orig_x = until.getObjFromSession(uid + 'x_bytes', params.group)
        orig_y = until.getObjFromSession(uid + 'y_bytes', params.group)
        orig_z = until.getObjFromSession(uid + 'z_bytes', params.group)

        issuer = blind_demo.Issuer(orig_g, orig_h, orig_x, orig_y, orig_z,
                                   params)

        print(issuer.parameters)
        """
            if session.get('upsilon_bytes')!=None:
                orig_upsilon = until.getObjFromSession('upsilon_bytes',params.group)
                
            if session.get('mu_bytes')!=None:
                orig_mu = until.getObjFromSession('mu_bytes',params.group)
                
            if session.get('d_bytes')!=None:
                orig_d = until.getObjFromSession('d_bytes',params.group)
                
            if session.get('s1_bytes')!=None:
                orig_s1 = until.getObjFromSession('s1_bytes',params.group)
                
            if session.get('s2_bytes')!=None:
                orig_s2 = until.getObjFromSession('s2_bytes',params.group)
            
            issuer.start(orig_z,orig_upsilon,orig_mu,orig_d,orig_s1,orig_s2)
            """

        return issuer
    except Exception:
        return None
Esempio n. 12
0
def getIssuerObj():
    try:
            
            secp = session.get('secp')
        
            if secp == 'secp256k1':
                params = blind_demo.choose_parameters_secp256k1()
            elif secp == 'secp192k1':
                params = blind_demo.choose_parameters_secp192k1()
            elif secp == 'secp160k1':
                params = blind_demo.choose_parameters_secp160k1()
            
            orig_h = blind_demo.getObjFromSession('h_bytes',params.group)
            orig_g = blind_demo.getObjFromSession('g_bytes',params.group)
            
            orig_x = blind_demo.getObjFromSession('x_bytes',params.group)
            orig_y = blind_demo.getObjFromSession('y_bytes',params.group)
            orig_z = blind_demo.getObjFromSession('z_bytes',params.group)
            
            if session.get('upsilon_bytes')!=None:
                orig_upsilon = blind_demo.getObjFromSession('upsilon_bytes',params.group)
                
            if session.get('mu_bytes')!=None:
                orig_mu = blind_demo.getObjFromSession('mu_bytes',params.group)
                
            if session.get('d_bytes')!=None:
                orig_d = blind_demo.getObjFromSession('d_bytes',params.group)
                
            if session.get('s1_bytes')!=None:
                orig_s1 = blind_demo.getObjFromSession('s1_bytes',params.group)
                
            if session.get('s2_bytes')!=None:
                orig_s2 = blind_demo.getObjFromSession('s2_bytes',params.group)
            
            issuer = blind_demo.Issuer(orig_g,orig_h,orig_x,orig_y,params)
            
            issuer.start(orig_z,orig_upsilon,orig_mu,orig_d,orig_s1,orig_s2)
            
            return issuer
    except Exception:
        return None
Esempio n. 13
0
def initgamma():
    try:
            
            secp = session.get('secp')
            print(secp)
        
            if secp == 'secp256k1':
                params = blind_demo.choose_parameters_secp256k1()
            elif secp == 'secp192k1':
                params = blind_demo.choose_parameters_secp192k1()
            elif secp == 'secp160k1':
                params = blind_demo.choose_parameters_secp160k1()
            
            orig_z = blind_demo.getObjFromSession('z_bytes',params.group)
            orig_zu = blind_demo.getObjFromSession('zu_bytes',params.group)
            orig_xi = blind_demo.getObjFromSession('xi_bytes',params.group)
            orig_gamma = blind_demo.getObjFromSession('gamma_bytes',params.group)
            orig_y = blind_demo.getObjFromSession('y_bytes',params.group)
            
            rjson1 = str(orig_gamma) + '#' + str(orig_xi) + '#' + str(orig_z) + '#' + str(orig_zu) + '#' + str(orig_y)
            
            
            orig_zu = blind_demo.getObjFromSession('zu_bytes',params.group)
            
            
            # protocol two
            orig_upsilon = blind_demo.getObjFromSession('upsilon_bytes',params.group)
            orig_mu = blind_demo.getObjFromSession('mu_bytes',params.group)
            orig_d = blind_demo.getObjFromSession('d_bytes',params.group)
            orig_s1 = blind_demo.getObjFromSession('s1_bytes',params.group)
            orig_s2 = blind_demo.getObjFromSession('s2_bytes',params.group)
            orig_z1 = blind_demo.getObjFromSession('z1_bytes',params.group)
            orig_z2 = blind_demo.getObjFromSession('z2_bytes',params.group)
            orig_a = blind_demo.getObjFromSession('a_bytes',params.group)
            orig_b1 = blind_demo.getObjFromSession('b1_bytes',params.group)
            orig_b2 = blind_demo.getObjFromSession('b2_bytes',params.group)
            
            rjson2 = str(orig_upsilon) + '#' + str(orig_mu) + '#' + str(orig_d) + '#' + str(orig_s1) + '#' + str(orig_s2) + '#' + str(orig_z1) + '#' + str(orig_z2) + '#' + str(orig_a)+ '#' + str(orig_b1)+ '#' + str(orig_b2)
            
            # protocol three
            
            orig_t1 = blind_demo.getObjFromSession('t1_bytes',params.group)
            orig_t2 = blind_demo.getObjFromSession('t2_bytes',params.group)
            orig_t3 = blind_demo.getObjFromSession('t3_bytes',params.group)
            orig_t4 = blind_demo.getObjFromSession('t4_bytes',params.group)
            orig_t5 = blind_demo.getObjFromSession('t5_bytes',params.group)
            
            orig_zeta1 = blind_demo.getObjFromSession('zeta1_bytes',params.group)
            orig_zeta2 = blind_demo.getObjFromSession('zeta2_bytes',params.group)
            orig_alpha = blind_demo.getObjFromSession('alpha_bytes',params.group)
            orig_beta1 = blind_demo.getObjFromSession('beta1_bytes',params.group)
            orig_beta2 = blind_demo.getObjFromSession('beta2_bytes',params.group)
            orig_epsilon = blind_demo.getObjFromSession('epsilon_bytes',params.group)
            orig_e = blind_demo.getObjFromSession('e_bytes',params.group)
            
            rjson3 = str(orig_t1) + '#' + str(orig_t2) + '#' + str(orig_t3) + '#' + str(orig_t4) + '#' + str(orig_t5) + '#' + str(orig_zeta1) + '#' + str(orig_zeta2) + '#' + str(orig_alpha)+ '#' + str(orig_b1)+ '#' + str(orig_beta1)+ '#' + str(orig_beta2)+ '#' + str(orig_epsilon)+ '#' + str(orig_e)

            rjson = rjson1 + '#' + rjson2 + '#' + rjson3
            
            # protocol four
            orig_c = blind_demo.getObjFromSession('c_bytes',params.group)
            orig_r = blind_demo.getObjFromSession('r_bytes',params.group)
            
            rjson4 = str(orig_c) + '#' + str(orig_r)
            
            # protocol five
            orig_rho = blind_demo.getObjFromSession('rho_bytes',params.group)
            orig_omega = blind_demo.getObjFromSession('omega_bytes',params.group)
            orig_sigma1 = blind_demo.getObjFromSession('sigma1_bytes',params.group)
            orig_sigma2 = blind_demo.getObjFromSession('sigma2_bytes',params.group)
            orig_delta = blind_demo.getObjFromSession('delta_bytes',params.group)
            
            rjson5 = str(orig_rho) + '#' + str(orig_omega) + '#' + str(orig_sigma1) + '#' + str(orig_sigma2) + '#' + str(orig_delta)
            
            rjson = rjson1 + '#' + rjson2 + '#' + rjson3 + '#' + rjson4 + '#' + rjson5
            
            
            m = session.get('m')
            if(m != None):
                m = m.decode('utf-8')
            else:
                m = 'None'
            
            rjson =  rjson + '#' + m
            
            contractAddress = session.get('cas')
            xiupsilon = session.get('xiupsilon')
            
            rjson = rjson + '#' + str(contractAddress) + '#' + str(xiupsilon)
            
            return rjson
    except Exception:
        return "0"