flwr-nightly 1.15.0.dev20250124__py3-none-any.whl → 1.15.0.dev20250125__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
flwr/server/app.py CHANGED
@@ -31,12 +31,8 @@ from typing import Any, Optional
31
31
 
32
32
  import grpc
33
33
  import yaml
34
- from cryptography.exceptions import UnsupportedAlgorithm
35
34
  from cryptography.hazmat.primitives.asymmetric import ec
36
- from cryptography.hazmat.primitives.serialization import (
37
- load_ssh_private_key,
38
- load_ssh_public_key,
39
- )
35
+ from cryptography.hazmat.primitives.serialization import load_ssh_public_key
40
36
 
41
37
  from flwr.common import GRPC_MAX_MESSAGE_LENGTH, EventType, event
42
38
  from flwr.common.address import parse_address
@@ -64,7 +60,6 @@ from flwr.common.exit_handlers import register_exit_handlers
64
60
  from flwr.common.grpc import generic_create_grpc_server
65
61
  from flwr.common.logger import log, warn_deprecated_feature
66
62
  from flwr.common.secure_aggregation.crypto.symmetric_encryption import (
67
- private_key_to_bytes,
68
63
  public_key_to_bytes,
69
64
  )
70
65
  from flwr.proto.fleet_pb2_grpc import ( # pylint: disable=E0611
@@ -378,21 +373,12 @@ def run_superlink() -> None:
378
373
  fleet_thread.start()
379
374
  bckg_threads.append(fleet_thread)
380
375
  elif args.fleet_api_type == TRANSPORT_TYPE_GRPC_RERE:
381
- maybe_keys = _try_setup_node_authentication(args, certificates)
376
+ node_public_keys = _try_load_public_keys_node_authentication(args)
382
377
  interceptors: Optional[Sequence[grpc.ServerInterceptor]] = None
383
- if maybe_keys is not None:
384
- (
385
- node_public_keys,
386
- server_private_key,
387
- server_public_key,
388
- ) = maybe_keys
378
+ if node_public_keys is not None:
389
379
  state = state_factory.state()
390
- state.clear_supernode_auth_keys_and_credentials()
380
+ state.clear_supernode_auth_keys()
391
381
  state.store_node_public_keys(node_public_keys)
392
- state.store_server_private_public_key(
393
- private_key_to_bytes(server_private_key),
394
- public_key_to_bytes(server_public_key),
395
- )
396
382
  log(
397
383
  INFO,
398
384
  "Node authentication enabled with %d known public keys",
@@ -541,34 +527,20 @@ def _format_address(address: str) -> tuple[str, str, int]:
541
527
  return (f"[{host}]:{port}" if is_v6 else f"{host}:{port}", host, port)
542
528
 
543
529
 
544
- def _try_setup_node_authentication(
530
+ def _try_load_public_keys_node_authentication(
545
531
  args: argparse.Namespace,
546
- certificates: Optional[tuple[bytes, bytes, bytes]],
547
- ) -> Optional[tuple[set[bytes], ec.EllipticCurvePrivateKey, ec.EllipticCurvePublicKey]]:
548
- if (
549
- not args.auth_list_public_keys
550
- and not args.auth_superlink_private_key
551
- and not args.auth_superlink_public_key
552
- ):
553
- return None
554
-
555
- if (
556
- not args.auth_list_public_keys
557
- or not args.auth_superlink_private_key
558
- or not args.auth_superlink_public_key
559
- ):
560
- sys.exit(
561
- "Authentication requires providing file paths for "
562
- "'--auth-list-public-keys', '--auth-superlink-private-key' and "
563
- "'--auth-superlink-public-key'. Provide all three to enable authentication."
532
+ ) -> Optional[set[bytes]]:
533
+ """Return a set of node public keys."""
534
+ if args.auth_superlink_private_key or args.auth_superlink_public_key:
535
+ log(
536
+ WARN,
537
+ "The `--auth-superlink-private-key` and `--auth-superlink-public-key` "
538
+ "arguments are deprecated and will be removed in a future release. Node "
539
+ "authentication no longer requires these arguments.",
564
540
  )
565
541
 
566
- if certificates is None:
567
- sys.exit(
568
- "Authentication requires secure connections. "
569
- "Please provide certificate paths to `--ssl-certfile`, "
570
- "`--ssl-keyfile`, and `—-ssl-ca-certfile` and try again."
571
- )
542
+ if not args.auth_list_public_keys:
543
+ return None
572
544
 
573
545
  node_keys_file_path = Path(args.auth_list_public_keys)
574
546
  if not node_keys_file_path.exists():
@@ -581,35 +553,6 @@ def _try_setup_node_authentication(
581
553
 
582
554
  node_public_keys: set[bytes] = set()
583
555
 
584
- try:
585
- ssh_private_key = load_ssh_private_key(
586
- Path(args.auth_superlink_private_key).read_bytes(),
587
- None,
588
- )
589
- if not isinstance(ssh_private_key, ec.EllipticCurvePrivateKey):
590
- raise ValueError()
591
- except (ValueError, UnsupportedAlgorithm):
592
- sys.exit(
593
- "Error: Unable to parse the private key file in "
594
- "'--auth-superlink-private-key'. Authentication requires elliptic "
595
- "curve private and public key pair. Please ensure that the file "
596
- "path points to a valid private key file and try again."
597
- )
598
-
599
- try:
600
- ssh_public_key = load_ssh_public_key(
601
- Path(args.auth_superlink_public_key).read_bytes()
602
- )
603
- if not isinstance(ssh_public_key, ec.EllipticCurvePublicKey):
604
- raise ValueError()
605
- except (ValueError, UnsupportedAlgorithm):
606
- sys.exit(
607
- "Error: Unable to parse the public key file in "
608
- "'--auth-superlink-public-key'. Authentication requires elliptic "
609
- "curve private and public key pair. Please ensure that the file "
610
- "path points to a valid public key file and try again."
611
- )
612
-
613
556
  with open(node_keys_file_path, newline="", encoding="utf-8") as csvfile:
614
557
  reader = csv.reader(csvfile)
615
558
  for row in reader:
@@ -623,11 +566,7 @@ def _try_setup_node_authentication(
623
566
  "file. Please ensure that the CSV file path points to a valid "
624
567
  "known SSH public keys files and try again."
625
568
  )
626
- return (
627
- node_public_keys,
628
- ssh_private_key,
629
- ssh_public_key,
630
- )
569
+ return node_public_keys
631
570
 
632
571
 
633
572
  def _try_obtain_exec_auth_plugin(
@@ -840,12 +779,12 @@ def _add_args_common(parser: argparse.ArgumentParser) -> None:
840
779
  parser.add_argument(
841
780
  "--auth-superlink-private-key",
842
781
  type=str,
843
- help="The SuperLink's private key (as a path str) to enable authentication.",
782
+ help="This argument is deprecated and will be removed in a future release.",
844
783
  )
845
784
  parser.add_argument(
846
785
  "--auth-superlink-public-key",
847
786
  type=str,
848
- help="The SuperLink's public key (as a path str) to enable authentication.",
787
+ help="This argument is deprecated and will be removed in a future release.",
849
788
  )
850
789
 
851
790
 
@@ -74,8 +74,6 @@ class InMemoryLinkState(LinkState): # pylint: disable=R0902,R0904
74
74
  self.task_ins_id_to_task_res_id: dict[UUID, UUID] = {}
75
75
 
76
76
  self.node_public_keys: set[bytes] = set()
77
- self.server_public_key: Optional[bytes] = None
78
- self.server_private_key: Optional[bytes] = None
79
77
 
80
78
  self.lock = threading.RLock()
81
79
 
@@ -403,30 +401,9 @@ class InMemoryLinkState(LinkState): # pylint: disable=R0902,R0904
403
401
  log(ERROR, "Unexpected run creation failure.")
404
402
  return 0
405
403
 
406
- def store_server_private_public_key(
407
- self, private_key: bytes, public_key: bytes
408
- ) -> None:
409
- """Store `server_private_key` and `server_public_key` in the link state."""
404
+ def clear_supernode_auth_keys(self) -> None:
405
+ """Clear stored `node_public_keys` in the link state if any."""
410
406
  with self.lock:
411
- if self.server_private_key is None and self.server_public_key is None:
412
- self.server_private_key = private_key
413
- self.server_public_key = public_key
414
- else:
415
- raise RuntimeError("Server private and public key already set")
416
-
417
- def get_server_private_key(self) -> Optional[bytes]:
418
- """Retrieve `server_private_key` in urlsafe bytes."""
419
- return self.server_private_key
420
-
421
- def get_server_public_key(self) -> Optional[bytes]:
422
- """Retrieve `server_public_key` in urlsafe bytes."""
423
- return self.server_public_key
424
-
425
- def clear_supernode_auth_keys_and_credentials(self) -> None:
426
- """Clear stored `node_public_keys` and credentials in the link state if any."""
427
- with self.lock:
428
- self.server_private_key = None
429
- self.server_public_key = None
430
407
  self.node_public_keys.clear()
431
408
 
432
409
  def store_node_public_keys(self, public_keys: set[bytes]) -> None:
@@ -264,22 +264,8 @@ class LinkState(abc.ABC): # pylint: disable=R0904
264
264
  """
265
265
 
266
266
  @abc.abstractmethod
267
- def store_server_private_public_key(
268
- self, private_key: bytes, public_key: bytes
269
- ) -> None:
270
- """Store `server_private_key` and `server_public_key` in the link state."""
271
-
272
- @abc.abstractmethod
273
- def get_server_private_key(self) -> Optional[bytes]:
274
- """Retrieve `server_private_key` in urlsafe bytes."""
275
-
276
- @abc.abstractmethod
277
- def get_server_public_key(self) -> Optional[bytes]:
278
- """Retrieve `server_public_key` in urlsafe bytes."""
279
-
280
- @abc.abstractmethod
281
- def clear_supernode_auth_keys_and_credentials(self) -> None:
282
- """Clear stored `node_public_keys` and credentials in the link state if any."""
267
+ def clear_supernode_auth_keys(self) -> None:
268
+ """Clear stored `node_public_keys` in the link state if any."""
283
269
 
284
270
  @abc.abstractmethod
285
271
  def store_node_public_keys(self, public_keys: set[bytes]) -> None:
@@ -71,13 +71,6 @@ CREATE TABLE IF NOT EXISTS node(
71
71
  );
72
72
  """
73
73
 
74
- SQL_CREATE_TABLE_CREDENTIAL = """
75
- CREATE TABLE IF NOT EXISTS credential(
76
- private_key BLOB PRIMARY KEY,
77
- public_key BLOB
78
- );
79
- """
80
-
81
74
  SQL_CREATE_TABLE_PUBLIC_KEY = """
82
75
  CREATE TABLE IF NOT EXISTS public_key(
83
76
  public_key BLOB PRIMARY KEY
@@ -208,7 +201,6 @@ class SqliteLinkState(LinkState): # pylint: disable=R0904
208
201
  cur.execute(SQL_CREATE_TABLE_TASK_INS)
209
202
  cur.execute(SQL_CREATE_TABLE_TASK_RES)
210
203
  cur.execute(SQL_CREATE_TABLE_NODE)
211
- cur.execute(SQL_CREATE_TABLE_CREDENTIAL)
212
204
  cur.execute(SQL_CREATE_TABLE_PUBLIC_KEY)
213
205
  cur.execute(SQL_CREATE_INDEX_ONLINE_UNTIL)
214
206
  res = cur.execute("SELECT name FROM sqlite_schema;")
@@ -773,46 +765,9 @@ class SqliteLinkState(LinkState): # pylint: disable=R0904
773
765
  log(ERROR, "Unexpected run creation failure.")
774
766
  return 0
775
767
 
776
- def store_server_private_public_key(
777
- self, private_key: bytes, public_key: bytes
778
- ) -> None:
779
- """Store `server_private_key` and `server_public_key` in the link state."""
780
- query = "SELECT COUNT(*) FROM credential"
781
- count = self.query(query)[0]["COUNT(*)"]
782
- if count < 1:
783
- query = (
784
- "INSERT OR REPLACE INTO credential (private_key, public_key) "
785
- "VALUES (:private_key, :public_key)"
786
- )
787
- self.query(query, {"private_key": private_key, "public_key": public_key})
788
- else:
789
- raise RuntimeError("Server private and public key already set")
790
-
791
- def get_server_private_key(self) -> Optional[bytes]:
792
- """Retrieve `server_private_key` in urlsafe bytes."""
793
- query = "SELECT private_key FROM credential"
794
- rows = self.query(query)
795
- try:
796
- private_key: Optional[bytes] = rows[0]["private_key"]
797
- except IndexError:
798
- private_key = None
799
- return private_key
800
-
801
- def get_server_public_key(self) -> Optional[bytes]:
802
- """Retrieve `server_public_key` in urlsafe bytes."""
803
- query = "SELECT public_key FROM credential"
804
- rows = self.query(query)
805
- try:
806
- public_key: Optional[bytes] = rows[0]["public_key"]
807
- except IndexError:
808
- public_key = None
809
- return public_key
810
-
811
- def clear_supernode_auth_keys_and_credentials(self) -> None:
812
- """Clear stored `node_public_keys` and credentials in the link state if any."""
813
- queries = ["DELETE FROM public_key;", "DELETE FROM credential;"]
814
- for query in queries:
815
- self.query(query)
768
+ def clear_supernode_auth_keys(self) -> None:
769
+ """Clear stored `node_public_keys` in the link state if any."""
770
+ self.query("DELETE FROM public_key;")
816
771
 
817
772
  def store_node_public_keys(self, public_keys: set[bytes]) -> None:
818
773
  """Store a set of `node_public_keys` in the link state."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flwr-nightly
3
- Version: 1.15.0.dev20250124
3
+ Version: 1.15.0.dev20250125
4
4
  Summary: Flower: A Friendly Federated AI Framework
5
5
  Home-page: https://flower.ai
6
6
  License: Apache-2.0
@@ -215,7 +215,7 @@ flwr/proto/transport_pb2_grpc.py,sha256=Nvn7oxzm1g1fPiGCGhyKxILDZHYG0CcgjySTzxq-
215
215
  flwr/proto/transport_pb2_grpc.pyi,sha256=AGXf8RiIiW2J5IKMlm_3qT3AzcDa4F3P5IqUjve_esA,766
216
216
  flwr/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
217
217
  flwr/server/__init__.py,sha256=cEg1oecBu4cKB69iJCqWEylC8b5XW47bl7rQiJsdTvM,1528
218
- flwr/server/app.py,sha256=7Ru-udfJDLU3VHa47q_4ErdKROvuyRktjO6GWZMdvvg,32865
218
+ flwr/server/app.py,sha256=4AYewApWSvYTJZcLzKGrcvT8AvHUXzwY0ROBXgmFlPU,30598
219
219
  flwr/server/client_manager.py,sha256=7Ese0tgrH-i-ms363feYZJKwB8gWnXSmg_hYF2Bju4U,6227
220
220
  flwr/server/client_proxy.py,sha256=4G-oTwhb45sfWLx2uZdcXD98IZwdTS6F88xe3akCdUg,2399
221
221
  flwr/server/compat/__init__.py,sha256=VxnJtJyOjNFQXMNi9hIuzNlZM5n0Hj1p3aq_Pm2udw4,892
@@ -289,10 +289,10 @@ flwr/server/superlink/fleet/vce/backend/backend.py,sha256=LBAQxnbfPAphVOVIvYMj0Q
289
289
  flwr/server/superlink/fleet/vce/backend/raybackend.py,sha256=jsUkFEVQTnrucK1jNQ_cUM8YwL7W4MQNA1GAf8ibRdg,7156
290
290
  flwr/server/superlink/fleet/vce/vce_api.py,sha256=WTnUILr1OHS8LfjXQUA3FyWJYdJgdqpFAybyJUD-1Xo,13025
291
291
  flwr/server/superlink/linkstate/__init__.py,sha256=v-2JyJlCB3qyhMNwMjmcNVOq4rkooqFU0LHH8Zo1jls,1064
292
- flwr/server/superlink/linkstate/in_memory_linkstate.py,sha256=v02iAvIlUqNnHodj_nERZh5lE5s-V3SxF3OiuoCnMXE,21561
293
- flwr/server/superlink/linkstate/linkstate.py,sha256=oHqOOgmsbi7V8zc0pbZeypcvXEtPXRckrp6cdGG52Qo,12694
292
+ flwr/server/superlink/linkstate/in_memory_linkstate.py,sha256=4ahMj7TLe-GO2ctyeZ2BBRkviGv27s6x1NS_ETRJHP8,20514
293
+ flwr/server/superlink/linkstate/linkstate.py,sha256=LWA5zRwN829GDAeSo5kmkzsMu0SkXa9qg4aG_0QN0uk,12159
294
294
  flwr/server/superlink/linkstate/linkstate_factory.py,sha256=ISSMjDlwuN7swxjOeYlTNpI_kuZ8PGkMcJnf1dbhUSE,2069
295
- flwr/server/superlink/linkstate/sqlite_linkstate.py,sha256=zk3V63_sgRqKOpXXX02TfqLZpHpcxUHrVAGfxPq0yvA,42101
295
+ flwr/server/superlink/linkstate/sqlite_linkstate.py,sha256=E07w0_eCoOnZOBbdh3I3PN5k5tqt4LrEnYAuiMOF0I0,40398
296
296
  flwr/server/superlink/linkstate/utils.py,sha256=EpRehwI4NeEW3oINICPWP9STK49N0aszd5s5jtle7DQ,13602
297
297
  flwr/server/superlink/simulation/__init__.py,sha256=mg-oapC9dkzEfjXPQFior5lpWj4g9kwbLovptyYM_g0,718
298
298
  flwr/server/superlink/simulation/simulationio_grpc.py,sha256=8aUrZZLdvprKUfLLqFID4aItus9beU6m1qLQYIPB7k0,2224
@@ -325,8 +325,8 @@ flwr/superexec/exec_servicer.py,sha256=X10ILT-AoGMrB3IgI2mBe9i-QcIVUAl9bucuqVOPY
325
325
  flwr/superexec/exec_user_auth_interceptor.py,sha256=K06OU-l4LnYhTDg071hGJuOaQWEJbZsYi5qxUmmtiG0,3704
326
326
  flwr/superexec/executor.py,sha256=_B55WW2TD1fBINpabSSDRenVHXYmvlfhv-k8hJKU4lQ,3115
327
327
  flwr/superexec/simulation.py,sha256=WQDon15oqpMopAZnwRZoTICYCfHqtkvFSqiTQ2hLD_g,4088
328
- flwr_nightly-1.15.0.dev20250124.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
329
- flwr_nightly-1.15.0.dev20250124.dist-info/METADATA,sha256=tr-JyBTsXNIUah1qY_BnD7Uhtsukv8Ktq5edbetabJs,15864
330
- flwr_nightly-1.15.0.dev20250124.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
331
- flwr_nightly-1.15.0.dev20250124.dist-info/entry_points.txt,sha256=JlNxX3qhaV18_2yj5a3kJW1ESxm31cal9iS_N_pf1Rk,538
332
- flwr_nightly-1.15.0.dev20250124.dist-info/RECORD,,
328
+ flwr_nightly-1.15.0.dev20250125.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
329
+ flwr_nightly-1.15.0.dev20250125.dist-info/METADATA,sha256=6xKhBBSDBkiq4rDxICNgqjqay3PiJGuB3esHhT-i_Ig,15864
330
+ flwr_nightly-1.15.0.dev20250125.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
331
+ flwr_nightly-1.15.0.dev20250125.dist-info/entry_points.txt,sha256=JlNxX3qhaV18_2yj5a3kJW1ESxm31cal9iS_N_pf1Rk,538
332
+ flwr_nightly-1.15.0.dev20250125.dist-info/RECORD,,