#pragma once /** @file @brief 192/256-bit additive homomorphic encryption by lifted-ElGamal @author MITSUNARI Shigeo(@herumi) @license modified new BSD license http://opensource.org/licenses/BSD-3-Clause */ #include #include #include namespace mcl { #ifdef MCL_USE_AHE192 namespace ahe192 { const mcl::EcParam& para = mcl::ecparam::NIST_P192; typedef mcl::FpT Fp; typedef mcl::FpT Zn; typedef mcl::EcT Ec; typedef mcl::ElgamalT ElgamalEc; typedef ElgamalEc::PrivateKey SecretKey; typedef ElgamalEc::PublicKey PublicKey; typedef ElgamalEc::CipherText CipherText; static inline void initAhe() { Fp::init(para.p); Zn::init(para.n); Ec::init(para.a, para.b); Ec::setIoMode(16); Zn::setIoMode(16); } static inline void initSecretKey(SecretKey& sec) { const Ec P(Fp(para.gx), Fp(para.gy)); sec.init(P, Zn::getBitSize(), mcl::getRandomGenerator()); } } //mcl::ahe192 #endif #ifdef MCL_USE_AHE256 namespace ahe256 { const mcl::EcParam& para = mcl::ecparam::NIST_P256; typedef mcl::FpT Fp; typedef mcl::FpT Zn; typedef mcl::EcT Ec; typedef mcl::ElgamalT ElgamalEc; typedef ElgamalEc::PrivateKey SecretKey; typedef ElgamalEc::PublicKey PublicKey; typedef ElgamalEc::CipherText CipherText; static inline void initAhe() { Fp::init(para.p); Zn::init(para.n); Ec::init(para.a, para.b); Ec::setIoMode(16); Zn::setIoMode(16); } static inline void initSecretKey(SecretKey& sec) { const Ec P(Fp(para.gx), Fp(para.gy)); sec.init(P, Zn::getBitSize(), mcl::getRandomGenerator()); } } //mcl::ahe256 #endif } // mcl