123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- from openfhe import *
- cc = BinFHEContext()
- cc.GenerateBinFHEContext(STD128,LMKCDEY)
- sk = cc.KeyGen()
- print("Generating the bootstrapping keys...\n")
- cc.BTKeyGen(sk)
- print("Completed the key generation.\n")
- """
- Encrypt two ciphertexts representing Boolean True (1).
- By default, freshly encrypted ciphertexts are bootstrapped.
- If you wish to get a fresh encryption without bootstrapping, write
- ct1 = cc.Encrypt(sk, 1, FRESH)
- """
- ct1 = cc.Encrypt(sk, 1)
- ct2 = cc.Encrypt(sk, 1)
- ctAND1 = cc.EvalBinGate(AND, ct1, ct2)
- ct2Not = cc.EvalNOT(ct2)
- ctAND2 = cc.EvalBinGate(AND, ct2Not, ct1)
- ctResult = cc.EvalBinGate(OR, ctAND1, ctAND2)
- result = cc.Decrypt(sk, ctResult)
- print(f"Result of encrypted computation of (1 AND 1) OR (1 AND (NOT 1)) = {result}")
|