risk_propagation.account module¶
Configuration of a bank account
- class risk_propagation.account.Account(label, origin, initial_risk_score=None, transaction=None, period=None, n_periods=1)[source]¶
Bases:
object
Class containing information on a bank account
- __init__(label, origin, initial_risk_score=None, transaction=None, period=None, n_periods=1)[source]¶
Initializes an instance of Account
- Parameters:
label (
str
) – Identifier/label of the accountorigin (
Bank
) – The bank that the account belongs toinitial_risk_score (
float
|PaillierCiphertext
|None
) – Optional initial risk_score of this accounttransaction (
Transaction
|None
) – Optionally specify a transaction alreadyperiod (
int
|None
) – The period z to which the transaction belongs.n_periods (
int
) – The total number of periods z in the protocol.
- add_transaction(transaction, period)[source]¶
Adds incoming transaction to account
- Parameters:
transaction (
Transaction
) – the transaction to addperiod (
int
) – the period z to which the transaction belongs.
- Return type:
None
- property amounts: Generator[int, None, None]¶
A generator of all transaction amounts
- Returns:
a generator of all transaction amounts
- encrypt(public_key)[source]¶
Encrypt the risk score of the account
- Parameters:
public_key (
DistributedPaillier
|Paillier
) – the public key to use in the encryption- Raises:
ValueError – raised when risk_score is already encrypted
- Return type:
None
- property has_encrypted_risk_score: bool¶
Check if this account’s risk score is a paillier ciphertext
- Returns:
True if the risk score is encrypted else false
- property label: str¶
Label of the account
- Returns:
the label of the account
- property linked_accounts: set[tuple[str, int]]¶
Accounts linked to this account together with their amount value (label, amount)
- Returns:
a collection of all account linked to this account
- property origin: Bank¶
The bank that possesses the information on this account
- Returns:
a bank
- property risk_score: float | PaillierCiphertext¶
Risk score of the account
- Returns:
current risk score
- Raises:
AttributeError – raised when risk score is not set
- property total_income: int¶
Sum of all incoming transactions
- Returns:
total amount of incoming transactions
- property transactions: Transactions¶
The collection of all incoming transactions
- Returns:
the collection of incoming transactions
- property unsafe_encrypted_risk_score: PaillierCiphertext¶
Encrypted risk score. Note that the ciphertext is not (yet) safe to broadcast as it first needs to be randomized.
- Returns:
current risk score
- Raises:
AttributeError – raised when risk score is not encrypted