SIFE — Single-Input Functional Encryption

Single-input functional encryption schemes: the key generator and crypto class of every scheme of the family (the registry: pyfe4ai.core.registry).

The key generator and crypto class of every scheme below are importable from pyfe4ai.schemes.sife under their own names (one name per class, no aliases; the naming rule is in pyfe4ai.core.registry).

DDH

Simple Single Input Functional Encryption | From “Simple Functional Encryption Schemes for Inner Products” | Published in: PKC 2015 | By Michel Abdalla, Florian Bourse, Angelo De Caro, and David Pointcheval | URL: https://eprint.iacr.org/2015/017.pdf

  • type: public-key encryption

  • setting: Integer based (order-q subgroup of Z_p^*, p = 2q + 1)

Construction 1 of ABDP15 (DDH): mpk = (g, h_i = g^{s_i}); the key for y is sk_y = <s, y> mod q; ct = (g^r, h_i^r g^{x_i}); decryption computes prod ct_i^{y_i} / ct_0^{sk_y} = g^{<x, y>} and a bounded discrete log (dlog_bound, default 10^(precision + 2)). Every ciphertext component is reduced modulo p – versions <= 0.2.0 published the integer (h_i^r mod p)(g^{x_i} mod p), from which x_i follows by trial division – and keys are reduced modulo q.

class pyfe4ai.schemes.sife.ddh.SIFEDDHKeyGenerator(config, **kwargs)[source]

Bases: DDHKeyGeneratorBase

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the SIFE key generator.

Parameters:

config (dict) – Scheme configuration. Recognised keys: sec_param, eta (plaintext vector length).

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, eta, sec_param).

Return type:

dict

Returns:

Dict of public parameters.

get_private_keys(nid='nid_default')[source]

Return encryption keys (group element list gs).

Parameters:

nid (str, default: 'nid_default') – Client identifier (unused for single-input schemes).

Return type:

dict | None

Returns:

Dict with gs list.

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 (list of int).

Return type:

dict | None

Returns:

Dict with z (<s, y> mod q) and the weights y.

Raises:
class pyfe4ai.schemes.sife.ddh.SIFEDDH(config, **kwargs)[source]

Bases: IPFEAbsCrypto

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the SIFE crypto system.

Parameters:

config (dict) – Must contain keys with pp (public parameters) and either sk (encryption keys) or dk (decryption key); dlog_bound (default 10^(precision + 2)) bounds the inner products decryption recovers.

Return type:

None

encrypt(lst_pt)[source]

Encrypt a plaintext vector under the DDH-based scheme.

Parameters:

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

Return type:

dict

Returns:

Dict with ct0 (group element) and ct1 (list of group elements).

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

Decrypt a ciphertext to recover the inner product ⟨x, y⟩.

Parameters:
Returns:

The inner product as an integer, or None if |<x, y>| exceeds dlog_bound.

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

Not implemented for this scheme; raises NotImplementedError.

Parameters:

lst_ndarray (list)

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

DDH over ristretto255

Simple Single Input Functional Encryption over ristretto255 | From “Simple Functional Encryption Schemes for Inner Products” | Published in: PKC 2015 | By Michel Abdalla, Florian Bourse, Angelo De Caro, and David Pointcheval | URL: https://eprint.iacr.org/2015/017.pdf

  • type: public-key encryption

  • setting: the prime-order group ristretto255 (RFC 9496), written additively

Construction 1 of ABDP15 (DDH), as pyfe4ai.schemes.sife.ddh but in ristretto255: mpk = (G, H_i = s_i G); the key for y is sk_y = <s, y> mod L; ct = (r G, r H_i + x_i G); decryption computes sum_i y_i ct_i - sk_y ct_0 = <x, y> G and a bounded discrete log (dlog_bound, default 10^(precision + 2)). See pyfe4ai.schemes.common.ec_ddh_base.

class pyfe4ai.schemes.sife.ddh_ristretto255.SIFEDDHRistretto255KeyGenerator(config, **kwargs)[source]

Bases: ECDDHKeyGeneratorBase

Key generator for DDH-based single-input inner-product FE over ristretto255.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Check the configuration.

Parameters:

config (dict) – eta (plaintext vector length); group (optional, "ristretto255").

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='nid_default')[source]

Encryption key {h}: the elements H_i as hex encodings.

Parameters:

nid (str, default: 'nid_default')

Return type:

dict | None

get_decryption_keys(sid, **kwargs)[source]

{z: <s, y> mod L, y} for credentials["fusion_weight"].

Parameters:

sid (str)

Return type:

dict | None

class pyfe4ai.schemes.sife.ddh_ristretto255.SIFEDDHRistretto255(config, **kwargs)[source]

Bases: ECDDHCryptoBase

Crypto operations for DDH-based single-input inner-product FE over ristretto255.

Parameters:

config (dict)

encrypt(lst_pt)[source]

{ct0: r G, ct1: [r H_i + x_i G]} for eta integers lst_pt.

Parameters:

lst_pt (list)

Return type:

dict

decrypt(dct_ct, dk, fusion_weight)[source]

<x, y>, or None if |<x, y>| exceeds dlog_bound.

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

Not implemented for this scheme; raises NotImplementedError.

Parameters:

lst_ndarray (list)

Return type:

list | None

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Aggregate ciphertexts from multiple clients.

Parameters:

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

Return type:

list | None

Returns:

Aggregated ciphertext list, or None on error.

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt aggregated ndarray ciphertexts.

Parameters:

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

Return type:

list | None

Returns:

One float array of decrypted results per layer.

Raises:

FESchemeError – If an element does not decrypt (see decoded_layer()).

DDH Dynamic

Simple Single Input Functional Encryption, variable-length vectors | From “Simple Functional Encryption Schemes for Inner Products” | Published in: PKC 2015 | By Michel Abdalla, Florian Bourse, Angelo De Caro, and David Pointcheval | URL: https://eprint.iacr.org/2015/017.pdf

  • type: public-key encryption

  • setting: Integer based (order-q subgroup of Z_p^*, p = 2q + 1)

ABDP15 Construction 1 (pyfe4ai.schemes.sife.ddh) for vectors of any length up to eta: a key for y of length k <= eta is the key of (y, 0, ..., 0), and a plaintext of length m <= eta is encrypted as a prefix of (x, 0, ..., 0) (the omitted components are a function of a full ciphertext). The key decrypts any ciphertext with at least k components. Security reduces to ABDP15 by this zero padding; there is no separate paper.

class pyfe4ai.schemes.sife.ddh_dynamic.SIFEDDHDynamicKeyGenerator(config, **kwargs)[source]

Bases: SIFEDDHKeyGenerator

ABDP15 key generator issuing keys for weight vectors of length <= eta.

Parameters:

config (dict)

get_decryption_keys(sid, **kwargs)[source]

Key for a weight prefix y (len(y) <= eta).

Return type:

dict | None

Returns:

Dict with z (<s[:k], y> mod q), y and size = k.

Parameters:

sid (str)

class pyfe4ai.schemes.sife.ddh_dynamic.SIFEDDHDynamic(config, **kwargs)[source]

Bases: SIFEDDH

ABDP15 encryption of vectors of length <= eta.

Parameters:

config (dict)

Damgård DDH

Single-Input Inner-Product Functional Encryption (Damgard / DDH) | From “Fully Secure Functional Encryption for Inner Products, | from Standard Assumptions” | By Shweta Agrawal, Benoit Libert, and Damien Stehle | Published in: CRYPTO 2016 – the DDH scheme, as recalled (D_k-MDDH, here | k = 1) in Abdalla, Catalano, Fiore, Gay, Ursu, CRYPTO 2018, Fig. 7.

  • type: public-key encryption

  • setting: Integer based (order-q subgroup of Z_p^*, p = 2q + 1)

h = g^a with a discarded ([A] with A = (1, a)); per coordinate (s_i, t_i) <- Z_q^2 and pk_i = g^{s_i} h^{t_i}. The key for y is (<s, y>, <t, y>) mod q; ct = (g^r, h^r, g^{x_i} pk_i^r); decryption computes prod e_i^{y_i} / (c^{k1} d^{k2}) = g^{<x, y>} and a discrete log bounded by eta B^2, with 2 eta B^2 < q so that signed results are unique.

class pyfe4ai.schemes.sife.damgard_ddh.SIFEDamgardKeyGenerator(config, **kwargs)[source]

Bases: DamgardDDHKeyGeneratorBase

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the SIFE Damgård DDH key generator.

Parameters:

config (dict) – Scheme configuration. Recognised keys: sec_param, eta, modulus_length (default sec_param) and bound (on inputs and weights).

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

Return the encryption key (public key vector pk).

Parameters:

nid (str, default: 'nid_default') – Client identifier (unused for single-input schemes).

Return type:

dict | None

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 (list of int).

Return type:

dict | None

class pyfe4ai.schemes.sife.damgard_ddh.SIFEDamgard(config, **kwargs)[source]

Bases: IPFEAbsCrypto

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the SIFE Damgård DDH crypto object.

Parameters:

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

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 (list) – Fusion weight vector (or dict of per-client weight vectors).

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, scaled by 10^precision.

Return type:

list | None

Returns:

One object array of ciphertexts per input array.

Raises:

NotImplementedError – If eta != 1.

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 Single-Input Inner-Product Functional Encryption | From “Simple Functional Encryption Schemes for Inner Products” | By Michel Abdalla, Florian Bourse, Angelo De Caro, David Pointcheval | Published in: PKC 2015; full version ePrint 2015/017 (revised 2015-03-28, 2015-10-01) | | This module implements the generic simple FE construction instantiated | under the LWE assumption as a research-oriented Python prototype.

  • type: public-key encryption

  • setting: Integer based

  • note: prototype implementation with the common key generator / crypto API

The scheme is the LWE instantiation as revised in the full version (Construction 4.1 over the Regev scheme of Construction 6.5, Sec. 6.2; F. Bourse, PhD thesis, ENS 2017, Fig. 8.1): uniform secrets, binary r, t(x) = x floor(q / p) and no r-ary decomposition of the message. Theorem 2 of the proceedings version does not cover it: its simulation reuses encryption randomness through the secret key and changes the basis of noisy public keys with coefficients in Z_q, and both steps fail for keys A s + e.

The full version proves selective IND-CPA with its Thm. 4.4, through public-key and ciphertext reproducibility (Thms. 6.6 and 6.7; Bourse, Thm. 4.3.5 with Thms. 8.2.2, 8.2.3, 8.3.2). The proof assumes LWE with errors of width sigma' = sigma / (1 + 2 X sqrt(eta)), the condition derived in the proof of Thm. 6.6; Sec. 6.2 lists the stronger (l B + 1) sigma'. It also needs m >= (n + eta + 1) log2 q + 2 log2(1 / eps) (proof of Thm. 6.7). See pyfe4ai.schemes.common.abdp15_lwe for the hypotheses that the library meets differently.

The public matrix A is published as a seed and expanded with SHAKE-128; encryption computes A^T r and pk^T r exactly with numpy, either over an A kept in memory or expanded for every batch (matrix_mode). See pyfe4ai.schemes.common.abdp15_lwe, which also covers the standard parameters. Versions <= 0.2.0 published A entry by entry.

class pyfe4ai.schemes.sife.lwe.SIFELWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ABDP15KeyGeneratorMixin

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the SIFE LWE key generator.

Parameters:

config (dict) – Scheme configuration. Recognised keys: sec_param, eta, lwe_n (default 32; "auto" for the smallest dimension meeting the 128-bit table, the standard profile’s choice), bound_x, bound_y and matrix_mode ("memory" or "stream", see pyfe4ai.schemes.common.abdp15_lwe).

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.

Return type:

dict

Returns:

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

get_private_keys(nid='nid_default', **kwargs)[source]

Return encryption keys (public-key matrix pk).

Parameters:

nid (str, default: 'nid_default') – Client identifier (unused for single-input schemes).

Return type:

dict | None

Returns:

Dict with pk matrix.

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 (list of int).

Return type:

dict | None

Returns:

Dict with sk_y (the projected secret key).

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

Bases: IPFEAbsCrypto, ABDP15CryptoMixin

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the SIFE LWE crypto system.

Parameters:

config (dict) – Must contain keys with pp (public parameters) and optionally sk (encryption keys); optional matrix_mode ("memory" or "stream").

Return type:

None

encrypt(lst_pt)[source]

Encrypt a plaintext vector under the LWE-based scheme.

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 a ciphertext to recover the inner product ⟨x, y⟩.

Parameters:
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) – Ciphertext arrays to aggregate.

  • **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 element-wise.

Parameters:
  • dict_ndarray_ct (dict) – List of object ndarrays with per-element ciphertexts.

  • **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 Single-Input Inner-Product Functional Encryption | Based on the LWE variant of | “Fully Secure Functional Encryption for Inner Products, | from Standard Assumptions” | By Shweta Agrawal, Benoit Libert, Damien Stehle | Published in: CRYPTO 2016 | | as recalled in Abdalla, Catalano, Fiore, Gay, Ursu, CRYPTO 2018, Fig. 8. | Parameters follow GoFE’s innerprod/fullysec/lwe.go.

  • type: public-key encryption

  • setting: Integer based

A <- Z_q^{m x n}; Z has D_{sigma1} entries in its first m/2 columns and D_{sigma2} entries plus the identity in the others; U = Z A. The key for y is Z^T y; ct = (A s + e0, U s + e1 + floor(q/K) x); decryption decodes <y, ct1> - <Z^T y, ct0>. Signed messages and weights: K = 2 eta X Y + 1 (versions <= 0.2.0 used 2 eta X Y, so +-eta X Y decoded with a random sign), centred decoding.

class pyfe4ai.schemes.sife.fullysec_lwe.SIFEFullySecLWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the fully secure SIFE LWE key generator.

Parameters:

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

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.

Return type:

dict

Returns:

Dict containing A, k, q, m, eta, lwe_n, bound_x, bound_y, and noise parameters.

get_private_keys(nid='nid_default', **kwargs)[source]

Return encryption keys (public-key matrix pk).

Parameters:

nid (str, default: 'nid_default') – Client identifier (unused for single-input schemes).

Return type:

dict | None

Returns:

Dict with pk matrix.

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 (list of int).

Return type:

dict | None

Returns:

Dict with sk_y (Z^T y) and the weights y.

Raises:
class pyfe4ai.schemes.sife.fullysec_lwe.SIFEFullySecLWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the fully secure SIFE 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 under the fully-secure LWE scheme.

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 a ciphertext to recover the inner product ⟨x, y⟩.

Parameters:
Returns:

The inner product, or None if it decodes beyond eta X Y (wrong key or ciphertext).

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) – Ciphertext arrays to aggregate.

  • **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 element-wise.

Parameters:
  • dict_ndarray_ct (dict) – List of object ndarrays with per-element ciphertexts.

  • **kwargs – Must include dk and fusion_weight.

Return type:

list | None

Returns:

List of float ndarrays with decrypted values.

Ring-LWE

Ring-LWE-Based Single-Input Inner-Product Functional Encryption | Based on | “Efficient Lattice-Based Inner-Product Functional Encryption” | By Bermudo Mera, Karmakar, Marc, Soleimanian | ePrint: 2021/046 | | (PKC 2022), Section 4 (selectively secure Ring-LWE IPFE) with the batching | of Remark 1; also informed by GoFE’s innerprod/simple/ringlwe.go.

  • type: public-key encryption

  • setting: R_q = Z_q[x] / (x^ring_n + 1), ring_n a power of two

Public a; s_i, e_i <- D_sigma1, pk_i = a s_i + e_i. The key for y is sk_y = sum y_i s_i. A plaintext is an eta x k matrix (k <= ring_n, column j in coefficient j): ct0 = a r + f0, ct_i = pk_i r + f_i + Delta x_i with r, f0 <- D_sigma2, f_i <- D_sigma3; decryption rounds sum y_i ct_i - ct0 sk_y. Parameters come from pyfe4ai.primitives.lattice.ring_lwe_utils.bmms21_parameters(); ring_n defaults to the toy value DEFAULT_RING_N (versions <= 0.2.0 claimed to derive it but always chose 32).

class pyfe4ai.schemes.sife.ring_lwe.SIFERingLWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the SIFE Ring-LWE key generator.

Parameters:

config (dict) – Scheme configuration. Recognised keys: sec_param (kappa of the noise bounds), eta, bound_x, bound_y and ring_n (default DEFAULT_RING_N; "auto" for the smallest dimension meeting the 128-bit table, the standard profile’s choice) and gaussian_sampler ("facct", the default, or "rounded"; see scheme_sampler()). ring_modulus must stay "prime": the opt-in RNS modulus is implemented for the MIFE / MCFE family only.

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

Return the encryption key (public key polynomials pk).

Parameters:

nid (str, default: 'nid_default') – Client identifier (unused for single-input schemes).

Return type:

dict | None

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 (list of int).

Return type:

dict | None

class pyfe4ai.schemes.sife.ring_lwe.SIFERingLWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the SIFE Ring-LWE crypto object.

Parameters:

config (dict) – Must contain keys with pp (public parameters) and optionally sk (encryption keys); gaussian_sampler: that of the encryption noise (default: that of pp, else "facct").

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 (list) – Fusion weight vector (or dict of per-client weight vectors).

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Not implemented for this scheme; raises NotImplementedError.

Parameters:

lst_ndarray (list)

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

Adaptively Secure Ring-LWE

Adaptively secure Ring-LWE single-input inner-product FE.

Bermudo Mera, Karmakar, Marc, Soleimanian:
“Efficient Lattice-Based Inner-Product Functional Encryption”, PKC 2022,
ePrint 2021/046 – Section 5 (adaptively secure IPFE based on RLWE), with
Theorem 1 (mhe-RLWE from RLWE), Theorem 2 (Ring-LHL) and the parameter
constraints of Appendix C.1. It is the ring counterpart of the LWE scheme
of Agrawal, Libert, Stehle (CRYPTO 2016, pyfe4ai.schemes.sife.fullysec_lwe).
  • type: public-key encryption, adaptive IND security

  • setting: R_q = Z_q[x] / (x^ring_n + 1), q an NTT-friendly prime

Construction (l = eta slots, m key polynomials, Delta = floor(q / p)):

  • Setup: a = (a_1, ..., a_m) <- R_q^m uniform with some a_j invertible; s_i = (s_i1, ..., s_im), s_ij <- D_sigma1; pk_i = <a, s_i> (no error term).

  • Encrypt: r <- D_sigma2, f0 <- D_sigma2^m, f_i <- D_sigma3; ct0 = a r + f0, ct_i = pk_i r + f_i + Delta x_i (constant coefficient, Delta x_i linear in x_i as the proof needs); resampled until some ct0_j is invertible and ct0 is proportional to a in no CRT slot.

  • KeyGen: sk_y = sum_i y_i s_i (m polynomials).

  • Decrypt: d = sum_i y_i ct_i - <ct0, sk_y>; round its constant coefficient.

Deviations from the paper:

  • m >= 5 key polynomials instead of m = 3. With the constraints of Appendix C.1, m = 3 admits no modulus: Theorem 2 (k = 2) needs the s* of game G4 -> G5 to have width sigma' >= sqrt(n ln(2mn(1 + 1/delta)) / pi) q^(2/m + eps/2), G3 -> G4 needs sigma1 >= sqrt(l) 2X sigma', Theorem 1 needs sigma2 > sigma n C sqrt(l + 2) with C = sqrt(kappa) sigma1, and the decryption noise l Y (sqrt(kappa) sigma3 + m n kappa sigma1 sigma2) then grows like q^(4/m) while it must stay below q / 2p. Theorem 2 holds for every m >= 3, so the proof is unchanged. m = "auto" (default) takes the smallest m that admits a modulus; pyfe4ai.primitives.lattice.ring_lwe_utils.bmms21_adaptive_parameters() derives the widths and q.

  • Signed inputs |x| <= X, |y| <= Y: p = 2 l X Y + 2 with centred decoding, ||x1 - x0||_inf <= 2X, and complexity leveraging over (2X + 1)^(2l) challenge pairs.

  • Gaussian samples (keys and encryption noise) are exact D_{Z,sigma} by default (gaussian_sampler = "facct", discrete_gaussian_facct()), whatever the library-wide default; "rounded" (a rounded continuous Gaussian, the library default) stays selectable. Rounded keys are 0.02 / sigma1^2 per sample, over m n eta samples, from D_{Z,sigma1} in statistical distance for an ideal rounded Gaussian – in the standard configurations from about 2^-47 (elementwise eta = 1, X = 100) over 2^-44.5 (packed eta = 1) to 2^-40.5 (eta = 4, X = Y = 4), negligible above sigma1 = 2^40 – and about 2^-12 at eta = 1 with the double-precision path’s artifacts (crypto review, October 2026), terms the proof does not account for. Python FACCT is slower than the rounded sampler at the key width sigma1 but faster beyond 2^40 (the encryption widths), where the rounded sampler needs MPFR Box-Muller.

Ciphertext layouts (ndarray_layout):

  • "elementwise" (default): one vector per ciphertext; the ndarray helper encrypts every element on its own.

  • "packed" (opt-in, experimental, its own parameter record; the leveraging argument below is this project’s own, checked independently but not published or externally reviewed): a ciphertext holds an eta x k matrix, k <= ring_n (Remark 1: Delta x_ij is added to coefficient j of ct_i), and decrypts to the k inner products <x_j, y> of its columns. The ndarray helper packs ring_n elements per ciphertext. The statistical games G3* - G5* of the proof depend on the challenge only through the span V of the differences x1_j - x0_j, so the leveraging ranges over the possible V, (D + 1) (4X + 1)^(l D) with D = min(l, ring_n), whatever k is (guessing both challenge matrices would give (2X + 1)^(2lk)); G3 -> G4 decomposes along a basis B of V, ||B|| <= 2X sqrt(l D), which sigma1 absorbs, and G4 -> G5 applies Theorem 2 once per basis vector (pyfe4ai.primitives.lattice.ring_lwe_utils.bmms21_adaptive_leveraging()). G5* writes the differences in that basis mod q, so q must exceed the minors of the basis, (2X sqrt(D))^D; the parameters enforce it (it moves e.g. eta = 24, X = 4 to a larger ring). For eta = 1, V is {0} or Q: two guesses, and the basis [1] of norm 1 instead of 2X (X = 100, Y = 1: m = 12 and a 107-bit q against m = 19 and 111 bits elementwise, whose parameters stay as they are). Encryptors and decryptors accept pp flagged "packed" only if its q, p and widths are the packed derivation.

Under the standard profile ring_n = "auto" takes the smallest ring dimension (with the smallest m) whose q meets RING_LWE_128_LOG_Q at the width sigma (about 8) of the RLWE problem of Theorem 1.

pyfe4ai.schemes.sife.fullysec_ring_lwe.LAYOUTS = ('elementwise', 'packed')

Values of the ndarray_layout option; the first is the default.

pyfe4ai.schemes.sife.fullysec_ring_lwe.DEFAULT_SAMPLER = 'facct'

the exact D_{Z,sigma} of the proof, whatever the library-wide default is.

Type:

Default Gaussian sampler of this scheme (gaussian_sampler option)

pyfe4ai.schemes.sife.fullysec_ring_lwe.encode_message(x, q, p)[source]

floor(q / p) x mod q: linear in x, as the last game of the proof needs.

Parameters:

x (int)

Return type:

mpz

pyfe4ai.schemes.sife.fullysec_ring_lwe.independent_at_every_slot(a_ntt, c_ntt, q)[source]

True iff (a(t), c(t)) has rank 2 over Z_q in every CRT slot t.

a_ntt and c_ntt hold m NTT vectors each. Then x -> (<a, x>, <c, x>) maps R_q^m onto R_q^2 (the condition of the Ring-LHL step, which the paper states as “ct0 is not a multiple of a”).

Parameters:
Return type:

bool

class pyfe4ai.schemes.sife.fullysec_ring_lwe.SIFEFullySecRingLWEKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for the adaptively secure Ring-LWE IPFE of BMMS21 (Sec. 5).

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the key generator.

Parameters:

config (dict) – Scheme configuration. Recognised keys: sec_param (kappa), eta, bound_x, bound_y, ring_n (power of two, "auto", or None for the toy default), m (number of key polynomials, at least 5, or "auto", the default), ndarray_layout ("elementwise", the default, or "packed": up to ring_n vectors per ciphertext, with parameters of their own) and gaussian_sampler ("facct", the default, or "rounded") for the keys, also published in pp as the encryptors’ default.

Raises:

FEValidationError – For an unknown ndarray_layout or sampler, or a ring_modulus other than "prime" (the adaptive proof’s Ring-LHL, Theorem 2, is for a prime q; see RNS modulus for the Ring-LWE schemes: security review).

Return type:

None

setup()[source]

Sample s_i (m polynomials per slot) and pk_i = <a, s_i>.

Return type:

None

get_public_parameters()[source]

Return a, p, q, ring_n, m, eta, the bounds and the encryption widths sigma2, sigma3, the gaussian_sampler (and ndarray_layout when packed).

Return type:

dict

get_private_keys(nid='nid_default', **kwargs)[source]

Return the encryption key: the public keys pk_i (eta polynomials).

Parameters:

nid (str, default: 'nid_default')

Return type:

dict | None

get_decryption_keys(sid, **kwargs)[source]

Derive sk_y = sum_i y_i s_i (m polynomials mod q).

Parameters:
  • sid (str) – Session identifier.

  • **kwargs – Must include credentials with fusion_weight.

Return type:

dict | None

class pyfe4ai.schemes.sife.fullysec_ring_lwe.SIFEFullySecRingLWE(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for the adaptively secure Ring-LWE IPFE of BMMS21 (Sec. 5).

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise with keys.pp and, for encryptors, keys.sk; the optional gaussian_sampler ("facct" or "rounded") of the encryption noise defaults to that of pp, else "facct".

Raises:

FEValidationError – For an unknown sampler.

Parameters:

config (dict)

Return type:

None

encrypt(lst_pt)[source]

Encrypt an integer vector of length eta or, with packed parameters, an eta x k matrix (eta rows of k <= ring_n integers; column j goes to coefficient j).

Return type:

dict

Returns:

Dict with ct0 (m polynomials) and ct (eta polynomials); for a matrix also k.

Raises:
  • FEKeyError – If public parameters or the encryption key are missing.

  • FEValidationError – If the plaintext is malformed or out of bound, or is a matrix without packed parameters (their sigma1 and leveraging cover only one vector per ciphertext).

Parameters:

lst_pt (list)

decrypt(dct_ct, dk, fusion_weight)[source]

Return <x, y>, or None if the decoded value exceeds eta X Y; for a packed ciphertext (one with k) the list of the k inner products, or None if one of them exceeds the bound.

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

Encrypt ndarrays (eta = 1): one ciphertext per element, or with packed parameters ring_n consecutive elements (row-major) per ciphertext.

A packed layer is {"shape", "first_chunk", "chunks"}, its chunks packed ciphertexts numbered consecutively across the layers (the layout of the MCFE Ring-LWE schemes, which EncryptedGradient serialises).

Parameters:

lst_ndarray (list)

Return type:

list | None

compute_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt ndarray ciphertexts (delegates to decrypt_lst_ndarray_ct()).

Parameters:

dict_ndarray_ct (dict)

Return type:

list | None

decrypt_lst_ndarray_ct(dict_ndarray_ct, **kwargs)[source]

Decrypt ndarray ciphertexts, element-wise or packed layers (transforming sk_y once); needs dk and fusion_weight.

Parameters:

dict_ndarray_ct (dict)

Return type:

list | None

Paillier

Paillier-Based Single-Input Inner-Product Functional Encryption | From “Fully Secure Functional Encryption for Inner Products, | from Standard Assumptions” | By Shweta Agrawal, Benoit Libert, and Damien Stehle | Published in: CRYPTO 2016 (DCR instantiation; recalled as Fig. 9 of | ABMPSW20, https://eprint.iacr.org/2020/788, Appendix B.1)

  • type: public-key encryption

  • setting: Integer based (Z_{N^2}^*, N = p q with safe primes)

Construction: g = g'^{2N} mod N^2; s <- D_{Z^eta, sigma} with sigma > sqrt(kappa) * N^{5/2}; h_i = g^{s_i}; ct = (g^r, (1 + N)^{x_i} h_i^r) with r <- {0..N/4}; sk_y = <s, y> over Z; <x, y> = (prod ct_i^{y_i} ct_0^{-sk_y} - 1 mod N^2) / N. The Gaussian is a rounded continuous Gaussian at bits(sigma) + 128 bits of precision and kappa is the config key stat_param (default 64).

class pyfe4ai.schemes.sife.paillier.SIFEPaillierKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the SIFE Paillier key generator.

Parameters:

config (dict) – Scheme configuration. Recognised keys: eta, bit_length (bits of each prime of N, default 128), bound_x, bound_y and stat_param (default 64).

Return type:

None

setup()[source]

Sample s <- D_{Z^eta, sigma} with sigma > sqrt(kappa) N^{5/2} (ALS16).

Versions <= 0.2.0 drew |s_i| <= max(sec_param, bound_y * eta), so s could be recovered from the public key by brute force.

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

Return the encryption key (public key vector pk).

Parameters:

nid (str, default: 'nid_default') – Client identifier (unused for single-input schemes).

Return type:

dict | None

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 (list of int).

Return type:

dict | None

class pyfe4ai.schemes.sife.paillier.SIFEPaillier(config, **kwargs)[source]

Bases: OfflineRandomMixin, IPFEAbsCrypto

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

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the SIFE Paillier crypto object.

Parameters:

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

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 (list) – Fusion weight vector (or dict of per-client weight vectors).

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, scaled by 10^precision.

Return type:

list | None

Returns:

One object array of ciphertexts per input array.

Raises:

NotImplementedError – If eta != 1.

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 Inner-Product Encryption over Pairings | “Function-Hiding Inner Product Encryption is Practical” | By Kim, Lewi, Mandal, Montgomery, Roy, Wu, SCN 2018 (ePrint 2016/440), | Section 3; structure as in GoFE’s innerprod/fullysec/fhipe.go.

  • type: secret-key encryption with function-hiding keys

  • setting: asymmetric pairing group (default BLS12-381); secure in the generic bilinear group model

B <- GL_n(Z_q) (rejection sampling), B* = det(B) (B^{-1})^T. The key for y is (g1^{alpha det B}, g1^{alpha B y}), a ciphertext of x is (g2^beta, g2^{beta B* x}); decryption pairs them and solves a bounded discrete log of e(g1, g2)^{alpha beta det B <x, y>} to base e(g1, g2)^{alpha beta det B}. Keys live in G1 and ciphertexts in G2, as in the paper (B used transposed, which is identically distributed).

Deviation: every vector is padded as x' = (x, 1, 0), y' = (y, 0, 1) (<x', y'> = <x, y>) so that n = eta + 2 >= 3 and no vector is zero: with n = 1 (B* = 1) ciphertexts and keys revealed x and y directly, and an all-zero vector was recognisable without a key – the paper requires non-zero vectors. The encryption key (g2, B*) determines B up to a scalar and is master-secret equivalent.

class pyfe4ai.schemes.sife.fh_ipe_pairing.SIFEFHIPEPairingKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for function-hiding inner-product encryption over pairings.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the SIFE FH-IPE key generator.

Parameters:

config (dict) – Scheme configuration. Recognised keys: eta, bound_x, bound_y and pairing_group_param (asymmetric group, default "BLS12-381").

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

Return the encryption key (g2, b_star); it is equivalent to the master secret key.

Parameters:

nid (str, default: 'nid_default') – Client identifier (unused for single-input schemes).

Return type:

dict | None

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 (list of int).

Return type:

dict | None

class pyfe4ai.schemes.sife.fh_ipe_pairing.SIFEFHIPEPairing(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for function-hiding inner-product encryption over pairings.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the SIFE FH-IPE crypto object.

Parameters:

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

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.

  • dk (dict) – Functional decryption key.

  • fusion_weight (list | None, default: None) – Not needed: the key encodes y and hides it (function hiding). Checked against the bounds if given.

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Not implemented for this scheme; raises NotImplementedError.

Parameters:

lst_ndarray (list)

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

Partial FH-IPE (Pairing)

Partially Function-Hiding Inner-Product Encryption over Pairings | “A New Paradigm for Public-Key Functional Encryption for Degree-2 Polynomials” | By Romain Gay, PKC 2020 (ePrint 2020/093) – Fig. 8, CPA variant (no | QANIZK), with k = 1 (SXDH); structure as in GoFE’s | innerprod/fullysec/part_fh_ipe.go.

  • type: public-key encryption for vectors in the span of a public matrix M; secret-key encryption (Enc') of arbitrary vectors

  • setting: asymmetric pairing group (default BLS12-381)

a, b <- (1, Z_q), U in Z_q^{(eta+2) x 2}, V in Z_q^{eta x 2} and a random full-rank M in Z^{eta x k} with k = subspace_dim < eta; the public key is ([a]_1, [U a]_1, V^T M, M) and msk = (b, U, V).

  • Enc(t): [c = a r ; (-V^T M t ; M t) + U c]_1 for t in Z^k.

  • Enc’(x): the same with (-V^T x ; x); needs V, so it is run by the key generator (SIFEPartFHIPEPairingKeyGenerator.sec_encrypt()).

  • KeyGen(y): [(-U^T w ; w)]_2 with w = (b s ; y + V b s).

  • Dec: prod_j e(ct_j, sk_j) = [<x, y>]_T and a bounded discrete log.

Every key holder learns M^T y (encrypt the unit vectors t = e_j and decrypt), the leakage the paper allows; for an integer y with |y_i| <= bound this often determines y unless eta - k is large, so k defaults to 1 – the public encryption space and the leakage have the same dimension k. Public encryption requires |t_i| <= coeff_bound and |M t| <= bound so that the final discrete log is feasible. Versions <= 0.2.0 handed the master secret key to every encryptor and, by default, used a square M (k = eta), which reveals V and with it y. Deviations: M and V^T M are published in the clear instead of in G1.

class pyfe4ai.schemes.sife.part_fh_ipe_pairing.SIFEPartFHIPEPairingKeyGenerator(config, **kwargs)[source]

Bases: IPFEAbsKeyGenerator, ParameterCacheMixin

Key generator for partially function-hiding inner-product encryption over pairings.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the SIFE partially FH-IPE key generator.

Parameters:

config (dict) – Scheme configuration. Recognised keys: eta, bound (or bound_x), subspace_dim (1 <= subspace_dim < eta, default 1), coeff_bound (bound on the coefficients t of public encryption, default 1) and pairing_group_param (asymmetric group, default "BLS12-381").

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

Public-key scheme: encryptors need the public parameters only.

Returns None; versions <= 0.2.0 returned the master secret key.

Parameters:

nid (str, default: 'nid_default')

Return type:

dict | None

sec_encrypt(lst_pt)[source]

Enc'(msk, x) for any x with |x_i| <= bound (needs V).

Parameters:

lst_pt (list)

Return type:

dict

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 (list of int).

Return type:

dict | None

class pyfe4ai.schemes.sife.part_fh_ipe_pairing.SIFEPartFHIPEPairing(config, **kwargs)[source]

Bases: IPFEAbsCrypto

Crypto operations for partially function-hiding inner-product encryption over pairings.

Parameters:

config (dict)

__init__(config, **kwargs)[source]

Initialise the SIFE partially FH-IPE crypto object.

Parameters:

config (dict) – Must contain keys with pp (public parameters); encryption is public-key.

Return type:

None

encrypt(lst_pt)[source]

Public Enc(t) of x = M t for k coefficients t.

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 (list | None, default: None) – Fusion weight vector (or dict of per-client weight vectors).

encrypt_lst_ndarray(lst_ndarray, **kwargs)[source]

Not implemented for this scheme; raises NotImplementedError.

Parameters:

lst_ndarray (list)

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