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'
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 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'
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 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
def issuerExecuteFour(): try: issuer = getIssuerObj() uid = until.get_mac_address() orig_e = until.getObjFromSession(uid + 'e_bytes', issuer.parameters.group) orig_d = until.getObjFromSession(uid + 'd_bytes', issuer.parameters.group) orig_mu = until.getObjFromSession(uid + 'mu_bytes', issuer.parameters.group) r, c = issuer.protocol_four(orig_e, orig_d, orig_mu) until.putBytesToSession(uid + 'r_bytes', r, issuer.parameters.group) until.putBytesToSession(uid + 'c_bytes', c, issuer.parameters.group) rjson = str(r) + '#' + str(c) return rjson except Exception as e: print(e) return "0"
def issuerExecuteSix(): try: uid = until.get_mac_address() contractAddress = session.get(uid + 'cas') issuer = getIssuerObj() orig_xi = until.getObjFromSession(uid + 'xi_bytes', issuer.parameters.group) orig_upsilon = until.getObjFromSession(uid + 'upsilon_bytes', issuer.parameters.group) xiupsilon = issuer.protocol_six(orig_xi, orig_upsilon) until.putBytesToSession(uid + 'xiupsilon_bytes', xiupsilon, issuer.parameters.group) rjson = str(orig_xi) + "#" + str(xiupsilon) + "#" + str( contractAddress) return rjson except Exception as e: print(e) return "0"
def issuerExecuteTwo(): try: issuer = getIssuerObj() uid = until.get_mac_address() print(issuer.parameters.group) orig_zu = until.getObjFromSession(uid + 'zu_bytes', issuer.parameters.group) orig_upsilon = until.getObjFromSession(uid + 'upsilon_bytes', issuer.parameters.group) orig_mu = until.getObjFromSession(uid + 'mu_bytes', issuer.parameters.group) orig_s1 = until.getObjFromSession(uid + 's1_bytes', issuer.parameters.group) orig_s2 = until.getObjFromSession(uid + 's2_bytes', issuer.parameters.group) orig_d = until.getObjFromSession(uid + 'd_bytes', issuer.parameters.group) #tracerparams = blind_demo.tracer_choose_keypair(issuer.parameters.group,issuer.g) #xt = tracerparams.yt #yt = tracerparams.yt #until.putBytesToSession('xt_bytes', xt, issuer.parameters.group) #until.putBytesToSession('yt_bytes', yt, issuer.parameters.group) orig_yt = until.getObjFromSession(uid + 'yt_bytes', issuer.parameters.group) z1, z2, a, b1, b2 = issuer.protocol_two(orig_yt, orig_upsilon, orig_zu, orig_mu, orig_s1, orig_s2, orig_d) until.putBytesToSession(uid + 'z1_bytes', z1, issuer.parameters.group) until.putBytesToSession(uid + 'z2_bytes', z2, issuer.parameters.group) until.putBytesToSession(uid + 'a_bytes', a, issuer.parameters.group) until.putBytesToSession(uid + 'b1_bytes', b1, issuer.parameters.group) until.putBytesToSession(uid + 'b2_bytes', b2, issuer.parameters.group) rjson = str(z1) + '#' + str(z2) + '#' + str(a) + '#' + str( b1) + '#' + str(b2) return rjson except Exception as e: print(e) 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"
def initgamma(): 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_z = until.getObjFromSession(uid + 'z_bytes', params.group) orig_zu = until.getObjFromSession(uid + 'zu_bytes', params.group) orig_xi = until.getObjFromSession(uid + 'xi_bytes', params.group) orig_gamma = until.getObjFromSession(uid + 'gamma_bytes', params.group) orig_y = until.getObjFromSession(uid + 'y_bytes', params.group) rjson1 = str(orig_gamma) + '#' + str(orig_xi) + '#' + str( orig_z) + '#' + str(orig_zu) + '#' + str(orig_y) orig_zu = until.getObjFromSession(uid + 'zu_bytes', params.group) # protocol two orig_upsilon = until.getObjFromSession(uid + 'upsilon_bytes', params.group) orig_mu = until.getObjFromSession(uid + 'mu_bytes', params.group) orig_d = until.getObjFromSession(uid + 'd_bytes', params.group) orig_s1 = until.getObjFromSession(uid + 's1_bytes', params.group) orig_s2 = until.getObjFromSession(uid + 's2_bytes', params.group) orig_z1 = until.getObjFromSession(uid + 'z1_bytes', params.group) orig_z2 = until.getObjFromSession(uid + 'z2_bytes', params.group) orig_a = until.getObjFromSession(uid + 'a_bytes', params.group) orig_b1 = until.getObjFromSession(uid + 'b1_bytes', params.group) orig_b2 = until.getObjFromSession(uid + '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 = until.getObjFromSession(uid + 't1_bytes', params.group) orig_t2 = until.getObjFromSession(uid + 't2_bytes', params.group) orig_t3 = until.getObjFromSession(uid + 't3_bytes', params.group) orig_t4 = until.getObjFromSession(uid + 't4_bytes', params.group) orig_t5 = until.getObjFromSession(uid + 't5_bytes', params.group) orig_zeta1 = until.getObjFromSession(uid + 'zeta1_bytes', params.group) orig_zeta2 = until.getObjFromSession(uid + 'zeta2_bytes', params.group) orig_alpha = until.getObjFromSession(uid + 'alpha_bytes', params.group) orig_beta1 = until.getObjFromSession(uid + 'beta1_bytes', params.group) orig_beta2 = until.getObjFromSession(uid + 'beta2_bytes', params.group) orig_epsilon = until.getObjFromSession(uid + 'epsilon_bytes', params.group) orig_e = until.getObjFromSession(uid + '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) # protocol four orig_c = until.getObjFromSession(uid + 'c_bytes', params.group) orig_r = until.getObjFromSession(uid + 'r_bytes', params.group) rjson4 = str(orig_c) + '#' + str(orig_r) # protocol five orig_rho = until.getObjFromSession(uid + 'rho_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) 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(uid + 'cas') orig_xiupsilon = until.getObjFromSession(uid + 'xiupsilon_bytes', params.group) rjson = rjson + '#' + str(contractAddress) + '#' + str(orig_xiupsilon) return rjson except Exception: return "0"