Beispiel #1
0
    def obfuscate(self,
                  circuit,
                  secparam,
                  directory,
                  obliviate=False,
                  nslots=None,
                  kappa=None):
        start = time.time()

        self._remove_old(directory)
        if nslots is None:
            nslots = secparam

        # create a dummy branching program to determine parameters
        bp = SZBranchingProgram(circuit,
                                verbose=self._verbose,
                                obliviate=obliviate)
        if not kappa:
            kappa = len(bp)
        nzs = bp.set_straddling_sets()

        primes = self._gen_mlm_params(secparam, kappa, 0, nzs, directory)
        bps = self._construct_bps(SZBranchingProgram, nslots, circuit, primes,
                                  obliviate)
        self._randomize(secparam, bps, primes)
        self._obfuscate(bps, len(primes))

        end = time.time()
        self.logger('Obfuscation took: %f' % (end - start))
        if self._verbose:
            _obf.max_mem_usage()
Beispiel #2
0
    def obfuscate(self, fname, secparam, directory, obliviate=False,
                  nslots=None, kappa=None, formula=True):
        start = time.time()

        self._remove_old(directory)
        if nslots is None:
            nslots = secparam

        # create a dummy branching program to determine parameters
        bp = SZBranchingProgram(fname, verbose=self._verbose,
                                obliviate=obliviate, formula=formula)
        nzs = bp.set_straddling_sets()
        if not kappa:
            kappa = nzs

        primes = self._gen_mlm_params(secparam, kappa, 0, nzs, directory)
        bps = self._construct_bps(SZBranchingProgram, nslots, fname, primes,
                                  obliviate, formula=formula)
        self._randomize(secparam, bps, primes)
        self._obfuscate(bps, len(primes))

        _obf.wait(self._state)
        if self._verbose:
            _obf.max_mem_usage()

        end = time.time()
        self.logger('Obfuscation took: %f' % (end - start))
    def obfuscate(self, circuit, secparam, directory, obliviate=False,
                  nslots=None, kappa=None):
        start = time.time()

        self._remove_old(directory)
        if nslots is None:
            nslots = secparam

        # create a dummy branching program to determine parameters
        bp = AGISBranchingProgram(circuit, verbose=self._verbose,
                                  obliviate=obliviate)
        # add two to kappa due to the bookend vectors
        if not kappa:
            kappa = len(bp) + 2
        # construct straddling sets, and add two to the number of Zs to take
        # bookend vectors into account
        nzs = bp.set_straddling_sets() + 2
        # width is the column/row-length of the matrices
        width = bp.size

        primes = self._gen_mlm_params(secparam, kappa, width, nzs, directory)
        bps = self._construct_bps(AGISBranchingProgram, nslots, circuit,
                                  primes, obliviate)
        self._randomize(secparam, bps, primes)
        self._construct_bookend_vectors(bps, primes, nzs)
        self._obfuscate(bps, len(primes))

        end = time.time()
        self.logger('Obfuscation took: %f' % (end - start))
        if self._verbose:
            _obf.max_mem_usage()
    def obfuscate(self,
                  circuit,
                  secparam,
                  directory,
                  obliviate=False,
                  nslots=None,
                  kappa=None):
        start = time.time()

        self._remove_old(directory)
        if nslots is None:
            nslots = secparam

        # create a dummy branching program to determine parameters
        bp = AGISBranchingProgram(circuit,
                                  verbose=self._verbose,
                                  obliviate=obliviate)
        # add two to kappa due to the bookend vectors
        if not kappa:
            kappa = len(bp) + 2
        # construct straddling sets, and add two to the number of Zs to take
        # bookend vectors into account
        nzs = bp.set_straddling_sets() + 2
        # width is the column/row-length of the matrices
        width = bp.size

        primes = self._gen_mlm_params(secparam, kappa, width, nzs, directory)
        bps = self._construct_bps(AGISBranchingProgram, nslots, circuit,
                                  primes, obliviate)
        self._randomize(secparam, bps, primes)
        self._construct_bookend_vectors(bps, primes, nzs)
        self._obfuscate(bps, len(primes))

        end = time.time()
        self.logger('Obfuscation took: %f' % (end - start))
        if self._verbose:
            _obf.max_mem_usage()