def eddsa_gen(): print("test_eddsa_gen...") clientObj = mpc_crypto.Eddsa(CLIENT) serverObj = mpc_crypto.Eddsa(SERVER) clientObj.initGenerate() serverObj.initGenerate() exec_client_server(clientObj, serverObj) print(" ok") return clientObj, serverObj
def run_eddsa_gen(): print("Generating EDDSA key...") eddsaObj = mpc_crypto.Eddsa(peer) eddsaObj.initGenerate() exec_mpc_exchange(eddsaObj) print(" ok") return eddsaObj
def run_getpubkey(inShare, cryptoType): print("Getting public key...") if cryptoType == 'ECDSA': obj = mpc_crypto.Ecdsa(peer, inShare) elif cryptoType == 'EDDSA': obj = mpc_crypto.Eddsa(peer, inShare) else: sys.exit("getpubkey not supported for " + cryptoType) with obj: pk = obj.getPublic() print("ok") return pk
def run_generate(): print("Generating key...") if args.type == 'EDDSA': obj = mpc_crypto.Eddsa(peer) obj.initGenerate() elif args.type == 'ECDSA': obj = mpc_crypto.Ecdsa(peer) obj.initGenerate() elif args.type == 'generic': obj = mpc_crypto.GenericSecret(peer) obj.initGenerate(args.size) else: sys.exit("Generate not supported for " + args.type) with obj: exec_mpc_exchange(obj) print(" ok") return obj.exportShare()
def run_sign(inShare): print(args.type + " signing...") if args.type == 'ECDSA': obj = mpc_crypto.Ecdsa(peer, inShare) elif args.type == 'EDDSA': obj = mpc_crypto.Eddsa(peer, inShare) else: sys.exit("Sign not supported for " + args.type) if not args.data_file: sys.exit("Input data missing") with open(args.data_file, "rb") as f: inData = f.read() with obj: obj.initSign(inData, True) exec_mpc_exchange(obj) sig = obj.getSignResult() print("ok") return sig
def run_get_public(inShare, cryptoType): print(cryptoType + " get_public...") if not args.data_file: sys.exit("Input data missing") with open(args.data_file, "rb") as f: inData = f.read() if cryptoType == 'ECDSA': if len(inData) > 32: sys.exit( "Input too long. Data should be hashed before ECDSA signing.") obj = mpc_crypto.Ecdsa(peer, inShare) elif cryptoType == 'EDDSA': obj = mpc_crypto.Eddsa(peer, inShare) else: sys.exit("Sign not supported for " + cryptoType) with obj: # sig = bytes(mpc_crypto.serializePubBIP32(obj.share), 'utf-8') sig = bytes(obj.get_public().hex(), 'utf-8') print("ok", sig) return sig
def run_sign(inShare, cryptoType): print(cryptoType + " signing...") if not args.data_file: sys.exit("Input data missing") with open(args.data_file, "rb") as f: inData = f.read() if cryptoType == 'ECDSA': if len(inData) > 32: sys.exit( "Input too long. Data should be hashed before ECDSA signing.") obj = mpc_crypto.Ecdsa(peer, inShare) elif cryptoType == 'EDDSA': obj = mpc_crypto.Eddsa(peer, inShare) else: sys.exit("Sign not supported for " + cryptoType) with obj: obj.initSign(inData) exec_mpc_exchange(obj) sig = bytes(obj.getSignResult().hex(), 'utf-8') print("ok", sig) return sig
def run_verify(inShare, cryptoType): print("Verifying...") if not args.data_file: sys.exit("Input data missing") with open(args.data_file, "r") as f: filecontent = f.read() inData = bytes.fromhex(filecontent) if not args.sig_file: sys.exit("Signature file missing") with open(args.sig_file, "rb") as f: sigData = f.read() if cryptoType == 'ECDSA': obj = mpc_crypto.Ecdsa(peer, inShare) elif cryptoType == 'EDDSA': obj = mpc_crypto.Eddsa(peer, inShare) else: sys.exit("verify not supported for " + cryptoType) with obj: obj.verify(inData, sigData) print("ok") return 1