This example demonstrates a complete privacy-preserving machine learning workflow using PVAC-HFHE. A credit scoring neural network evaluates loan applications on encrypted data, ensuring both the model and applicant data remain private.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/octra-labs/pvac_hfhe_cpp/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The credit scoring system implements:- 8-input features: Age, income, debt, savings, credit history, employment, defaults, and open accounts
- Hidden layer: 4 neurons with cubic activation (x³)
- Output: Single risk score (negative = low risk, positive = high risk)
- Fully homomorphic: All computations on encrypted data
This demonstrates PVAC-HFHE’s capability to run real machine learning models on encrypted data with verifiable computation.
Architecture
Model structure
Features
| Index | Feature | Unit | Description |
|---|---|---|---|
| 0 | age | years | Applicant’s age |
| 1 | income_k | thousands | Annual income |
| 2 | debt_k | thousands | Outstanding debt |
| 3 | savings_k | thousands | Total savings |
| 4 | history_score | 0-100 | Credit history score |
| 5 | employment_years | years | Years at current job |
| 6 | defaults | count | Past payment defaults |
| 7 | open_accounts | count | Active credit lines |
Decision logic
Implementation
Key generation with custom parameters
Use optimized parameters for ML workloads:
These reduced parameters enable fast demos. For production, use default parameters from
Params constructor (m_bits=8192, lpn_n=4096).Complete example
Sample data
The example includes a CSV dataset with test applicants:Loading from CSV
Example output
Privacy guarantees
This implementation provides:- Client privacy: Applicant features remain encrypted throughout evaluation
- Model privacy: Server can’t determine exact model weights from operations
- Verifiability: All computations can be verified using PVAC commitments
- No trusted party: Neither client nor server can cheat undetected
Workflow summary
Performance characteristics
Circuit complexity
- Depth: 496 layers (cubic activation creates depth-3 operations per neuron)
- Size: ~4,500 edges per inference
- Inference time: Fast with demo parameters, production parameters provide stronger security
Scaling to production
For production deployments:Extending the model
Adding more neurons
Different activation functions
Multi-class output
Building and running
Source files
Complete source code:examples/ml/credit_scoring.cpp- Main inference codeexamples/ml/credit_db.csv- Sample applicant dataexamples/ml/README.md- Additional documentation
Applications
This pattern extends to many privacy-preserving ML scenarios:- Healthcare: Diagnose patients without revealing medical records
- Finance: Risk assessment with private financial data
- Hiring: Candidate evaluation without bias or data exposure
- Insurance: Premium calculation on encrypted claims history
- Fraud detection: Pattern matching on encrypted transactions
Next steps
Basic usage
Learn PVAC-HFHE fundamentals
Polynomial evaluation
Understand activation functions
API reference
Explore all available functions
Core concepts
Understand the fundamentals