proof of concept implementation of pvac-hfhe, which is based on the assumption of binary parity for learning with noise and arithmetic on a 127-bit prime field.
we rely on a syndrome graph constructed from a dense random k-uniform hypergraph, and the choice of parameters is based on results on threshold behavior and fractional colorability of random hypergraphs from the works of the moscow institute of physics and technology (MIPT), this is the very first implementation of the beginning of 2024 in its original form.
ps: look at the attachments.
| requirement | ver |
|---|---|
| c++ stand | C++17 or later |
| compiler | GCC 9+, Clang 10+, MSVC 2019+ |
| cpu | x86-64 with PCLMUL (recommended) |
git clone https://github.com/octra-labs/pvac_hfhe_cpp.git
cd pvac_hfhe_cpp#include <pvac/pvac.hpp>build and run:
make test-hfhe-native
PVAC_HFHE_DEPTH_ROUNDS=63 make test-hfhe-depth
make build/recrypt_usage
./build/recrypt_usage#include <iostream>
#include <pvac/pvac.hpp>
using namespace pvac;
int main() {
// key generation
Params prm;
PubKey pk;
SecKey sk;
keygen(prm, pk, sk);
// encrypt values (client-side)
Cipher a = enc_value(pk, sk, 42);
Cipher b = enc_value(pk, sk, 17);
// homo ops (server-side)
Cipher sum = ct_add(pk, a, b); // 42 + 17
Cipher diff = ct_sub(pk, a, b); // 42 - 17
Cipher prod = ct_mul(pk, a, b); // 42 * 17
// decrypt results (client-side)
std::cout << "42 + 17 = " << IsOne(dec_value(pk, sk, sum) == fp_from_u64(59)) << "\n";
std::cout << "42 - 17 = " << fp_IsOne(dec_value(pk, sk, diff) == fp_from_u64(25)) << "\n";
std::cout << "42 * 17 = " << fp_IsOne(dec_value(pk, sk, prod) == fp_from_u64(714)) << "\n";
return 0;
}g++ -std=c++17 -O2 -march=native -I./include example.cpp -o example
./example