Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pvac-hfhe-cpp


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.

info

requirements

requirement ver
c++ stand C++17 or later
compiler GCC 9+, Clang 10+, MSVC 2019+
cpu x86-64 with PCLMUL (recommended)

installation

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

example

#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

About

pvac-hfhe: PoC for publicly verifiable arithmetic computations with hypergraph based homomorphic encryption over Fp (p = 2^127 - 1), omissions for large numbers and excluded the transfer mechanism for data convertation (applies only to the prod version of octra network). c++17 header-only.

Resources

Stars

60 stars

Watchers

7 watching

Forks

Releases

Packages

Contributors

Languages