MIFE — Multi-Input Functional Encryption

Multi-input functional encryption schemes.

class pyfe4ai.schemes.mife.MIFE(config)[source]

Bases: IPFEAbsCrypto

Crypto operations for DDH-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config)[source]

Initialise the MIFE crypto system.

Parameters:

config (dict) – Must contain keys with pp (public parameters) and either sk (encryption keys) or dk (decryption key).

Return type:

None

encrypt(lst_pt)[source]

Encrypt a plaintext vector for one client.

Parameters:

lst_pt (list) – Integer plaintext vector of length ≤ eta.

Return type:

dict

Returns:

Dict with t (group element pair) and c (ciphertext list).

Raises:
decrypt(dct_ct, dk, fusion_weight)[source]

Decrypt aggregated ciphertexts to recover the multi-input inner product.

Parameters:
  • dct_ct (dict) – Mapping of client IDs to their ciphertext dicts.

  • dk (dict) – Decryption key dict with d (per-client) and z.

  • fusion_weight (dict) – Mapping of client IDs to weight lists.

Returns:

The inner product as an integer, or None if out of bound.

Raises:
encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Encrypt a list of ndarrays element-wise.

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt.

Return type:

list | None

Returns:

List of object ndarrays containing per-element ciphertexts.

decrypt_lst_ndarray_ct(dict_ndarray_ct, dk, fusion_weight)[source]

Decrypt ndarray ciphertexts from multiple clients.

Parameters:
  • dict_ndarray_ct (dict) – Mapping of client IDs to ciphertext ndarray lists.

  • dk (dict) – Decryption key dict.

  • fusion_weight (dict) – Mapping of client IDs to weight lists.

Return type:

list | None

Returns:

List of float ndarrays with decrypted values.

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Aggregate ndarray ciphertexts (delegates to decrypt_lst_ndarray_ct()).

Parameters:
  • dict_ndarray_ct (dict) – Mapping of client IDs to ciphertext ndarray lists.

  • **kwargs – Must include dk and fusion_weight.

Return type:

list | None

Returns:

Decrypted ndarray list.

class pyfe4ai.schemes.mife.MIFEKeyGenerator(config, **kwargs)[source]

Bases: DDHKeyGeneratorBase

Key generator for DDH-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the MIFE key generator.

Parameters:

config (dict) – Scheme configuration. Recognised keys: sec_param, eta (int or per-client dict), n (number of clients), s, lst_nid (client identifiers).

Return type:

None

setup()[source]

Generate master secret key (msk) and master public key (mpk).

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters (g, p, n, eta, sec_param).

Return type:

dict

Returns:

Dict of public parameters.

get_private_keys(nid)[source]

Return encryption keys for client nid.

Parameters:

nid (str) – Client identifier, must be in lst_nid.

Return type:

dict | None

Returns:

Dict with g_a, w, u keys, or None if nid is invalid.

get_decryption_keys(sid, **kwargs)[source]

Derive a functional decryption key for the given fusion weights.

Parameters:
  • sid (str) – Session identifier.

  • **kwargs – Must include credentials with fusion_weight (dict mapping client IDs to weight lists).

Return type:

dict | None

Returns:

Dict with d (per-client keys) and z (aggregated secret).

Raises:

FEKeyError – If credentials are missing.

pyfe4ai.schemes.mife.HybridAlphaMIFE

alias of MIFE

pyfe4ai.schemes.mife.HybridAlphaMIFEKeyGenerator

alias of MIFEKeyGenerator

class pyfe4ai.schemes.mife.MIFEFHIPE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for function-hiding multi-input IPE over pairings.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

encrypt(lst_pt)[source]
Parameters:

lst_pt (list)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight)[source]

Decrypt ciphertexts and recover the inner product.

Parameters:
  • dct_ct (dict) – Ciphertext dict (or dict of per-client ciphertexts).

  • dk (dict) – Functional decryption key.

  • fusion_weight (dict) – Fusion weight vector (or dict of per-client weight vectors).

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Perform the encrypt_lst_ndarray operation.

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt element-wise.

Return type:

list | None

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

class pyfe4ai.schemes.mife.MIFEFHIPEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for function-hiding multi-input IPE over pairings.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

setup()[source]

Generate master public and secret keys for the scheme.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

A dict of public parameters, or None on error.

get_private_keys(nid, **kwargs)[source]

Perform the get_private_keys operation.

Parameters:

nid (str) – Node identifier.

Return type:

dict | None

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict | None

class pyfe4ai.schemes.mife.MIFEFHMultiIPE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for function-hiding multi-slot multi-input IPE over pairings.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

encrypt(lst_pt)[source]
Parameters:

lst_pt (list)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight=None)[source]

Decrypt ciphertexts and recover the inner product.

Parameters:
  • dct_ct (dict) – Ciphertext dict (or dict of per-client ciphertexts).

  • dk (dict) – Functional decryption key.

  • fusion_weight (dict | None, default: None) – Fusion weight vector (or dict of per-client weight vectors).

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Perform the encrypt_lst_ndarray operation.

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt element-wise.

Return type:

list | None

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

class pyfe4ai.schemes.mife.MIFEFHMultiIPEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for function-hiding multi-slot multi-input IPE over pairings.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

setup()[source]

Generate master public and secret keys for the scheme.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

A dict of public parameters, or None on error.

get_private_keys(nid, **kwargs)[source]

Perform the get_private_keys operation.

Parameters:

nid (str) – Node identifier.

Return type:

dict | None

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict | None

class pyfe4ai.schemes.mife.MIFEFullySecLWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for fully secure LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

encrypt(lst_pt)[source]
Parameters:

lst_pt (list)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight)[source]

Decrypt ciphertexts and recover the inner product.

Parameters:
  • dct_ct (dict) – Ciphertext dict (or dict of per-client ciphertexts).

  • dk (dict) – Functional decryption key.

  • fusion_weight (dict) – Fusion weight vector (or dict of per-client weight vectors).

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Perform the encrypt_lst_ndarray operation.

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt element-wise.

Return type:

list | None

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

class pyfe4ai.schemes.mife.MIFEFullySecLWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for fully secure LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

setup()[source]

Generate master public and secret keys for the scheme.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

A dict of public parameters, or None on error.

get_private_keys(nid, **kwargs)[source]

Perform the get_private_keys operation.

Parameters:

nid (str) – Node identifier.

Return type:

dict | None

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict | None

class pyfe4ai.schemes.mife.MIFEPaillier(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for Paillier-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

encrypt(lst_pt)[source]
Parameters:

lst_pt (list)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight)[source]

Decrypt ciphertexts and recover the inner product.

Parameters:
  • dct_ct (dict) – Ciphertext dict (or dict of per-client ciphertexts).

  • dk (dict) – Functional decryption key.

  • fusion_weight (dict) – Fusion weight vector (or dict of per-client weight vectors).

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Perform the encrypt_lst_ndarray operation.

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt element-wise.

Return type:

list | None

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

class pyfe4ai.schemes.mife.MIFEPaillierKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for Paillier-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

setup()[source]

Generate master public and secret keys for the scheme.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

A dict of public parameters, or None on error.

get_private_keys(nid, **kwargs)[source]

Perform the get_private_keys operation.

Parameters:

nid (str) – Node identifier.

Return type:

dict | None

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict | None

pyfe4ai.schemes.mife.MIFEDamgardDDH

alias of MIFEDamgard

pyfe4ai.schemes.mife.MIFEDamgardDDHKeyGenerator

alias of MIFEDamgardKeyGenerator

class pyfe4ai.schemes.mife.MIFELWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the MIFE LWE crypto system.

Parameters:

config (dict) – Must contain keys with pp (public parameters) and optionally sk (encryption keys).

Return type:

None

encrypt(lst_pt)[source]

Encrypt a plaintext vector for one client.

Parameters:

lst_pt (list) – Integer plaintext vector of length eta.

Return type:

dict

Returns:

Dict with ct0 and ct1 (serialised LWE ciphertext vectors).

Raises:
decrypt(dct_ct, dk, fusion_weight)[source]

Decrypt aggregated ciphertexts to recover the multi-input inner product.

Parameters:
  • dct_ct (dict) – Mapping of client IDs to their ciphertext dicts.

  • dk (dict) – Decryption key dict with sk_y (per-client).

  • fusion_weight (dict) – Mapping of client IDs to weight lists.

Returns:

The inner product as an integer.

Raises:
encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Encrypt a list of ndarrays element-wise (requires eta=1).

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt.

Return type:

list | None

Returns:

List of object ndarrays containing per-element ciphertexts.

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Aggregate ndarray ciphertexts (delegates to decrypt_lst_ndarray_ct()).

Parameters:
  • dict_ndarray_ct (dict) – Mapping of client IDs to ciphertext ndarray lists.

  • **kwargs – Must include dk and fusion_weight.

Return type:

list | None

Returns:

Decrypted ndarray list.

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt ndarray ciphertexts from multiple clients.

Parameters:
  • dict_ndarray_ct (dict) – Mapping of client IDs to ciphertext ndarray lists.

  • **kwargs – Must include dk and fusion_weight.

Return type:

list | None

Returns:

List of float ndarrays with decrypted values.

class pyfe4ai.schemes.mife.MIFELWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the MIFE LWE key generator.

Parameters:

config (dict) – Scheme configuration. Recognised keys: sec_param, eta, n (number of clients), lwe_n, bound_x, bound_y.

Return type:

None

setup()[source]

Generate per-client secret keys and public keys.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

Dict containing A, p, q, m, eta, n, lwe_n, bound_x, bound_y, sec_param.

get_private_keys(nid, **kwargs)[source]

Return encryption keys for client nid.

Parameters:

nid (str) – Client identifier.

Return type:

dict | None

Returns:

Dict with pk matrix, or None if nid is invalid.

get_decryption_keys(sid, **kwargs)[source]

Derive a functional decryption key for the given fusion weights.

Parameters:
  • sid (str) – Session identifier.

  • **kwargs – Must include credentials with fusion_weight (dict mapping client IDs to weight lists).

Return type:

dict | None

Returns:

Dict with sk_y (per-client projected secret keys).

Raises:
class pyfe4ai.schemes.mife.MIFERingLWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for Ring-LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

encrypt(matrix_pt)[source]
Parameters:

matrix_pt (list[list[int]])

Return type:

dict

decrypt(dct_ct, dk, fusion_weight)[source]

Decrypt ciphertexts and recover the inner product.

Parameters:
  • dct_ct (dict) – Ciphertext dict (or dict of per-client ciphertexts).

  • dk (dict) – Functional decryption key.

  • fusion_weight (dict) – Fusion weight vector (or dict of per-client weight vectors).

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Perform the encrypt_lst_ndarray operation.

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt element-wise.

Return type:

list | None

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

class pyfe4ai.schemes.mife.MIFERingLWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for Ring-LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

setup()[source]

Generate master public and secret keys for the scheme.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

A dict of public parameters, or None on error.

get_private_keys(nid, **kwargs)[source]

Perform the get_private_keys operation.

Parameters:

nid (str) – Node identifier.

Return type:

dict | None

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict | None

class pyfe4ai.schemes.mife.ThresholdMIFE(config)[source]

Bases: IPFEAbsCrypto

Crypto operations for threshold DDH-based multi-input inner-product FE.

Parameters:

config (dict)

encrypt(pt)[source]
Parameters:

pt (list)

Return type:

dict

share_decrypt(dict_ct, credentials, dk, lst_sid_enrolled)[source]

Compute a partial decryption share.

Parameters:
  • dict_ct (dict) – Dict of per-client ciphertexts.

  • credentials (dict) – Credential dict containing fusion_weight and optional label.

  • dk (dict) – Functional decryption key.

  • lst_sid_enrolled (list) – List of enrolled session / node identifiers.

Return type:

dict

static L(id, dct_id_v, lst_sid_enrolled)[source]

Compute the Lagrange interpolation coefficient.

Parameters:
  • id (str) – Node identifier for Lagrange coefficient.

  • dct_id_v (dict) – Dict mapping node ids to values for interpolation.

  • lst_sid_enrolled (list) – List of enrolled session / node identifiers.

Return type:

int

combine_decrypt(dict_ct_prime)[source]
Parameters:

dict_ct_prime (dict)

Return type:

float | None

encrypt_lst_ndarray(lst_ndarray)[source]

Encrypt a list of ndarray-like plaintexts.

Parameters:

lst_ndarray (list) – List of plaintext arrays to encrypt.

Return type:

list

Returns:

List of ciphertext dicts, or None on error.

compute_lst_ndarray_ct(dict_ndarray_ct, credentials, dk, lst_sid_enrolled)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:
  • dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

  • credentials (dict) – Credential dict containing fusion_weight and optional label.

  • dk (dict) – Functional decryption key.

  • lst_sid_enrolled (list) – List of enrolled session / node identifiers.

Return type:

list

decrypt_lst_ndarray_ct(dict_ndarray_ct)[source]

Decrypt aggregated ndarray ciphertexts.

Parameters:

dict_ndarray_ct (dict) – Mapping of client IDs to their ciphertext lists.

Return type:

list

Returns:

List of decrypted inner-product results, or None on error.

class pyfe4ai.schemes.mife.ThresholdMIFEKeyGenerator(config)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for threshold DDH-based multi-input inner-product FE.

Parameters:

config (dict)

setup()[source]

Generate master public and secret keys for the scheme.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

A dict of public parameters, or None on error.

get_private_keys(nid)[source]

Return the private (encryption) keys for client nid.

Parameters:

nid (str) – A client/node identifier.

Return type:

dict | None

Returns:

A dict of private keys, or None if nid is invalid.

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict

class pyfe4ai.schemes.mife.ThresholdMIFELWE(config, **kwargs)[source]

Bases: MIFELWE

Crypto operations for threshold LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

share_decrypt(dict_ct, credentials, dk, lst_sid_enrolled)[source]

Compute a partial decryption share.

Parameters:
  • dict_ct (dict) – Dict of per-client ciphertexts.

  • credentials (dict) – Credential dict containing fusion_weight and optional label.

  • dk (dict) – Functional decryption key.

  • lst_sid_enrolled (list) – List of enrolled session / node identifiers.

Return type:

dict

combine_decrypt(dict_ct_prime)[source]
Parameters:

dict_ct_prime (dict)

Return type:

float

compute_lst_ndarray_ct(dict_ndarray_ct, credentials, dk, lst_sid_enrolled)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:
  • dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

  • credentials (dict) – Credential dict containing fusion_weight and optional label.

  • dk (dict) – Functional decryption key.

  • lst_sid_enrolled (list) – List of enrolled session / node identifiers.

Return type:

list

decrypt_lst_ndarray_ct(dict_ndarray_ct)[source]

Decrypt ndarray ciphertexts from multiple clients.

Parameters:
  • dict_ndarray_ct (dict) – Mapping of client IDs to ciphertext ndarray lists.

  • **kwargs – Must include dk and fusion_weight.

Return type:

list

Returns:

List of float ndarrays with decrypted values.

class pyfe4ai.schemes.mife.ThresholdMIFELWEKeyGenerator(config, **kwargs)[source]

Bases: MIFELWEKeyGenerator

Key generator for threshold LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

Dict containing A, p, q, m, eta, n, lwe_n, bound_x, bound_y, sec_param.

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict | None

DDH

Multi Input Functional Encryption | From “Multi-Input Functional Encryption for Inner Products: | Function-Hiding Realizations and Constructions without Pairings” | Published in: CRYPTO 2018 | By: Michel Abdalla, Dario Catalano, Dario Fiore, Romain Gay, and Bogdan Ursu5 | URL: https://eprint.iacr.org/2017/972.pdf

  • type: public-key encryption

  • setting: Integer based

class pyfe4ai.schemes.mife.ddh.MIFEKeyGenerator(config, **kwargs)[source]

Bases: DDHKeyGeneratorBase

Key generator for DDH-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the MIFE key generator.

Parameters:

config (dict) – Scheme configuration. Recognised keys: sec_param, eta (int or per-client dict), n (number of clients), s, lst_nid (client identifiers).

Return type:

None

setup()[source]

Generate master secret key (msk) and master public key (mpk).

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters (g, p, n, eta, sec_param).

Return type:

dict

Returns:

Dict of public parameters.

get_private_keys(nid)[source]

Return encryption keys for client nid.

Parameters:

nid (str) – Client identifier, must be in lst_nid.

Return type:

dict | None

Returns:

Dict with g_a, w, u keys, or None if nid is invalid.

get_decryption_keys(sid, **kwargs)[source]

Derive a functional decryption key for the given fusion weights.

Parameters:
  • sid (str) – Session identifier.

  • **kwargs – Must include credentials with fusion_weight (dict mapping client IDs to weight lists).

Return type:

dict | None

Returns:

Dict with d (per-client keys) and z (aggregated secret).

Raises:

FEKeyError – If credentials are missing.

class pyfe4ai.schemes.mife.ddh.MIFE(config)[source]

Bases: IPFEAbsCrypto

Crypto operations for DDH-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config)[source]

Initialise the MIFE crypto system.

Parameters:

config (dict) – Must contain keys with pp (public parameters) and either sk (encryption keys) or dk (decryption key).

Return type:

None

encrypt(lst_pt)[source]

Encrypt a plaintext vector for one client.

Parameters:

lst_pt (list) – Integer plaintext vector of length ≤ eta.

Return type:

dict

Returns:

Dict with t (group element pair) and c (ciphertext list).

Raises:
decrypt(dct_ct, dk, fusion_weight)[source]

Decrypt aggregated ciphertexts to recover the multi-input inner product.

Parameters:
  • dct_ct (dict) – Mapping of client IDs to their ciphertext dicts.

  • dk (dict) – Decryption key dict with d (per-client) and z.

  • fusion_weight (dict) – Mapping of client IDs to weight lists.

Returns:

The inner product as an integer, or None if out of bound.

Raises:
encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Encrypt a list of ndarrays element-wise.

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt.

Return type:

list | None

Returns:

List of object ndarrays containing per-element ciphertexts.

decrypt_lst_ndarray_ct(dict_ndarray_ct, dk, fusion_weight)[source]

Decrypt ndarray ciphertexts from multiple clients.

Parameters:
  • dict_ndarray_ct (dict) – Mapping of client IDs to ciphertext ndarray lists.

  • dk (dict) – Decryption key dict.

  • fusion_weight (dict) – Mapping of client IDs to weight lists.

Return type:

list | None

Returns:

List of float ndarrays with decrypted values.

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Aggregate ndarray ciphertexts (delegates to decrypt_lst_ndarray_ct()).

Parameters:
  • dict_ndarray_ct (dict) – Mapping of client IDs to ciphertext ndarray lists.

  • **kwargs – Must include dk and fusion_weight.

Return type:

list | None

Returns:

Decrypted ndarray list.

DDH Hybrid-Alpha

Multi Input Functional Encryption | From “Multi-Input Functional Encryption for Inner Products: | Function-Hiding Realizations and Constructions without Pairings” | Published in: CRYPTO 2018 | By: Michel Abdalla, Dario Catalano, Dario Fiore, Romain Gay, and Bogdan Ursu5 | URL: https://eprint.iacr.org/2017/972.pdf

  • type: public-key encryption

  • setting: Integer based

class pyfe4ai.schemes.mife.ddh_hybrid_alpha.MIFEKeyGenerator(config, **kwargs)[source]

Bases: DDHKeyGeneratorBase

Key generator for DDH-based multi-input FE (hybrid-alpha variant).

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

setup()[source]

Generate master public and secret keys for the scheme.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

A dict of public parameters, or None on error.

get_private_keys(nid)[source]

Return the private (encryption) keys for client nid.

Parameters:

nid (str) – A client/node identifier.

Return type:

dict | None

Returns:

A dict of private keys, or None if nid is invalid.

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict | None

class pyfe4ai.schemes.mife.ddh_hybrid_alpha.MIFE(config)[source]

Bases: IPFEAbsCrypto

Crypto operations for DDH-based multi-input FE (hybrid-alpha variant).

Parameters:

config (dict)

encrypt(lst_pt)[source]
Parameters:

lst_pt (list)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight)[source]

Decrypt ciphertexts and recover the inner product.

Parameters:
  • dct_ct (dict) – Ciphertext dict (or dict of per-client ciphertexts).

  • dk (dict) – Functional decryption key.

  • fusion_weight (dict) – Fusion weight vector (or dict of per-client weight vectors).

decrypt_debug(dct_ct, dk, fusion_weight)[source]

Decrypt with additional debug output.

Parameters:
  • dct_ct (dict) – Ciphertext dict (or dict of per-client ciphertexts).

  • dk (dict) – Functional decryption key.

  • fusion_weight (dict) – Fusion weight vector (or dict of per-client weight vectors).

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Perform the encrypt_lst_ndarray operation.

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt element-wise.

Return type:

list | None

decrypt_lst_ndarray_ct(dict_ndarray_ct, dk, fusion_weight)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:
  • dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

  • dk (dict) – Functional decryption key.

  • fusion_weight (dict) – Fusion weight vector (or dict of per-client weight vectors).

Return type:

list | None

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

DDH Threshold

R. Xu et al., “TAPFed: Threshold Secure Aggregation for Privacy-Preserving Federated Learning,” in IEEE Transactions on Dependable and Secure Computing, doi: 10.1109/TDSC.2024.3350206.

  • type: public-key encryption

  • setting: Integer based

class pyfe4ai.schemes.mife.ddh_threshold.ThresholdMIFEKeyGenerator(config)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for threshold DDH-based multi-input inner-product FE.

Parameters:

config (dict)

setup()[source]

Generate master public and secret keys for the scheme.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

A dict of public parameters, or None on error.

get_private_keys(nid)[source]

Return the private (encryption) keys for client nid.

Parameters:

nid (str) – A client/node identifier.

Return type:

dict | None

Returns:

A dict of private keys, or None if nid is invalid.

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict

class pyfe4ai.schemes.mife.ddh_threshold.ThresholdMIFE(config)[source]

Bases: IPFEAbsCrypto

Crypto operations for threshold DDH-based multi-input inner-product FE.

Parameters:

config (dict)

encrypt(pt)[source]
Parameters:

pt (list)

Return type:

dict

share_decrypt(dict_ct, credentials, dk, lst_sid_enrolled)[source]

Compute a partial decryption share.

Parameters:
  • dict_ct (dict) – Dict of per-client ciphertexts.

  • credentials (dict) – Credential dict containing fusion_weight and optional label.

  • dk (dict) – Functional decryption key.

  • lst_sid_enrolled (list) – List of enrolled session / node identifiers.

Return type:

dict

static L(id, dct_id_v, lst_sid_enrolled)[source]

Compute the Lagrange interpolation coefficient.

Parameters:
  • id (str) – Node identifier for Lagrange coefficient.

  • dct_id_v (dict) – Dict mapping node ids to values for interpolation.

  • lst_sid_enrolled (list) – List of enrolled session / node identifiers.

Return type:

int

combine_decrypt(dict_ct_prime)[source]
Parameters:

dict_ct_prime (dict)

Return type:

float | None

encrypt_lst_ndarray(lst_ndarray)[source]

Encrypt a list of ndarray-like plaintexts.

Parameters:

lst_ndarray (list) – List of plaintext arrays to encrypt.

Return type:

list

Returns:

List of ciphertext dicts, or None on error.

compute_lst_ndarray_ct(dict_ndarray_ct, credentials, dk, lst_sid_enrolled)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:
  • dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

  • credentials (dict) – Credential dict containing fusion_weight and optional label.

  • dk (dict) – Functional decryption key.

  • lst_sid_enrolled (list) – List of enrolled session / node identifiers.

Return type:

list

decrypt_lst_ndarray_ct(dict_ndarray_ct)[source]

Decrypt aggregated ndarray ciphertexts.

Parameters:

dict_ndarray_ct (dict) – Mapping of client IDs to their ciphertext lists.

Return type:

list

Returns:

List of decrypted inner-product results, or None on error.

Damgård DDH

Damgard-Based Multi-Input Inner-Product Functional Encryption | Multi-input construction inspired by | “Multi-Input Functional Encryption for Inner Products: | Function-Hiding Realizations and Constructions without Pairings” | By Michel Abdalla, Dario Catalano, Dario Fiore, Romain Gay, Bogdan Ursu | Published in: CRYPTO 2018 | | Instantiated here with a Damgard/DDH-based single-input building block inspired by | Agrawal, Libert, Stehle: | “Fully Secure Functional Encryption for Inner Products, from Standard | Assumptions” | Published in: CRYPTO 2016

  • type: public-key encryption

  • setting: Integer based

  • note: research-oriented Python prototype aligned with the existing

    crypto-ipfe API style

class pyfe4ai.schemes.mife.damgard_ddh.MIFEDamgardKeyGenerator(config, **kwargs)[source]

Bases: DamgardDDHKeyGeneratorBase

Key generator for Damgard DDH-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

setup()[source]

Generate master public and secret keys for the scheme.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

A dict of public parameters, or None on error.

get_private_keys(nid, **kwargs)[source]

Perform the get_private_keys operation.

Parameters:

nid (str) – Node identifier.

Return type:

dict | None

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict | None

class pyfe4ai.schemes.mife.damgard_ddh.MIFEDamgard(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for Damgard DDH-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

encrypt(lst_pt)[source]
Parameters:

lst_pt (list)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight)[source]

Decrypt ciphertexts and recover the inner product.

Parameters:
  • dct_ct (dict) – Ciphertext dict (or dict of per-client ciphertexts).

  • dk (dict) – Functional decryption key.

  • fusion_weight (dict) – Fusion weight vector (or dict of per-client weight vectors).

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Perform the encrypt_lst_ndarray operation.

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt element-wise.

Return type:

list | None

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

LWE

LWE-Based Multi-Input Inner-Product Functional Encryption | Multi-input organization inspired by | “Multi-Input Functional Encryption for Inner Products: | Function-Hiding Realizations and Constructions without Pairings” | By Michel Abdalla, Dario Catalano, Dario Fiore, Romain Gay, Bogdan Ursu | Published in: CRYPTO 2018 | | This prototype composes per-client simple LWE inner-product FE instances | following the repository’s MIFE API, using the LWE instantiation of | “Simple Functional Encryption Schemes for Inner Products” | By Michel Abdalla, Florian Bourse, Angelo De Caro, David Pointcheval | Published in: PKC 2015

  • type: public-key encryption

  • setting: Integer based

  • note: prototype implementation aligned with the existing crypto-ipfe API

class pyfe4ai.schemes.mife.lwe.MIFELWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the MIFE LWE key generator.

Parameters:

config (dict) – Scheme configuration. Recognised keys: sec_param, eta, n (number of clients), lwe_n, bound_x, bound_y.

Return type:

None

setup()[source]

Generate per-client secret keys and public keys.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

Dict containing A, p, q, m, eta, n, lwe_n, bound_x, bound_y, sec_param.

get_private_keys(nid, **kwargs)[source]

Return encryption keys for client nid.

Parameters:

nid (str) – Client identifier.

Return type:

dict | None

Returns:

Dict with pk matrix, or None if nid is invalid.

get_decryption_keys(sid, **kwargs)[source]

Derive a functional decryption key for the given fusion weights.

Parameters:
  • sid (str) – Session identifier.

  • **kwargs – Must include credentials with fusion_weight (dict mapping client IDs to weight lists).

Return type:

dict | None

Returns:

Dict with sk_y (per-client projected secret keys).

Raises:
class pyfe4ai.schemes.mife.lwe.MIFELWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the MIFE LWE crypto system.

Parameters:

config (dict) – Must contain keys with pp (public parameters) and optionally sk (encryption keys).

Return type:

None

encrypt(lst_pt)[source]

Encrypt a plaintext vector for one client.

Parameters:

lst_pt (list) – Integer plaintext vector of length eta.

Return type:

dict

Returns:

Dict with ct0 and ct1 (serialised LWE ciphertext vectors).

Raises:
decrypt(dct_ct, dk, fusion_weight)[source]

Decrypt aggregated ciphertexts to recover the multi-input inner product.

Parameters:
  • dct_ct (dict) – Mapping of client IDs to their ciphertext dicts.

  • dk (dict) – Decryption key dict with sk_y (per-client).

  • fusion_weight (dict) – Mapping of client IDs to weight lists.

Returns:

The inner product as an integer.

Raises:
encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Encrypt a list of ndarrays element-wise (requires eta=1).

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt.

Return type:

list | None

Returns:

List of object ndarrays containing per-element ciphertexts.

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Aggregate ndarray ciphertexts (delegates to decrypt_lst_ndarray_ct()).

Parameters:
  • dict_ndarray_ct (dict) – Mapping of client IDs to ciphertext ndarray lists.

  • **kwargs – Must include dk and fusion_weight.

Return type:

list | None

Returns:

Decrypted ndarray list.

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt ndarray ciphertexts from multiple clients.

Parameters:
  • dict_ndarray_ct (dict) – Mapping of client IDs to ciphertext ndarray lists.

  • **kwargs – Must include dk and fusion_weight.

Return type:

list | None

Returns:

List of float ndarrays with decrypted values.

Fully-Secure LWE

Fully Secure LWE-Based Multi-Input Inner-Product Functional Encryption | Multi-input organization inspired by | “Multi-Input Functional Encryption for Inner Products: | Function-Hiding Realizations and Constructions without Pairings” | By Michel Abdalla, Dario Catalano, Dario Fiore, Romain Gay, Bogdan Ursu | Published in: CRYPTO 2018 | | Instantiated here with the fully secure LWE single-input line from | “Fully Secure Functional Encryption for Inner Products, | from Standard Assumptions” | By Shweta Agrawal, Benoit Libert, Damien Stehle | Published in: CRYPTO 2016

  • type: public-key encryption

  • setting: Integer based

  • note: research-oriented Python prototype aligned with the crypto-ipfe API

class pyfe4ai.schemes.mife.fullysec_lwe.MIFEFullySecLWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for fully secure LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

setup()[source]

Generate master public and secret keys for the scheme.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

A dict of public parameters, or None on error.

get_private_keys(nid, **kwargs)[source]

Perform the get_private_keys operation.

Parameters:

nid (str) – Node identifier.

Return type:

dict | None

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict | None

class pyfe4ai.schemes.mife.fullysec_lwe.MIFEFullySecLWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for fully secure LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

encrypt(lst_pt)[source]
Parameters:

lst_pt (list)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight)[source]

Decrypt ciphertexts and recover the inner product.

Parameters:
  • dct_ct (dict) – Ciphertext dict (or dict of per-client ciphertexts).

  • dk (dict) – Functional decryption key.

  • fusion_weight (dict) – Fusion weight vector (or dict of per-client weight vectors).

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Perform the encrypt_lst_ndarray operation.

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt element-wise.

Return type:

list | None

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

LWE Threshold

Threshold LWE-Based Multi-Input Inner-Product Functional Encryption | Threshold secure aggregation organization inspired by | “TAPFed: Threshold Secure Aggregation for Privacy-Preserving Federated Learning” | Published in: IEEE TDSC | | This prototype combines threshold decryption-key sharing with the | repository’s LWE-based MIFE line.

  • type: public-key encryption

  • setting: Integer based

  • note: research prototype aligned with the existing crypto-ipfe API

class pyfe4ai.schemes.mife.lwe_threshold.ThresholdMIFELWEKeyGenerator(config, **kwargs)[source]

Bases: MIFELWEKeyGenerator

Key generator for threshold LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

Dict containing A, p, q, m, eta, n, lwe_n, bound_x, bound_y, sec_param.

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict | None

class pyfe4ai.schemes.mife.lwe_threshold.ThresholdMIFELWE(config, **kwargs)[source]

Bases: MIFELWE

Crypto operations for threshold LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

share_decrypt(dict_ct, credentials, dk, lst_sid_enrolled)[source]

Compute a partial decryption share.

Parameters:
  • dict_ct (dict) – Dict of per-client ciphertexts.

  • credentials (dict) – Credential dict containing fusion_weight and optional label.

  • dk (dict) – Functional decryption key.

  • lst_sid_enrolled (list) – List of enrolled session / node identifiers.

Return type:

dict

combine_decrypt(dict_ct_prime)[source]
Parameters:

dict_ct_prime (dict)

Return type:

float

compute_lst_ndarray_ct(dict_ndarray_ct, credentials, dk, lst_sid_enrolled)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:
  • dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

  • credentials (dict) – Credential dict containing fusion_weight and optional label.

  • dk (dict) – Functional decryption key.

  • lst_sid_enrolled (list) – List of enrolled session / node identifiers.

Return type:

list

decrypt_lst_ndarray_ct(dict_ndarray_ct)[source]

Decrypt ndarray ciphertexts from multiple clients.

Parameters:
  • dict_ndarray_ct (dict) – Mapping of client IDs to ciphertext ndarray lists.

  • **kwargs – Must include dk and fusion_weight.

Return type:

list

Returns:

List of float ndarrays with decrypted values.

Ring-LWE

Ring-LWE-Based Multi-Input Inner-Product Functional Encryption | Multi-input organization inspired by | “Multi-Input Functional Encryption for Inner Products: | Function-Hiding Realizations and Constructions without Pairings” | By Michel Abdalla, Dario Catalano, Dario Fiore, Romain Gay, Bogdan Ursu | Published in: CRYPTO 2018 | | This prototype combines the repository’s MIFE API with the Ring-LWE | inner-product FE line from | “Efficient Lattice-Based Inner-Product Functional Encryption” | By Bermudo Mera, Karmakar, Marc, Soleimanian | ePrint: 2021/046

  • type: public-key encryption

  • setting: Integer based

  • note: research prototype with SIMD-style matrix encryption

class pyfe4ai.schemes.mife.ring_lwe.MIFERingLWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for Ring-LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

setup()[source]

Generate master public and secret keys for the scheme.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

A dict of public parameters, or None on error.

get_private_keys(nid, **kwargs)[source]

Perform the get_private_keys operation.

Parameters:

nid (str) – Node identifier.

Return type:

dict | None

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict | None

class pyfe4ai.schemes.mife.ring_lwe.MIFERingLWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for Ring-LWE-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

encrypt(matrix_pt)[source]
Parameters:

matrix_pt (list[list[int]])

Return type:

dict

decrypt(dct_ct, dk, fusion_weight)[source]

Decrypt ciphertexts and recover the inner product.

Parameters:
  • dct_ct (dict) – Ciphertext dict (or dict of per-client ciphertexts).

  • dk (dict) – Functional decryption key.

  • fusion_weight (dict) – Fusion weight vector (or dict of per-client weight vectors).

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Perform the encrypt_lst_ndarray operation.

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt element-wise.

Return type:

list | None

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

Paillier

Paillier-Based Multi-Input Inner-Product Functional Encryption | Multi-input construction inspired by | “Multi-Input Functional Encryption for Inner Products: | Function-Hiding Realizations and Constructions without Pairings” | By Michel Abdalla, Dario Catalano, Dario Fiore, Romain Gay, Bogdan Ursu | Published in: CRYPTO 2018 | | Instantiated here with a Paillier-based single-input building block inspired by | Agrawal, Libert, Stehle: | “Fully Secure Functional Encryption for Inner Products, from Standard | Assumptions” | Published in: CRYPTO 2016

  • type: public-key encryption

  • setting: Integer based

  • note: research-oriented Python prototype aligned with the existing

    crypto-ipfe API style

class pyfe4ai.schemes.mife.paillier.MIFEPaillierKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for Paillier-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

setup()[source]

Generate master public and secret keys for the scheme.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

A dict of public parameters, or None on error.

get_private_keys(nid, **kwargs)[source]

Perform the get_private_keys operation.

Parameters:

nid (str) – Node identifier.

Return type:

dict | None

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict | None

class pyfe4ai.schemes.mife.paillier.MIFEPaillier(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for Paillier-based multi-input inner-product FE.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

encrypt(lst_pt)[source]
Parameters:

lst_pt (list)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight)[source]

Decrypt ciphertexts and recover the inner product.

Parameters:
  • dct_ct (dict) – Ciphertext dict (or dict of per-client ciphertexts).

  • dk (dict) – Functional decryption key.

  • fusion_weight (dict) – Fusion weight vector (or dict of per-client weight vectors).

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Perform the encrypt_lst_ndarray operation.

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt element-wise.

Return type:

list | None

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

FH-IPE (Pairing)

Function-Hiding Multi-Input Inner-Product Encryption over Pairings | Multi-input organization inspired by | “Multi-Input Functional Encryption for Inner Products: | Function-Hiding Realizations and Constructions without Pairings” | By Michel Abdalla, Dario Catalano, Dario Fiore, Romain Gay, Bogdan Ursu | Published in: CRYPTO 2018 | | This prototype composes per-client pairing-based FH-IPE instances and | adapts them to the repository’s MIFE API.

  • type: public-key encryption

  • setting: Pairing based

  • note: research prototype aligned with the existing crypto-ipfe API

class pyfe4ai.schemes.mife.fh_ipe_pairing.MIFEFHIPEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for function-hiding multi-input IPE over pairings.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

setup()[source]

Generate master public and secret keys for the scheme.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

A dict of public parameters, or None on error.

get_private_keys(nid, **kwargs)[source]

Perform the get_private_keys operation.

Parameters:

nid (str) – Node identifier.

Return type:

dict | None

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict | None

class pyfe4ai.schemes.mife.fh_ipe_pairing.MIFEFHIPE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for function-hiding multi-input IPE over pairings.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

encrypt(lst_pt)[source]
Parameters:

lst_pt (list)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight)[source]

Decrypt ciphertexts and recover the inner product.

Parameters:
  • dct_ct (dict) – Ciphertext dict (or dict of per-client ciphertexts).

  • dk (dict) – Functional decryption key.

  • fusion_weight (dict) – Fusion weight vector (or dict of per-client weight vectors).

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Perform the encrypt_lst_ndarray operation.

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt element-wise.

Return type:

list | None

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

FH-Multi-IPE (Pairing)

Function-Hiding Multi-Input Inner-Product Encryption over Pairings | Based on | “Full-Hiding (Unbounded) Multi-Input Inner Product Functional Encryption | from the k-Linear Assumption” | By Palash Datta, Tatsuaki Okamoto, Jun Tomida | See ePrint 2018/061 | | This prototype follows the GoFE innerprod/fullysec/fh_multi_ipe.go | organization and adapts it to the repository’s MIFE API.

  • type: public-key encryption

  • setting: Pairing based

  • note: research prototype aligned with the existing crypto-ipfe API

class pyfe4ai.schemes.mife.fh_multi_ipe_pairing.MIFEFHMultiIPEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for function-hiding multi-slot multi-input IPE over pairings.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

setup()[source]

Generate master public and secret keys for the scheme.

Return type:

None

get_public_parameters()[source]

Return serialisable public parameters.

Return type:

dict

Returns:

A dict of public parameters, or None on error.

get_private_keys(nid, **kwargs)[source]

Perform the get_private_keys operation.

Parameters:

nid (str) – Node identifier.

Return type:

dict | None

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

sid (str) – Session / decryption-key identifier.

Return type:

dict | None

class pyfe4ai.schemes.mife.fh_multi_ipe_pairing.MIFEFHMultiIPE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for function-hiding multi-slot multi-input IPE over pairings.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

encrypt(lst_pt)[source]
Parameters:

lst_pt (list)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight=None)[source]

Decrypt ciphertexts and recover the inner product.

Parameters:
  • dct_ct (dict) – Ciphertext dict (or dict of per-client ciphertexts).

  • dk (dict) – Functional decryption key.

  • fusion_weight (dict | None, default: None) – Fusion weight vector (or dict of per-client weight vectors).

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Perform the encrypt_lst_ndarray operation.

Parameters:

lst_ndarray (list) – List of numpy arrays to encrypt element-wise.

Return type:

list | None

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Compute inner products on encrypted ndarray ciphertexts.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:

dict_ndarray_ct (dict) – Encrypted ndarray ciphertexts (list or dict).

Return type:

list | None