risk_propagation.player module

Configuration of a bank

class risk_propagation.player.Player(name, accounts, transactions, pool, paillier, delta_func=<function Player.<lambda>>)[source]

Bases: object

Player class performing steps in protocol

COMPENSATION_FACTOR = 1000000000000
__init__(name, accounts, transactions, pool, paillier, delta_func=<function Player.<lambda>>)[source]

Initializes a player instance

Parameters:
  • name (str) – the name of the player

  • accounts (ndarray[Any, dtype[object_]]) – an array of accounts containing an initial risk score per account

  • transactions (Union[ndarray[Any, dtype[object_]], List[ndarray[Any, dtype[object_]]]]) – an array containing arrays of transactions corresponding to periods

  • pool (Pool) – the communication pool to use

  • paillier (DistributedPaillier) – an instance of DistributedPaillier

  • delta_func (Callable[[int], float]) – Callable function which uses the iteration index to determine the delta value (must be between [0 and 1)).

property banks: Tuple[Bank, ...]

All banks in the protocol

Returns:

all banks in the protocol

async decrypt()[source]

Decryption of the risk scores per bank, compensating for the COMPENSATION_FACTOR

Return type:

None

property delta: float

The delta value for the current iteration

Returns:

Float in the range of [0,1)

Raises:

AssertionError – raised when the delta is not within the range [0..1)

encrypt_initial_risk_scores()[source]

Encrypt the initialised risk scores of this player’s accounts

Return type:

None

async iteration()[source]

Perform a single iteration

Return type:

None

property other_banks: Tuple[Bank, ...]

The other banks in the protocol

Returns:

the other banks in the protocol

property risk_scores: Dict[str, FixedPoint]

The plaintext risk scores belonging to this player’s bank

Returns:

plaintext dictionary of risk scores

Raises:

AttributeError – raised when risk scores are not available

async run_protocol(iterations)[source]

Runs the entire protocol

Parameters:

iterations (int) – the number of iterations to perform

Return type:

None

set_current_period(period_z)[source]

Set the period z to be used in the next iteration(s)

Parameters:

period_z (int) – The period z that should be used.

Return type:

None

update_risk_scores()[source]

Updates risk scores of all accounts

Return type:

None