main_40.py 1015 B

1234567891011121314151617181920212223242526272829
  1. def test_localization_of_pseudonym(self):
  2. name = b" a 16 byte name "
  3. target = b"PEP3 storage_facility"
  4. pp = pep3_pb2.Pseudonymizable(data=name,
  5. state=pep3_pb2.Pseudonymizable.UNENCRYPTED_NAME)
  6. self.collector.pseudonymize([pp])
  7. self.collector.relocalize([pp],
  8. self.config.collector.warrants.to_sf)
  9. sfp = elgamal.Triple.unpack(pp.data) \
  10. .decrypt(self.sf.private_keys['pseudonym'])
  11. pseudonym_secrets = {}
  12. for peer_secrets in self.secrets.peers.values():
  13. for shard, shard_secrets in peer_secrets.by_shard.items():
  14. pseudonym_secrets[shard] \
  15. = shard_secrets.pseudonym_component_secret
  16. s = 1
  17. e = ed25519.scalar_unpack(common.sha256(target))
  18. for secret in pseudonym_secrets.values():
  19. s *= pow(ed25519.scalar_unpack(secret), e, ed25519.l)
  20. s %= ed25519.l
  21. self.assertEqual(
  22. sfp * ed25519.scalar_inv(s),
  23. ed25519.Point.lizard(name))