API Reference¶
Top-level package¶
pyfe4ai: Python Functional Encryption for AI Security and Privacy.
The package exports its entry points:
create()builds the key generator of a scheme given by its id"family/variant"and returns it with the scheme’s crypto class;list_schemes(),get_scheme()(aScheme: classes, kind, capabilities, review status),CAPABILITIESandget_scheme_status()query the scheme registry (pyfe4ai.core.registry);backend_info()(pyfe4ai.backend.backend_info()) reports the backend in use (native extension or Python), the extension’s build, the threads, the Gaussian sampler and the parameter cache directory;the exceptions and warnings of the library.
The scheme classes themselves are exported by the family packages
pyfe4ai.schemes.sife, mife,
mcfe and quadratic, the ML
adapter by pyfe4ai.ml.
pyfe4ai exports the entry points of the library:
create()– the key generator of a scheme given by its id"family/variant", built from a config and not yet set up, with the scheme’s crypto class (CreatedScheme);the queries of the scheme registry (
pyfe4ai.core.registry):list_schemes(),get_scheme()(aScheme: classes, kind, capabilities, review status),CAPABILITIES,get_scheme_status()andSchemeStatus;backend_info()(backend_info()) – the backend the calling thread uses (the native extension or the Python implementation) and how it was chosen, the extension’s version and build, the threads per native call, the Gaussian sampler and the parameter cache directory; importingpyfe4aidoes not load the extension, calling it does. Without the extension the library also says so once, with anFEWarningat the first fallback to Python (Native Backend);the exceptions:
FEErrorand its subclassesFEConfigError,FEKeyError,FEValidationError(also aValueError),FESchemeError(also aRuntimeError) andMixedSharingsError(anFESchemeError);the warnings
FESecurityWarningandFEWarning;__version__.
The scheme classes are exported by the family packages
(pyfe4ai.schemes.sife, mife,
mcfe, quadratic), named
after their scheme’s id (see pyfe4ai.core.registry). The status and
security-profile modules are documented on Security & Status.
Public and internal modules¶
Public – what applications use; changes are listed in the changelog (from version 0.3.0: Upgrading from 0.3.0):
pyfe4ai(above);the family packages
pyfe4ai.schemes.sife,mife,mcfeandquadratic: the key generators and crypto classes and their documented methods (the scheme modules, e.g.pyfe4ai.schemes.mcfe.ring_lwe, document them);pyfe4ai.core.registry,pyfe4ai.core.config(the config classes and their options),pyfe4ai.core.status,pyfe4ai.core.profiles,pyfe4ai.core.exceptionsandpyfe4ai.core.ids(the rules for server and client ids, withis_idandas_id);from
pyfe4ai.backend:available,get_backend,set_backend,backend,active_backend,get_threads,set_threads,implementation,describe,backend_infoandMISSING_EXTENSION_NOTICE;the few entry points in otherwise internal modules that the documentation names:
get_gaussian_sampler,set_gaussian_samplerandgaussian_sampler(pyfe4ai.primitives.sampling),pairing_availableandDEFAULT_PAIRING_GROUP(pyfe4ai.primitives.pairing.pairing_backend),PartialDecryptionBudget(pyfe4ai.schemes.threshold.kl) anddefault_cache_dir(pyfe4ai.core.base).
Internal – documented here for contributors and reviewers; they may change in any version without notice:
pyfe4ai.core.base(the base classes and the parameter cache),pyfe4ai.core.formatsandpyfe4ai.core.versions(the classes that describe the serialized objects and their version markers; the serialized formats themselves are documented and versioned there),pyfe4ai.core.one_time,pyfe4ai.core.forksafe(the fork handler; what threads, copies andforkdo is on Threads, Processes and Copies),pyfe4ai.core.constants;pyfe4ai.schemes.common,pyfe4ai.schemes.thresholdand the helpers of the scheme modules other than their classes;pyfe4ai.primitivesand the rest ofpyfe4ai.backend: the interface the scheme and primitive layers call (pyfe4ai.backend.ops(),pyfe4ai.backend.ring(),pyfe4ai.backend.interface) and its two implementations (pyfe4ai.backend.python_impl,pyfe4ai.backend.native_impl);pyfe4ai._validationand the native extensionpyfe4ai._rust_native.
The package is organised in layers:
pyfe4ai.core– base classes and the parameter cache, the configurations (pyfe4ai.core.config), the serialized objects (pyfe4ai.core.formats) and their versions (pyfe4ai.core.versions), security profiles, review status, one-time precomputations, the fork handler, exceptions;pyfe4ai.schemes– the schemes by family (sife,mife,mcfe,quadratic), with the components several families share inpyfe4ai.schemes.commonandpyfe4ai.schemes.threshold;pyfe4ai.primitives– lattices, Gaussian sampling, hashing, groups and pairings;pyfe4ai.backend– the operations the schemes and primitives take from a backend (pyfe4ai.backend.interface), their native (Rust) and Python implementations, the selection between them, and threads;pyfe4ai.ml– the ML adapter (encrypted inference, federated aggregation) and quantization.
- Core
- SIFE — Single-Input Functional Encryption
- MIFE — Multi-Input Functional Encryption
- MCFE — Multi-Client Functional Encryption
- DDH
- DDH over ristretto255
- DDH Decentralized
- DDH Threshold
- Damgård DDH
- LWE
- Fully-Secure LWE
- LWE Decentralized
- LWE Threshold
- Ring-LWE
- Ring-LWE Decentralized
- Ring-LWE Threshold
- Paillier
- Paillier Decentralized
- FH-Multi-IPE (Pairing)
- FH-Multi-IPE Decentralized (Pairing)
- FH-Multi-IPE Threshold (Pairing)
- Building Blocks
- Quadratic FE
- Shared Scheme Components
- Configuration
SHARING_SCHEMESPER_SAMPLEFLOODINGSKEY_SHARESDEFAULT_CT_FORMATDEFAULT_RING_MODULUSDerivedOptionSchemeConfigconfig_class()config_classes()STANDARD_MINIMASTANDARD_PRESETSSTANDARD_PAIRING_GROUPSTANDARD_FIXEDresolve()validate_sharing()resolve_sharing()flooding_config()check_kl_threshold()check_kl_flooding()check_kl_sharing()threshold_key_shares()check_no_flooding_options()ETA()BOUND_X()BOUND_Y()BOUND()GROUP()MODULUS_LENGTH()BIT_LENGTH()LWE_N()MATRIX_MODE()GAUSSIAN_SAMPLER()LIBRARY_SAMPLER()RING_MODULUS()RING_N()LABEL_HASH()PAIRING_GROUP_PARAM()T()S()LST_SID()SHARING()FLOODING_ACCOUNTING()MAX_PARTIAL_DECRYPTIONS()STAT_PARAM()DDHConfigRistrettoConfigDamgardDDHConfigPaillierConfigLWEConfigABDP15ConfigRingLWEConfigPairingIPEConfigThresholdConfigThresholdSharingConfigCryptoConfigSIFEDDHConfigSIFEDDHRistretto255ConfigSIFELWEConfigSIFEPaillierConfigSIFEDamgardConfigSIFERingLWEConfigSIFEFullySecRingLWEConfigSIFEFullySecLWEConfigSIFEDDHDynamicConfigSIFEFHIPEPairingConfigSIFEPartFHIPEPairingConfigMIFEDDHConfigMIFEDDHRistretto255ConfigMIFELWEConfigMIFEPaillierConfigMIFEDamgardConfigMIFERingLWEConfigMIFEFullySecLWEConfigMIFEFHIPEPairingConfigMIFEFHMultiIPEPairingConfigThresholdMIFEDDHConfigThresholdMIFELWEConfigMCFEDDHConfigMCFEDDHRistretto255ConfigMCFELWEConfigMCFEPaillierConfigMCFEDamgardConfigMCFERingLWEConfigMCFEFullySecLWEConfigMCFEFHMultiIPEPairingConfigThresholdMCFEFHMultiIPEPairingConfigDecentralizedMCFEFHMultiIPEPairingConfigThresholdMCFEDDHConfigDecentralizedMCFEDDHConfigThresholdMCFELWEConfigDecentralizedMCFELWEConfigThresholdMCFERingLWEConfigDecentralizedMCFERingLWEConfigDecentralizedMCFEPaillierConfigQuadraticQuadConfigQuadraticSGPConfigQuadraticMIQFEConfigCombinationCOMBINATIONSoptions_rst()
- Primitives
- Native Backend
- ML Adapter