Search code examples
seal

fractional to binary with SEAL


Am I able to convert a fractional encoded ciphertext to binary encoded one?

Let's say I encrypt 5 with being fractional encoded. Then, can I an array consisting of E(1), E(0), E(1)? (5 = 101)


Solution

  • Let us try to work it out with plaintexts. Then we can try to solve it with ciphertext.

    1. If by "a binary encoded one" you meant a binary encoding of 5, then yes. Fractional encoded 5 and binary encoded 5 are both plaintext x^2+1.

    2. If by "an array consisting of E(1), E(0), E(1)" you meant 3 ciphertexts that respectively decrypt to 1, 0 and 1, then no.

    Extracting the k-th bit (denoted by m_k) of a number m from its fractional/integer/binary encoding M(x)=m_{n-1}x^{n-1}+...+m_kx^k+...+m_0, is equivalent to finding a function F such that, for a given k and any m, F(M(x))=m_k in \ZZ_2[x]/(x^n+1). Such a function is nontrivial to find. Even if it exists, it can be in the shape of a 2^n degree polynomial which is way too deep to evaluate homomorphically.

    1. If by "an array consisting of E(1), E(0), E(1)" you meant 1 ciphertext that decrypts to the vector [1, 0, 1], then no.

    One first have to solve scenario 2 stated above and successfully extract those individual bits. The rest is purely batching over ciphertexts, which can be done easily with the help of rotate_rows in SEAL.