flo-l commented on a change in pull request #1525:
URL: https://github.com/apache/systemds/pull/1525#discussion_r793765413
##########
File path:
src/main/java/org/apache/sysds/runtime/controlprogram/paramserv/FederatedPSControlThread.java
##########
@@ -258,9 +283,61 @@ public FederatedResponse execute(ExecutionContext ec,
Data... data) {
}
}
- /**
+ private static class SetupHEFederatedWorker extends
SetupFederatedWorker {
+ private static final long serialVersionUID =
9128347291804980123L;
+
+ byte[] _partial_pubkey_a;
+
+ protected SetupHEFederatedWorker(long batchSize, long dataSize, int
possibleBatchesPerLocalEpoch,
+ String programString, String
namespace, String gradientsFunctionName, String aggregationFunctionName,
+ ListObject hyperParams, long
modelVarID, int nbatches, byte[] partial_pubkey_a) {
+ // delegate everything to parent class. set modelAvg to true, as
it is the only supported case
+ super(batchSize, dataSize, possibleBatchesPerLocalEpoch,
programString, namespace, gradientsFunctionName,
+ aggregationFunctionName, hyperParams, modelVarID,
nbatches, true);
+
+ _partial_pubkey_a = partial_pubkey_a;
+ }
+
+ @Override
+ public FederatedResponse execute(ExecutionContext ec, Data... data) {
+ // TODO: set other CKKS parameters
+ // TODO generate partial public key
+ SEALClient sc = new SEALClient(_partial_pubkey_a);
+ ec.setSealClient(sc);
+ PublicKey partial_pubkey =
sc.generatePartialPublicKey();
+
+ FederatedResponse res = super.execute(ec, data);
+ if (!res.isSuccessful()) {
+ return res;
+ }
+
+ return new
FederatedResponse(FederatedResponse.ResponseType.SUCCESS, partial_pubkey);
+ }
+ }
+ /**
* Teardown UDF executed on the federated worker
*/
+ private static class SetPublicKeyFederatedWorker extends FederatedUDF {
+ private static final long serialVersionUID =
-1536502123123318969L;
+ private final PublicKey _public_key;
+
+ protected SetPublicKeyFederatedWorker(PublicKey public_key) {
+ super(new long[]{});
+ _public_key = public_key;
+ }
+
+ @Override
+ public FederatedResponse execute(ExecutionContext ec, Data...
data) {
+ ec.getSealClient().setPublicKey(_public_key);
+ return new
FederatedResponse(FederatedResponse.ResponseType.SUCCESS);
+ }
Review comment:
The key exchange is a two-step process:
1. Generate partial public keys on the client and send them to the server
2. Accumulate the partial public keys into one public key on the server
3. Send this public key back to each client. (this UDF)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]