-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiferential_priv_pysyft_intro.py
66 lines (42 loc) · 1.63 KB
/
diferential_priv_pysyft_intro.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import sys
import pytest
import torch as th
import syft as sy
from syft.core.node.common.service.auth import AuthorizationException
sy.LOG_FILE = "syft_do.log"
sy.logger.remove()
_ = sy.logger.add(sys.stdout, level="DEBUG")
x = th.tensor([1,2,3,4,5])
print(x)
somedevice = sy.Device()
# print(somedevice.name, somedevice.id, somedevice.address)
# print(somedevice.address.vm, somedevice.address.device, somedevice.address.domain, somedevice.address.network)
# print(somedevice.address.target_id)
# print(somedevice.address.target_id.pprint)
# print(somedevice.address.pprint)
bob_device = sy.Device(name="Bob's iPhone")
assert bob_device.name == "Bob's iPhone"
bob_device_client = bob_device.get_client()
msg = sy.ReprMessage(address=bob_device_client.address)
print(msg.pprint)
print(bob_device_client.address.pprint)
assert msg.address == bob_device_client.address
with pytest.raises(AuthorizationException):
bob_device_client.send_immediate_msg_without_reply(
msg=sy.ReprMessage(address=bob_device_client.address)
)
print(bob_device_client.keys)
print(bob_device.keys)
assert bob_device_client.verify_key != bob_device.root_verify_key
bob_device_client = bob_device.get_root_client()
# repr_service.py
# class ReprService(ImmediateNodeServiceWithoutReply):
# @staticmethod
# @service_auth(root_only=True)
bob_vm = sy.VirtualMachine(name="Bob's VM")
bob_vm_client = bob_vm.get_root_client()
bob_device_client.register(client=bob_vm_client)
bob_domain = sy.Domain(name="Bob's Domain")
bob_domain_client = bob_domain.get_root_client()
print(bob_domain.address.pprint)
bob_domain_client.register(client=bob_device_client)