#include #include "BGN.hpp" int main(void) { BGN system; // const PrivateKey sk = system.get_private_key(); Scalar test0(0); Scalar test1(1); Scalar test3(3); Scalar test5(5); Scalar test6(6); Scalar test10(10); Scalar test15(15); Scalar test30(30); Scalar decrypted; std::cout << "Scalar test value (0): " << test0 << std::endl; std::cout << "Scalar test value (1): " << test1 << std::endl; std::cout << "Scalar test value (3): " << test3 << std::endl; std::cout << "Scalar test value (5): " << test5 << std::endl; CurveBipoint encrypted0, encrypted1, encrypted3, encrypted6; TwistBipoint encrypted5, encrypted10; Quadripoint encrypted15, encrypted30; std::cout << "Performing encryptions" << std::endl; system.encrypt(encrypted0, test0); system.encrypt(encrypted1, test1); system.encrypt(encrypted3, test3); system.encrypt(encrypted5, test5); std::cout << "Performing additions" << std::endl; encrypted6 = system.homomorphic_addition(encrypted3, encrypted3); encrypted10 = system.homomorphic_addition(encrypted5, encrypted5); std::cout << "Performing multiplication" << std::endl; encrypted15 = system.homomorphic_multiplication(encrypted3, encrypted5); std::cout << "Performing L2 addition" << std::endl; encrypted30 = system.homomorphic_addition(encrypted15, encrypted15); std::cout << "Performing decryptions" << std::endl; decrypted = system.decrypt(encrypted0); std::cout << "Decryption of point at infinity (0): "; if (decrypted == test0) std::cout << "PASS" << std::endl; else std::cout << "FAIL" << std::endl; decrypted = system.decrypt(encrypted1); std::cout << "Decryption of generator (1): "; if (decrypted == test1) std::cout << "PASS" << std::endl; else std::cout << "FAIL" << std::endl; decrypted = system.decrypt(encrypted1); std::cout << "Memoization: "; if (decrypted == test1) std::cout << "PASS" << std::endl; else std::cout << "FAIL" << std::endl; decrypted = system.decrypt(encrypted3); std::cout << "Decryption of normal point in G (3): "; if (decrypted == test3) std::cout << "PASS" << std::endl; else std::cout << "FAIL" << std::endl; decrypted = system.decrypt(encrypted5); std::cout << "Decryption of normal point in H (5): "; if (decrypted == test5) std::cout << "PASS" << std::endl; else std::cout << "FAIL" << std::endl; decrypted = system.decrypt(encrypted6); std::cout << "Addition in G: "; if (decrypted == test6) std::cout << "PASS" << std::endl; else std::cout << "FAIL" << std::endl; decrypted = system.decrypt(encrypted10); std::cout << "Addition in H: "; if (decrypted == test10) std::cout << "PASS" << std::endl; else std::cout << "FAIL" << std::endl; decrypted = system.decrypt(encrypted15); std::cout << "Multiplication (G by H): "; if (decrypted == test15) std::cout << "PASS" << std::endl; else std::cout << "FAIL" << std::endl; decrypted = system.decrypt(encrypted30); std::cout << "Addition in G_T: "; if (decrypted == test30) std::cout << "PASS" << std::endl; else std::cout << "FAIL" << std::endl; return 0; }