Example #1
0
class CardinalityEfficientTestCase(unittest.TestCase):
    def setUp(self):
        self.scheme = CardinalityEfficient()
        self.scheme.client_count = 5
        self.shared_elements = generate_set(3)
        self.sets = [generate_set(2) for _ in range(self.scheme.client_count)]

    def test_parameters(self):
        m, k = CardinalityEfficient.determine_parameters(max_elements=1000, error_rate=0.001)
        self.assertEqual(m, 14378)
        self.assertEqual(k, 10)

    def test_correctness(self):
        pt_sets = [self.shared_elements | self.sets[i]
                for i in range(self.scheme.client_count)]
        set_sizes = len(pt_sets[0])
        m, k = CardinalityEfficient.determine_parameters(max_elements=set_sizes, error_rate=0.001)
        usks = self.scheme.setup(128, self.scheme.client_count, m, k)
        gid = (1).to_bytes(16, 'big')
        ct_sets = [self.scheme.encrypt(usks[i], gid, pt_sets[i])
                for i in range(self.scheme.client_count)]

        pt_cardinality = len(pt_sets[0].intersection(*pt_sets))
        ct_cardinality = self.scheme.eval(ct_sets)

        self.assertEqual(pt_cardinality, ct_cardinality)
Example #2
0
    def setUp(self, scenario):
        self.scheme = CardinalityEfficient()
        self.scheme.client_count = 5
        super().setUp(scenario)
        self.m, self.k = CardinalityEfficient.determine_parameters(
            max_elements=scenario, error_rate=0.001)

        self.usks = self.scheme.setup(self.secpar, self.scheme.client_count,
                                      self.m, self.k)
        self.default_cases()
Example #3
0
class MCCardinalityEfficient5Evaluation(MCEvaluationCase):
    def setUp(self, scenario):
        self.scheme = CardinalityEfficient()
        self.scheme.client_count = 5
        super().setUp(scenario)
        self.m, self.k = CardinalityEfficient.determine_parameters(
            max_elements=scenario, error_rate=0.001)

        self.usks = self.scheme.setup(self.secpar, self.scheme.client_count,
                                      self.m, self.k)
        self.default_cases()

    def evaluate_setup(self):
        usks = self.scheme.setup(self.secpar, self.scheme.client_count, self.m,
                                 self.k)

    def evaluate_encrypt(self):
        # takes a long time and we don't care
        pass
Example #4
0
    def test_correctness(self):
        pt_sets = [self.shared_elements | self.sets[i]
                for i in range(self.scheme.client_count)]
        set_sizes = len(pt_sets[0])
        m, k = CardinalityEfficient.determine_parameters(max_elements=set_sizes, error_rate=0.001)
        usks = self.scheme.setup(128, self.scheme.client_count, m, k)
        gid = (1).to_bytes(16, 'big')
        ct_sets = [self.scheme.encrypt(usks[i], gid, pt_sets[i])
                for i in range(self.scheme.client_count)]

        pt_cardinality = len(pt_sets[0].intersection(*pt_sets))
        ct_cardinality = self.scheme.eval(ct_sets)

        self.assertEqual(pt_cardinality, ct_cardinality)
Example #5
0
 def test_parameters(self):
     m, k = CardinalityEfficient.determine_parameters(max_elements=1000, error_rate=0.001)
     self.assertEqual(m, 14378)
     self.assertEqual(k, 10)
Example #6
0
 def setUp(self):
     self.scheme = CardinalityEfficient()
     self.scheme.client_count = 5
     self.shared_elements = generate_set(3)
     self.sets = [generate_set(2) for _ in range(self.scheme.client_count)]