Encryption HElib中的密钥加密

Encryption HElib中的密钥加密,encryption,helib,Encryption,Helib,问题是关于中的对称密钥加密,并且同态执行一些加法和乘法 在某些情况下,我们希望使用密钥加密消息,然后执行操作(不需要公钥)。 然而,在HElib中几乎没有关于这方面的其他信息 HElib中的一些给定代码如下所示: // Encryption using the secret key, this is useful, e.g., to put an // encryption of the secret key into the public key. long SecKey::skEncrypt

问题是关于中的对称密钥加密,并且同态执行一些加法和乘法

在某些情况下,我们希望使用密钥加密消息,然后执行操作(不需要公钥)。 然而,在HElib中几乎没有关于这方面的其他信息

HElib中的一些给定代码如下所示:

// Encryption using the secret key, this is useful, e.g., to put an
// encryption of the secret key into the public key.
long SecKey::skEncrypt(Ctxt& ctxt,
                       const NTL::ZZX& ptxt,
                       long ptxtSpace,
                       long skIdx) const
{....}
对于这个函数,当我测试这两个实现之间的性能时,我发现密钥版本的时间开销几乎等于公钥版本的时间开销

HELIB_NTIMER_START(Enc_testSecKeyEnc);
//    Ctxt ctxt1(publicKey);
//    ea.encrypt(ctxt1, publicKey, cmsg1);
    Ctxt ctxt1(secretKey);
    EncodedPtxt eptxt;
    ea.encode(eptxt, cmsg1);
    secretKey.Encrypt(ctxt1, eptxt);
    HELIB_NTIMER_STOP(Enc_testSecKeyEnc);
    printNamedTimer(cout, "Enc_testSecKeyEnc");
    
    vector<long> res1(ea.size());
    
    HELIB_NTIMER_START(Dec_testSecKeyEnc);
    ea.decrypt(ctxt1, secretKey, res1);
    HELIB_NTIMER_STOP(Dec_testSecKeyEnc);
    printNamedTimer(cout, "Dec_testSecKeyEnc");

或者我们如何实现基于HElib的对称HE?
Public-Key:
Enc_testSecKeyEnc: 0.023451 / 1 = 0.023451   [/Users/qifanwang/code/ePPDSC/ePPDSC/tests/HEmatrix_test.cpp:102]
Dec_testSecKeyEnc: 0.115884 / 1 = 0.115884   [/Users/qifanwang/code/ePPDSC/ePPDSC/tests/HEmatrix_test.cpp:110]

Secret-Key:
Enc_testSecKeyEnc: 0.030688 / 1 = 0.026804   [/Users/qifanwang/code/ePPDSC/ePPDSC/tests/HEmatrix_test.cpp:102]
Dec_testSecKeyEnc: 0.114252 / 1 = 0.114252   [/Users/qifanwang/code/ePPDSC/ePPDSC/tests/HEmatrix_test.cpp:114]

Parameters:
m = 18944, p = 127, phi(m) = 9216
  ord(p) = 36
  normBnd = 1.27247
  polyNormBnd = 1.27247
  factors = [2 37]
  generator 3 has order (!= Z_m^*) of 64
  generator 1153 has order (== Z_m^*) of 4
r = 1
nslots = 256
hwt = 0
ctxtPrimes = [6,7,8]
specialPrimes = [9,10]
number of bits = 262
security level = 118.653