Bit Extraction
from concrete import fhe
@fhe.compiler({"x": "encrypted"})
def f(x):
return fhe.bits(x)[0], fhe.bits(x)[3]
inputset = range(32)
circuit = f.compile(inputset)
assert circuit.encrypt_run_decrypt(0b_00000) == (0, 0)
assert circuit.encrypt_run_decrypt(0b_00001) == (1, 0)
assert circuit.encrypt_run_decrypt(0b_01100) == (0, 1)
assert circuit.encrypt_run_decrypt(0b_01101) == (1, 1)from concrete import fhe
@fhe.compiler({"x": "encrypted"})
def f(x):
return fhe.bits(x)[1:4]
inputset = range(32)
circuit = f.compile(inputset)
assert circuit.encrypt_run_decrypt(0b_01101) == 0b_110
assert circuit.encrypt_run_decrypt(0b_01011) == 0b_101Limitations
Performance Considerations
A Chain of Individual Bit Extractions
Reuse of Intermediate Extracted Bits
TLUs of 1b input precision
Last updated
Was this helpful?