def test_localization_of_pseudonym(self): name = b" a 16 byte name " target = b"PEP3 storage_facility" pp = pep3_pb2.Pseudonymizable( data=name, state=pep3_pb2.Pseudonymizable.UNENCRYPTED_NAME) self.collector.pseudonymize([pp]) self.collector.relocalize([pp], self.config.collector.warrants.to_sf) sfp = elgamal.Triple.unpack(pp.data)\ .decrypt(self.sf.private_keys['pseudonym']) pseudonym_secrets = {} for peer_secrets in self.secrets.peers.values(): for shard, shard_secrets in peer_secrets.by_shard.items(): pseudonym_secrets[shard] \ = shard_secrets.pseudonym_component_secret s = 1 e = ed25519.scalar_unpack(common.sha256(target)) for secret in pseudonym_secrets.values(): s *= pow(ed25519.scalar_unpack(secret), e, ed25519.l) s %= ed25519.l self.assertEqual(sfp * ed25519.scalar_inv(s), ed25519.Point.lizard(name))
def test_rsk(self): N = 5 n = ed25519.scalar_random() k = ed25519.scalar_random() r = [ed25519.scalar_random() for i in range(N)] target = ed25519.Point.random() triples = [ elgamal.encrypt(ed25519.Point.random(), target) for i in range(N) ] pseudonyms = [pep3_pb2.Pseudonymizable() for i in range(N)] for i in range(N): pseudonyms[i].data = triples[i].pack() self.pu.rsk(pseudonyms, k, n, r) for i in range(N): triples[i] = triples[i].rsk(k, n, r[i]) self.assertEqual( [triples[i] for i in range(N)], [elgamal.Triple.unpack(pseudonyms[i].data) for i in range(N)])
def _process_raw_ips(self, batch): pseudonymizables = [] for raw_ip in batch: p = pep3_pb2.Pseudonymizable() p.data = raw_ip p.state = pep3_pb2.Pseudonymizable.UNENCRYPTED_NAME pseudonymizables.append(p) self.pep.pseudonymize(pseudonymizables) self.pep.relocalize(pseudonymizables, self.pep.config.warrants.to_sf) return [p for p in pseudonymizables]
def Depseudonymize(self, request, context): common.authenticate( context, must_be_one_of=[b"PEP3 " + self.pep.my_type_name.encode('utf-8')]) result = pep3_pb2.Pseudonymizable() self.pep.depseudonymize(request, result) return result
def _process_raw_ips(self, batch): pseudonymizables = [] for raw_ip in batch: p = pep3_pb2.Pseudonymizable() p.data = raw_ip p.state = pep3_pb2.Pseudonymizable.ENCRYPTED_PSEUDONYM pseudonymizables.append(p) self.sf.pep.decrypt(pseudonymizables, self.sf.pep.private_keys["pseudonym"]) return pseudonymizables