MCFE — Multi-Client Functional Encryption

Multi-client functional encryption schemes.

class pyfe4ai.schemes.mcfe.MCFE(config)[source]

Bases: IPFEAbsCrypto

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

Parameters:

config (dict)

__init__(config)[source]

Initialise the MCFE 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, label)[source]

Encrypt a plaintext vector for one client under a label.

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

  • label (str) – Encryption label binding the ciphertext to a session.

Return type:

dict

Returns:

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

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

Decrypt aggregated ciphertexts to recover the multi-client 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.

  • label (str) – The encryption label used during encrypt().

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 with a label.

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

  • **kwargs – Must include label.

Return type:

list | None

Returns:

List of object ndarrays containing per-element ciphertexts.

decrypt_lst_ndarray_ct(dict_ndarray_ct, dk, fusion_weight, label)[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.

  • label (str) – The encryption label.

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, fusion_weight, and label.

Return type:

list | None

Returns:

Decrypted ndarray list.

class pyfe4ai.schemes.mcfe.MCFEKeyGenerator(config, **kwargs)[source]

Bases: DDHKeyGeneratorBase

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the MCFE 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.mcfe.DMCFE

alias of DecentralizedMCFE

pyfe4ai.schemes.mcfe.DMCFEKeyGenerator

alias of DecentralizedMCFEKeyGenerator

class pyfe4ai.schemes.mcfe.DecentralizedMCFEFHMultiIPE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for decentralized function-hiding multi-client 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, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • lst_pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

Return type:

dict

derive_function_decryption_key_share(fusion_weight)[source]
Parameters:

fusion_weight (dict)

Return type:

dict

combine_function_decryption_key_share(dct_dk_shares)[source]
Parameters:

dct_dk_shares (dict)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[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).

  • label (str) – Encryption label for replay protection.

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.mcfe.DecentralizedMCFEFHMultiIPEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for decentralized function-hiding multi-client 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

pyfe4ai.schemes.mcfe.DMCFELWE

alias of DecentralizedMCFELWE

pyfe4ai.schemes.mcfe.DMCFELWEKeyGenerator

alias of DecentralizedMCFELWEKeyGenerator

pyfe4ai.schemes.mcfe.DMCFERingLWE

alias of DecentralizedMCFERingLWE

pyfe4ai.schemes.mcfe.DMCFERingLWEKeyGenerator

alias of DecentralizedMCFERingLWEKeyGenerator

class pyfe4ai.schemes.mcfe.MCFEPaillier(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for Paillier-based multi-client 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, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • lst_pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[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).

  • label (str) – Encryption label for replay protection.

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.mcfe.MCFEPaillierKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for Paillier-based multi-client 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.mcfe.DecentralizedMCFEPaillier(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Decentralized Paillier MCFE: each client encrypts and derives functional decryption key shares locally. A combiner merges shares and decrypts the inner product.

Protocol flow:
  1. Each client i encrypts x_i under label ℓ.

  2. Given a function vector y = (y_1, …, y_n), each client i locally computes a DK share from (s_i, u_i, v_i, y).

  3. A combiner collects DK shares, aggregates, then decrypts ⟨x, y⟩ from the ciphertexts.

Parameters:

config (dict)

scheme_type = 'dMCFE_PAILLIER'
__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

encrypt(lst_pt, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • lst_pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

Return type:

dict

derive_function_decryption_key_share(fusion_weight)[source]

Derive this client’s DK share for the given function vector.

Each client i computes:

dk0_i = sum_j s_i[j] * y_i[j] dk1_i = sum_j u_i[j] * y_i[j] + sum_k v_i[k] * y_flat[k]

where y_flat is the concatenation of y vectors for all clients in a fixed (sorted) order.

Parameters:

fusion_weight (dict)

Return type:

dict

combine_function_decryption_key_share(dct_dk_shares)[source]

Aggregate per-client DK shares.

Because sum_i v_i = 0, the correlated-noise terms cancel:

dk0 = {nid: dk0_nid} dk1 = sum_i dk1_i = sum_i (u_i · y_i)

Parameters:

dct_dk_shares (dict)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[source]

Decrypt the inner product ⟨x, y⟩ from aggregated ciphertexts.

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).

  • label (str) – Encryption label for replay protection.

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, **kwargs)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:

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

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

class pyfe4ai.schemes.mcfe.DecentralizedMCFEPaillierKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for decentralized Paillier-based multi-client 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]

Not used — clients derive DK shares locally.

Parameters:

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

Return type:

dict | None

pyfe4ai.schemes.mcfe.MCFEDamgardDDH

alias of MCFEDamgard

pyfe4ai.schemes.mcfe.MCFEDamgardDDHKeyGenerator

alias of MCFEDamgardKeyGenerator

class pyfe4ai.schemes.mcfe.MCFEFullySecLWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for fully secure LWE-based multi-client 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, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • lst_pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[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).

  • label (str) – Encryption label for replay protection.

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.mcfe.MCFEFullySecLWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for fully secure LWE-based multi-client 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.mcfe.MCFEFHMultiIPE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for function-hiding multi-client 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, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • lst_pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[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).

  • label (str) – Encryption label for replay protection.

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.mcfe.MCFEFHMultiIPEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for function-hiding multi-client 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.mcfe.ThresholdMCFEFHMultiIPE(config, **kwargs)[source]

Bases: MCFEFHMultiIPE

Crypto operations for threshold function-hiding multi-client IPE over pairings.

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:

int

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 encrypted ndarray ciphertexts element-wise.

Parameters:

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

Return type:

list

class pyfe4ai.schemes.mcfe.ThresholdMCFEFHMultiIPEKeyGenerator(config, **kwargs)[source]

Bases: MCFEFHMultiIPEKeyGenerator

Key generator for threshold function-hiding multi-client IPE over pairings.

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:

A dict of public parameters, or None on error.

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.mcfe.MCFELWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the MCFE LWE crypto system.

Parameters:

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

Return type:

None

encrypt(lst_pt, label)[source]

Encrypt a plaintext vector for one client under a label.

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

  • label (str) – Encryption label binding the ciphertext to a session.

Return type:

dict

Returns:

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

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

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

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

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

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

  • label (str) – The encryption label used during encrypt().

Returns:

The inner product as an integer.

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

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

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

  • **kwargs – Must include label.

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, fusion_weight, and label.

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, fusion_weight, and label.

Return type:

list | None

Returns:

List of float ndarrays with decrypted values.

class pyfe4ai.schemes.mcfe.MCFELWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the MCFE LWE key generator.

Parameters:

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

Return type:

None

setup()[source]

Generate per-client secret keys, label masks, 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, bound_u, label_modulus, 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 and u label mask, or None if 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) and z (aggregated label masking secret).

Raises:
class pyfe4ai.schemes.mcfe.MCFERingLWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for Ring-LWE-based multi-client 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, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • matrix_pt (list[list[int]]) – Integer plaintext matrix.

  • label (str) – Encryption label for replay protection.

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[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).

  • label (str) – Encryption label for replay protection.

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.mcfe.MCFERingLWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for Ring-LWE-based multi-client 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.mcfe.ThresholdMCFE(config)[source]

Bases: IPFEAbsCrypto

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

Parameters:

config (dict)

encrypt(pt, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

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

combine_decrypt(dict_ct_prime)[source]
Parameters:

dict_ct_prime (dict)

Return type:

float

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

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.

static L(sid, sid_v, lst_sid_enrolled)[source]

Compute the Lagrange interpolation coefficient.

Parameters:
  • sid – Session / decryption-key identifier.

  • sid_v (dict) – Set of enrolled node identifiers.

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

Return type:

int

class pyfe4ai.schemes.mcfe.ThresholdMCFEKeyGenerator(config)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for threshold DDH-based multi-client 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 | None

class pyfe4ai.schemes.mcfe.ThresholdMCFELWE(config, **kwargs)[source]

Bases: MCFELWE

Crypto operations for threshold LWE-based multi-client 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, fusion_weight, and label.

Return type:

list

Returns:

List of float ndarrays with decrypted values.

class pyfe4ai.schemes.mcfe.ThresholdMCFELWEKeyGenerator(config, **kwargs)[source]

Bases: MCFELWEKeyGenerator

Key generator for threshold LWE-based multi-client 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, bound_u, label_modulus, 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.mcfe.ThresholdMCFERingLWE(config, **kwargs)[source]

Bases: MCFERingLWE

Crypto operations for threshold Ring-LWE-based multi-client 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:

list[int]

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 encrypted ndarray ciphertexts element-wise.

Parameters:

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

Return type:

list

class pyfe4ai.schemes.mcfe.ThresholdMCFERingLWEKeyGenerator(config, **kwargs)[source]

Bases: MCFERingLWEKeyGenerator

Key generator for threshold Ring-LWE-based multi-client 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:

A dict of public parameters, or None on error.

get_decryption_keys(sid, **kwargs)[source]

Perform the get_decryption_keys operation.

Parameters:

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

Return type:

dict | None

DDH

Chotard, Jérémy, Edouard Dufour Sans, Romain Gay, Duong Hieu Phan, and David Pointcheval. “Decentralized multi-client functional encryption for inner product.” In Advances in Cryptology ASIACRYPT 2018, Brisbane, QLD, Australia, December 2-6, pp. 703-732. Springer International Publishing, 2018.

  • setting: Integer based

class pyfe4ai.schemes.mcfe.ddh.MCFEKeyGenerator(config, **kwargs)[source]

Bases: DDHKeyGeneratorBase

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the MCFE 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.mcfe.ddh.MCFE(config)[source]

Bases: IPFEAbsCrypto

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

Parameters:

config (dict)

__init__(config)[source]

Initialise the MCFE 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, label)[source]

Encrypt a plaintext vector for one client under a label.

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

  • label (str) – Encryption label binding the ciphertext to a session.

Return type:

dict

Returns:

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

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

Decrypt aggregated ciphertexts to recover the multi-client 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.

  • label (str) – The encryption label used during encrypt().

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 with a label.

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

  • **kwargs – Must include label.

Return type:

list | None

Returns:

List of object ndarrays containing per-element ciphertexts.

decrypt_lst_ndarray_ct(dict_ndarray_ct, dk, fusion_weight, label)[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.

  • label (str) – The encryption label.

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, fusion_weight, and label.

Return type:

list | None

Returns:

Decrypted ndarray list.

DDH Decentralized

Abdalla, Michel, Fabrice Benhamouda, Markulf Kohlweiss, and Hendrik Waldner. “Decentralizing inner-product functional encryption.” In IACR International Workshop on Public Key Cryptography, pp. 128-157. Cham: Springer International Publishing, 2019.

  • setting: Integer based

class pyfe4ai.schemes.mcfe.ddh_decentralized.DecentralizedMCFEKeyGenerator(config, **kwargs)[source]

Bases: DDHKeyGeneratorBase

Key generator for decentralized DDH-based multi-client 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)[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.mcfe.ddh_decentralized.DecentralizedMCFE(config)[source]

Bases: IPFEAbsCrypto

Crypto operations for decentralized DDH-based multi-client inner-product FE.

Parameters:

config (dict)

encrypt(lst_pt, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • lst_pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

Return type:

dict

derive_function_decryption_key_share(fusion_weight)[source]
Parameters:

fusion_weight (dict)

Return type:

dict

combine_function_decryption_key_share(dct_dk_shares)[source]
Parameters:

dct_dk_shares (dict)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[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).

  • label (str) – Encryption label for replay protection.

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, label)[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).

  • label (str) – Encryption label for replay protection.

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.mcfe.ddh_threshold.ThresholdMCFEKeyGenerator(config)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for threshold DDH-based multi-client 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 | None

class pyfe4ai.schemes.mcfe.ddh_threshold.ThresholdMCFE(config)[source]

Bases: IPFEAbsCrypto

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

Parameters:

config (dict)

encrypt(pt, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

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

combine_decrypt(dict_ct_prime)[source]
Parameters:

dict_ct_prime (dict)

Return type:

float

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

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.

static L(sid, sid_v, lst_sid_enrolled)[source]

Compute the Lagrange interpolation coefficient.

Parameters:
  • sid – Session / decryption-key identifier.

  • sid_v (dict) – Set of enrolled node identifiers.

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

Return type:

int

Damgård DDH

Damgard/DDH-Based Multi-Client Inner-Product Functional Encryption | Multi-client label-aware structure inspired by | “Decentralized multi-client functional encryption for inner product” | By Jeremy Chotard, Edouard Dufour Sans, Romain Gay, Duong Hieu Phan, | David Pointcheval | Published in: ASIACRYPT 2018 | | Instantiated here with a Damgard/DDH-based inner-product FE 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.mcfe.damgard_ddh.MCFEDamgardKeyGenerator(config, **kwargs)[source]

Bases: DamgardDDHKeyGeneratorBase

Key generator for Damgard DDH-based multi-client 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.mcfe.damgard_ddh.MCFEDamgard(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for Damgard DDH-based multi-client 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, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • lst_pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[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).

  • label (str) – Encryption label for replay protection.

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-Client Inner-Product Functional Encryption | Multi-client label-aware organization inspired by | “Decentralized multi-client functional encryption for inner product” | By Jeremy Chotard, Edouard Dufour Sans, Romain Gay, Duong Hieu Phan, | David Pointcheval | Published in: ASIACRYPT 2018 | | This prototype composes per-client simple LWE inner-product FE instances | using a bounded label embedding, with the underlying LWE line taken from | “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.mcfe.lwe.MCFELWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the MCFE LWE key generator.

Parameters:

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

Return type:

None

setup()[source]

Generate per-client secret keys, label masks, 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, bound_u, label_modulus, 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 and u label mask, or None if 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) and z (aggregated label masking secret).

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

Bases: IPFEAbsCrypto

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the MCFE LWE crypto system.

Parameters:

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

Return type:

None

encrypt(lst_pt, label)[source]

Encrypt a plaintext vector for one client under a label.

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

  • label (str) – Encryption label binding the ciphertext to a session.

Return type:

dict

Returns:

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

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

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

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

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

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

  • label (str) – The encryption label used during encrypt().

Returns:

The inner product as an integer.

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

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

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

  • **kwargs – Must include label.

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, fusion_weight, and label.

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, fusion_weight, and label.

Return type:

list | None

Returns:

List of float ndarrays with decrypted values.

Fully-Secure LWE

Fully Secure LWE-Based Multi-Client Inner-Product Functional Encryption | Multi-client label-aware organization inspired by | “Decentralized multi-client functional encryption for inner product” | By Jeremy Chotard, Edouard Dufour Sans, Romain Gay, Duong Hieu Phan, | David Pointcheval | Published in: ASIACRYPT 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.mcfe.fullysec_lwe.MCFEFullySecLWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for fully secure LWE-based multi-client 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.mcfe.fullysec_lwe.MCFEFullySecLWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for fully secure LWE-based multi-client 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, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • lst_pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[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).

  • label (str) – Encryption label for replay protection.

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 Decentralized

Decentralized LWE-Based Multi-Client Inner-Product Functional Encryption | Decentralized key-share organization inspired by | “Decentralizing inner-product functional encryption” | By Michel Abdalla, Fabrice Benhamouda, Markulf Kohlweiss, Hendrik Waldner | Published in: PKC 2019 | | This prototype combines decentralized decryption-key-share derivation with | the LWE-based single-input inner-product FE line from | “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: research prototype aligned with the existing crypto-ipfe API

class pyfe4ai.schemes.mcfe.lwe_decentralized.DecentralizedMCFELWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for decentralized LWE-based multi-client 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.mcfe.lwe_decentralized.DecentralizedMCFELWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for decentralized LWE-based multi-client 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, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • lst_pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

Return type:

dict

derive_function_decryption_key_share(fusion_weight)[source]
Parameters:

fusion_weight (dict)

Return type:

dict

combine_function_decryption_key_share(dct_dk_shares)[source]
Parameters:

dct_dk_shares (dict)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[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).

  • label (str) – Encryption label for replay protection.

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, **kwargs)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:

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

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

LWE Threshold

Threshold LWE-Based Multi-Client 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 LWE-based | multi-client inner-product FE line used in this repository.

  • type: public-key encryption

  • setting: Integer based

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

class pyfe4ai.schemes.mcfe.lwe_threshold.ThresholdMCFELWEKeyGenerator(config, **kwargs)[source]

Bases: MCFELWEKeyGenerator

Key generator for threshold LWE-based multi-client 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, bound_u, label_modulus, 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.mcfe.lwe_threshold.ThresholdMCFELWE(config, **kwargs)[source]

Bases: MCFELWE

Crypto operations for threshold LWE-based multi-client 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, fusion_weight, and label.

Return type:

list

Returns:

List of float ndarrays with decrypted values.

Ring-LWE

Ring-LWE-Based Multi-Client Inner-Product Functional Encryption | Multi-client label-aware organization inspired by | “Decentralized multi-client functional encryption for inner product” | By Jeremy Chotard, Edouard Dufour Sans, Romain Gay, Duong Hieu Phan, | David Pointcheval | Published in: ASIACRYPT 2018 | | This prototype combines the repository’s MCFE 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 and labels

class pyfe4ai.schemes.mcfe.ring_lwe.MCFERingLWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for Ring-LWE-based multi-client 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.mcfe.ring_lwe.MCFERingLWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for Ring-LWE-based multi-client 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, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • matrix_pt (list[list[int]]) – Integer plaintext matrix.

  • label (str) – Encryption label for replay protection.

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[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).

  • label (str) – Encryption label for replay protection.

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

Ring-LWE Decentralized

Decentralized Ring-LWE-Based Multi-Client Inner-Product Functional Encryption | Decentralized key-share organization inspired by | “Decentralizing inner-product functional encryption” | By Michel Abdalla, Fabrice Benhamouda, Markulf Kohlweiss, Hendrik Waldner | Published in: PKC 2019 | | This prototype combines decentralized decryption-key-share derivation with | the Ring-LWE multi-client inner-product FE line used in this repository.

  • type: public-key encryption

  • setting: Integer based

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

class pyfe4ai.schemes.mcfe.ring_lwe_decentralized.DecentralizedMCFERingLWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for decentralized Ring-LWE-based multi-client 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.mcfe.ring_lwe_decentralized.DecentralizedMCFERingLWE(config, **kwargs)[source]

Bases: MCFERingLWE

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

derive_function_decryption_key_share(fusion_weight)[source]
Parameters:

fusion_weight (dict)

Return type:

dict

combine_function_decryption_key_share(dct_dk_shares)[source]
Parameters:

dct_dk_shares (dict)

Return type:

dict

Ring-LWE Threshold

Threshold Ring-LWE-Based Multi-Client 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 Ring-LWE | multi-client inner-product FE line used in this repository.

  • type: public-key encryption

  • setting: Integer based

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

class pyfe4ai.schemes.mcfe.ring_lwe_threshold.ThresholdMCFERingLWEKeyGenerator(config, **kwargs)[source]

Bases: MCFERingLWEKeyGenerator

Key generator for threshold Ring-LWE-based multi-client 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:

A dict of public parameters, or None on error.

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.mcfe.ring_lwe_threshold.ThresholdMCFERingLWE(config, **kwargs)[source]

Bases: MCFERingLWE

Crypto operations for threshold Ring-LWE-based multi-client 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:

list[int]

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 encrypted ndarray ciphertexts element-wise.

Parameters:

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

Return type:

list

Paillier

Paillier-Based Multi-Client Inner-Product Functional Encryption | Multi-client label-aware structure inspired by | “Decentralized multi-client functional encryption for inner product” | By Jeremy Chotard, Edouard Dufour Sans, Romain Gay, Duong Hieu Phan, | David Pointcheval | Published in: ASIACRYPT 2018 | | Instantiated here with a Paillier-based inner-product FE 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.mcfe.paillier.MCFEPaillierKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for Paillier-based multi-client 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.mcfe.paillier.MCFEPaillier(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for Paillier-based multi-client 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, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • lst_pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[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).

  • label (str) – Encryption label for replay protection.

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 Decentralized

Decentralized Paillier-Based Multi-Client Inner-Product Functional Encryption

This module is a research-oriented Python prototype — not a verbatim transcription of any single paper. The design draws on two main references:

  • Decentralized DK-share derivation pattern (correlated-noise v-shares with sum_i v_i = 0, label-masked encryption, per-client local DK computation): Inspired by — Abdalla, Benhamouda, Kohlweiss, Waldner, “Decentralizing Inner-Product Functional Encryption”, PKC 2019.

  • Paillier-based inner-product FE building block (Paillier encryption with homomorphic aggregation, L-function extraction): Inspired by — Agrawal, Libert, Stehlé, “Fully Secure Functional Encryption for Inner Products, from Standard Assumptions”, CRYPTO 2016.

Key simplifications relative to the papers:

  • Trusted setup (a single party samples all client secrets) rather than the interactive DKG protocol described in the PKC 2019 compiler.

  • Label masking uses SHA-256 hashed to a scalar (md5_hash alias), not the paper’s random-oracle-based PRF family.

  • Paillier generator selection follows a simplified safe-prime pipeline rather than the full CRS generation of the CRYPTO 2016 scheme.

  • No formal simulation-based security proof accompanies this code; correctness has been verified via unit tests only.

  • type: public-key encryption

  • setting: Integer based

class pyfe4ai.schemes.mcfe.paillier_decentralized.DecentralizedMCFEPaillierKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for decentralized Paillier-based multi-client 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]

Not used — clients derive DK shares locally.

Parameters:

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

Return type:

dict | None

class pyfe4ai.schemes.mcfe.paillier_decentralized.DecentralizedMCFEPaillier(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Decentralized Paillier MCFE: each client encrypts and derives functional decryption key shares locally. A combiner merges shares and decrypts the inner product.

Protocol flow:
  1. Each client i encrypts x_i under label ℓ.

  2. Given a function vector y = (y_1, …, y_n), each client i locally computes a DK share from (s_i, u_i, v_i, y).

  3. A combiner collects DK shares, aggregates, then decrypts ⟨x, y⟩ from the ciphertexts.

Parameters:

config (dict)

scheme_type = 'dMCFE_PAILLIER'
__init__(config, **kwargs)[source]

Perform the __init__ operation.

Parameters:

config (dict) – Scheme configuration dict.

Return type:

None

encrypt(lst_pt, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • lst_pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

Return type:

dict

derive_function_decryption_key_share(fusion_weight)[source]

Derive this client’s DK share for the given function vector.

Each client i computes:

dk0_i = sum_j s_i[j] * y_i[j] dk1_i = sum_j u_i[j] * y_i[j] + sum_k v_i[k] * y_flat[k]

where y_flat is the concatenation of y vectors for all clients in a fixed (sorted) order.

Parameters:

fusion_weight (dict)

Return type:

dict

combine_function_decryption_key_share(dct_dk_shares)[source]

Aggregate per-client DK shares.

Because sum_i v_i = 0, the correlated-noise terms cancel:

dk0 = {nid: dk0_nid} dk1 = sum_i dk1_i = sum_i (u_i · y_i)

Parameters:

dct_dk_shares (dict)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[source]

Decrypt the inner product ⟨x, y⟩ from aggregated ciphertexts.

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).

  • label (str) – Encryption label for replay protection.

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, **kwargs)[source]

Decrypt encrypted ndarray ciphertexts element-wise.

Parameters:

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

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

FH-Multi-IPE (Pairing)

Function-Hiding Multi-Client Inner-Product Encryption over Pairings | Multi-client label-aware structure inspired by | “Decentralized multi-client functional encryption for inner product” | By Jeremy Chotard, Edouard Dufour Sans, Romain Gay, Duong Hieu Phan, | David Pointcheval | Published in: ASIACRYPT 2018 | | Instantiated here with a function-hiding multi-input inner-product FE | building block 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

  • type: public-key encryption

  • setting: Pairing based

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

    crypto-ipfe API style

class pyfe4ai.schemes.mcfe.fh_multi_ipe_pairing.MCFEFHMultiIPEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for function-hiding multi-client 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.mcfe.fh_multi_ipe_pairing.MCFEFHMultiIPE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for function-hiding multi-client 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, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • lst_pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[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).

  • label (str) – Encryption label for replay protection.

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 Decentralized (Pairing)

Decentralized Function-Hiding Multi-Client Inner-Product Encryption over Pairings | Decentralized key-share organization inspired by | “Decentralizing inner-product functional encryption” | By Michel Abdalla, Fabrice Benhamouda, Markulf Kohlweiss, Hendrik Waldner | Published in: PKC 2019 | | This prototype combines decentralized function-key-share derivation with the | repository’s MCFE FHMultiIPE line. The outer label correction is distributed | across clients via additive padding shares, while each client locally derives | its own pairing-based FHMultiIPE inner key share.

  • type: public-key encryption

  • setting: Pairing based

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

class pyfe4ai.schemes.mcfe.fh_multi_ipe_pairing_decentralized.DecentralizedMCFEFHMultiIPEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for decentralized function-hiding multi-client 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.mcfe.fh_multi_ipe_pairing_decentralized.DecentralizedMCFEFHMultiIPE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for decentralized function-hiding multi-client 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, label)[source]

Encrypt plaintext and return a ciphertext dict.

Parameters:
  • lst_pt (list) – Integer plaintext vector.

  • label (str) – Encryption label for replay protection.

Return type:

dict

derive_function_decryption_key_share(fusion_weight)[source]
Parameters:

fusion_weight (dict)

Return type:

dict

combine_function_decryption_key_share(dct_dk_shares)[source]
Parameters:

dct_dk_shares (dict)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight, label)[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).

  • label (str) – Encryption label for replay protection.

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 Threshold (Pairing)

Threshold Function-Hiding Multi-Client Inner-Product Encryption over Pairings | Threshold secure aggregation organization inspired by | “TAPFed: Threshold Secure Aggregation for Privacy-Preserving Federated Learning” | | This prototype combines threshold sharing of the label-correction term with | the pairing-based MCFE FHMultiIPE line used in this repository.

  • type: public-key encryption

  • setting: Pairing based

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

    The current threshold layer shares the label-correction component, while reusing the full FHMultiIPE inner decryption key per server.

class pyfe4ai.schemes.mcfe.fh_multi_ipe_pairing_threshold.ThresholdMCFEFHMultiIPEKeyGenerator(config, **kwargs)[source]

Bases: MCFEFHMultiIPEKeyGenerator

Key generator for threshold function-hiding multi-client IPE over pairings.

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:

A dict of public parameters, or None on error.

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.mcfe.fh_multi_ipe_pairing_threshold.ThresholdMCFEFHMultiIPE(config, **kwargs)[source]

Bases: MCFEFHMultiIPE

Crypto operations for threshold function-hiding multi-client IPE over pairings.

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:

int

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 encrypted ndarray ciphertexts element-wise.

Parameters:

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

Return type:

list