Federation API

Functions

all_parties()

get all parties in order

get(name, tag[, idx])

This method will block until the remote object is fetched.

init(job_id, runtime_conf[, server_conf_path])

Initializes federation module.

local_party()

get local party

remote(obj, name, tag[, role, idx])

This method will send an object to other parties.

roles_to_parties(roles)

get parties from list of roles

init(job_id: str, runtime_conf, server_conf_path='arch/conf/server_conf.json')

Initializes federation module. This method should be called before calling other federation APIs

Parameters
  • job_id (str) – job id and default table namespace of this runtime. None is ok, uuid will be used.

  • runtime_conf (dict) –

    specifiy the role and parties. runtime_conf should be a dict with

    1. key “local” maps to the current process’ role and party_id.

    2. key “role” maps to a dict mapping from each role to all involving party_ids.

    {
      "local": {
          "role": "host",
          "party_id": 1000
      }
      "role": {
          "host": [999, 1000, 1001],
          "guest": [10002]
      }
    }
    

  • server_conf_path (str) – configurations of server, remain default.

Returns

nothing returns

Return type

None

Examples

>>> from arch.api import federation
>>> federation.init('job_id', runtime_conf)
all_parties()

get all parties in order

Returns

list of parties in order

Return type

list

local_party()

get local party

Returns

local party

Return type

Party

roles_to_parties(roles: list) → list

get parties from list of roles

Parameters

roles (list) – list of roles in str type

Returns

list of parties coresponsed to given roles in order

Return type

list

get(name, tag: str, idx=- 1)

This method will block until the remote object is fetched.

Parameters
  • name (str) – {algorithm}.{variableName} defined in transfer_conf.json.

  • tag (str) – transfer version, often indicates epoch number in algorithms

  • x (id) – idx of the party_ids in runtime role list, if idx < 0, list of all objects will be returned.

Returns

The object itself if idx is in range, else return list of all objects from possible source.

Return type

int or list

Examples

>>> b = federation.get("RsaIntersectTransferVariable.rsa_pubkey", tag="{}".format(_tag), idx=-1)
remote(obj, name: str, tag: str, role=None, idx=- 1)

This method will send an object to other parties.

Parameters
  • obj (any) – The object itself which can be pickled Or a DTable

  • name (str) – {algorithm}.{variableName} defined in transfer_conf.json.

  • tag (str) – transfer version, often indicates epoch number in algorithms

  • role (str or None) – The role you want to send to. None indicate broadcasting.

  • idx (int) – The idx of the party_ids of the role, if idx < 0, will send to all parties of the role.

Returns

nothing returns

Return type

None

Examples

>>> federation.remote(a, "RsaIntersectTransferVariable.rsa_pubkey", tag="{}".format(_tag))