Reading many papers in the homomorphic encryption domain and in cryptography, a lot of schemes operate on bits as 1 and 0.

If I wanted to implement a scheme, for example, Gentry's FHE, would I have to encode inputs as "bits" or just use bytes (C & C++ (char), Golang(byte), etc)?

  • 1
    $\begingroup$ Using natural numbers should probably also be an option for FHE. Implementations are generally using bytes or words; when encoding a number you can always leave the most significant bits set to zero. Not answering, there are better experts on FHE on this site. $\endgroup$
    – Maarten Bodewes
    Jun 27, 2018 at 13:07

1 Answer 1


That issue is not really relevant when one implements such schemes, because the plaintexts are typically used only in the encryption, where they are combined with big values that need to be encoded as big integers anyway.

All the homomorphic operations should not depend on the plaintext, so, the chosen encoding is irrelevant here.

And even if the decryption outputs a single bit, all the operations done in the decryption function are performed also over big integers.

As an example, the scheme implemented by Leo Ducas uses a regular C integer to encode input bits, as you can see in lines 29 and 30 of file LWE.h from his Github repository.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.