Skip to content

How to use signum? #9

@zzzhhhlll

Description

@zzzhhhlll

m_cc->Enable(ADVANCEDSHE);

m_OutputC = m_cc->EvalChebyshevSeries(m_InputC, coeff_val, -1, 1);

std::vector<Ciphertext<DCRTPoly>> t(1024);
int l = 512;
t[1] = m_InputC;

//--CHEBYSHEV series computation <--- this is very naively implemented---
for (int i = 2; i < l + 1; i++) {
    int j = int((i - 1) / 2) + 1;
    auto prod = m_cc->EvalMult(t[j], t[i - j]);
    t[i] = m_cc->EvalAdd(prod, prod);
    if (2 * j == i)
        m_cc->EvalSubInPlace(t[i], 1);
    else
        m_cc->EvalSubInPlace(t[i], t[2 * j - i]);
}

//----------------------------  T1009,T1011,T1013,T1015 -----------------------------

std::vector<double> coeff_val2(
    {5.3627954846304366e-05, -4.766676484102891e-05, 4.170646728565051e-05, -3.574695081520454e-05});
int len = 4;

for (int i = 0; i < len; i++) {
    double coeff = coeff_val2[i];
    auto temp1 = m_cc->EvalMult(m_cc->EvalMult(t[1 + 2 * i], coeff * 64), t[16]);
    auto temp2 = m_cc->EvalMult(t[15 - 2 * i], coeff * 32);
    temp1 = m_cc->EvalSub(temp1, temp2);
    temp1 = m_cc->EvalMult(temp1, t[32]);
    temp2 = m_cc->EvalMult(t[15 - 2 * i], coeff * 16);
    temp1 = m_cc->EvalSub(temp1, temp2);
    temp1 = m_cc->EvalMult(temp1, t[64]);
    temp2 = m_cc->EvalMult(t[15 - 2 * i], coeff * 8);
    temp1 = m_cc->EvalSub(temp1, temp2);
    temp1 = m_cc->EvalMult(temp1, t[128]);
    temp2 = m_cc->EvalMult(t[15 - 2 * i], coeff * 4);
    temp1 = m_cc->EvalSub(temp1, temp2);
    temp1 = m_cc->EvalMult(temp1, t[256]);
    temp2 = m_cc->EvalMult(t[15 - 2 * i], coeff * 2);
    temp1 = m_cc->EvalSub(temp1, temp2);
    temp1 = m_cc->EvalMult(temp1, t[512]);
    temp2 = m_cc->EvalMult(t[15 - 2 * i], coeff);
    auto t59 = m_cc->EvalSub(temp1, temp2);
    m_OutputC = m_cc->EvalAdd(m_OutputC, t59);
}

Could you explain these codes, please? By the way, how should I use it to compare two ciphertexts, what is the required multiplication depth, and how is the precision controlled?"Thank you very much.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions