from __future__ import print_function from circuit import ParseException from sage.all import random_prime import utils from mpi4py import MPI __all__ = ['test_circuit'] failstr = utils.clr_error('Fail') def test_obfuscation(path, cls, testcases, args): success = True obf = cls(verbose=args.verbose, nthreads=args.nthreads) directory = args.save if args.save \ else '%s.obf.%d' % (path, args.secparam) obf.obfuscate(path, args.secparam, directory, obliviate=args.obliviate, nslots=args.nslots, kappa=args.kappa) comm = MPI.COMM_WORLD rank = comm.Get_rank() if rank == 0: for k, v in testcases.items(): if obf.evaluate(directory, k) != v: print('%s (%s != %d) ' % (failstr, k, v)) success = False return success
from __future__ import print_function from circuit import ParseException from sage.all import random_prime import utils from mpi4py import MPI __all__ = ['test_circuit'] failstr = utils.clr_error('Fail') def test_obfuscation(path, cls, testcases, args): success = True obf = cls(verbose=args.verbose, nthreads=args.nthreads) directory = args.save if args.save \ else '%s.obf.%d' % (path, args.secparam) obf.obfuscate(path, args.secparam, directory, obliviate=args.obliviate, nslots=args.nslots, kappa=args.kappa) comm = MPI.COMM_WORLD rank = comm.Get_rank() if rank==0: for k, v in testcases.items(): if obf.evaluate(directory, k) != v: print('%s (%s != %d) ' % (failstr, k, v)) success = False return success def test_bp(path, cls, testcases, args): success = True try:
from __future__ import print_function from test import test_circuit from circuit import ParseException import argparse, os, sys, time import utils __all__ = ['main'] errorstr = utils.clr_error('Error:') def test_all(args, bpclass, obfclass, obfuscate): if not os.path.isdir(args.test_all): print("%s '%s' is not a valid directory" % (errorstr, args.test_all)) sys.exit(1) ext = '.acirc' if args.zimmerman else '.circ' for circuit in os.listdir(args.test_all): path = os.path.join(args.test_all, circuit) if os.path.isfile(path) and path.endswith(ext): test_circuit(path, bpclass, obfclass, obfuscate, args) def check_args(args): num_set = int(args.ananth_etal) + int(args.sahai_zhandry) + int(args.zimmerman) if num_set > 1: print('%s Only one of --ananth-etal, --sahai-zhandry, --zimmerman can be set' % errorstr) sys.exit(1) if num_set == 0: args.ananth_etal = True def bp(args):
from __future__ import print_function from test import test_circuit from circuit import ParseException import argparse, os, sys, time import utils __all__ = ['main'] errorstr = utils.clr_error('Error:') def test_all(args, bpclass, obfclass, obfuscate): if not os.path.isdir(args.test_all): print("%s '%s' is not a valid directory" % (errorstr, args.test_all)) sys.exit(1) ext = '.acirc' if args.zimmerman else '.circ' for circuit in os.listdir(args.test_all): path = os.path.join(args.test_all, circuit) if os.path.isfile(path) and path.endswith(ext): test_circuit(path, bpclass, obfclass, obfuscate, args) def check_args(args): num_set = int(args.ananth_etal) + int(args.sahai_zhandry) + int( args.zimmerman) if num_set > 1: print( '%s Only one of --ananth-etal, --sahai-zhandry, --zimmerman can be set' % errorstr)