Procházet zdrojové kódy

Revert changes from db494ddaaf0a9659414085425a157144358ebabb 4c79d3210df53fb0a20ef34aacdfd8dc52c58417

Dmitriy Suponitskiy před 1 rokem
rodič
revize
526dc2db2a

+ 0 - 2
src/lib/bindings.cpp

@@ -1041,8 +1041,6 @@ void bind_encodings(py::module &m)
             py::arg("sf"))
             py::arg("sf"))
         .def("GetSchemeID", &PlaintextImpl::GetSchemeID,
         .def("GetSchemeID", &PlaintextImpl::GetSchemeID,
             ptx_GetSchemeID_docs)
             ptx_GetSchemeID_docs)
-        .def("__len__", &PlaintextImpl::GetLength,
-            ptx_GetLength_docs)
         .def("GetLength", &PlaintextImpl::GetLength,
         .def("GetLength", &PlaintextImpl::GetLength,
             ptx_GetLength_docs)
             ptx_GetLength_docs)
         .def("GetSchemeID", &PlaintextImpl::GetSchemeID,
         .def("GetSchemeID", &PlaintextImpl::GetSchemeID,

+ 0 - 2
src/lib/binfhe_bindings.cpp

@@ -140,7 +140,6 @@ void bind_binfhe_keys(py::module &m) {
   py::class_<LWEPrivateKeyImpl, std::shared_ptr<LWEPrivateKeyImpl>>(
   py::class_<LWEPrivateKeyImpl, std::shared_ptr<LWEPrivateKeyImpl>>(
       m, "LWEPrivateKey")
       m, "LWEPrivateKey")
       .def(py::init<>())
       .def(py::init<>())
-      .def("__len__", &LWEPrivateKeyImpl::GetLength)    
       .def("GetLength", &LWEPrivateKeyImpl::GetLength)
       .def("GetLength", &LWEPrivateKeyImpl::GetLength)
       .def(py::self == py::self)
       .def(py::self == py::self)
       .def(py::self != py::self);
       .def(py::self != py::self);
@@ -149,7 +148,6 @@ void bind_binfhe_ciphertext(py::module &m) {
   py::class_<LWECiphertextImpl, std::shared_ptr<LWECiphertextImpl>>(
   py::class_<LWECiphertextImpl, std::shared_ptr<LWECiphertextImpl>>(
       m, "LWECiphertext")
       m, "LWECiphertext")
       .def(py::init<>())
       .def(py::init<>())
-      .def("__len__", &LWECiphertextImpl::GetLength)
       .def("GetLength", &LWECiphertextImpl::GetLength)
       .def("GetLength", &LWECiphertextImpl::GetLength)
       .def("GetModulus", &GetLWECiphertextModulusWrapper)
       .def("GetModulus", &GetLWECiphertextModulusWrapper)
       .def(py::self == py::self)
       .def(py::self == py::self)

+ 3 - 6
tests/test_boolean.py

@@ -3,10 +3,9 @@ import pytest
 
 
 
 
 ## Sample Program: Step 1: Set CryptoContext
 ## Sample Program: Step 1: Set CryptoContext
-@pytest.mark.parametrize("context",[TOY,MEDIUM,STD128])
 @pytest.mark.parametrize("a", [0, 1])
 @pytest.mark.parametrize("a", [0, 1])
 @pytest.mark.parametrize("b", [0, 1])
 @pytest.mark.parametrize("b", [0, 1])
-def test_boolean_AND(context,a, b):
+def test_boolean_AND(a, b):
     cc = BinFHEContext()
     cc = BinFHEContext()
 
 
     """
     """
@@ -15,13 +14,13 @@ def test_boolean_AND(context,a, b):
     MEDIUM corresponds to the level of more than 100 bits for both quantum and
     MEDIUM corresponds to the level of more than 100 bits for both quantum and
     classical computer attacks
     classical computer attacks
     """
     """
-    cc.GenerateBinFHEContext(context, GINX)
+    cc.GenerateBinFHEContext(STD128, GINX)
 
 
     ## Sample Program: Step 2: Key Generation
     ## Sample Program: Step 2: Key Generation
 
 
     # Generate the secret key
     # Generate the secret key
     sk = cc.KeyGen()
     sk = cc.KeyGen()
-    assert sk.GetLength() == len(sk)
+
     print("Generating the bootstrapping keys...\n")
     print("Generating the bootstrapping keys...\n")
 
 
     # Generate the bootstrapping keys (refresh and switching keys)
     # Generate the bootstrapping keys (refresh and switching keys)
@@ -38,8 +37,6 @@ def test_boolean_AND(context,a, b):
     ct1 = cc.Encrypt(sk, a)
     ct1 = cc.Encrypt(sk, a)
     ct2 = cc.Encrypt(sk, b)
     ct2 = cc.Encrypt(sk, b)
 
 
-    assert ct1.GetLength() == len(ct1)
-    
     # Sample Program: Step 4: Evaluation
     # Sample Program: Step 4: Evaluation
 
 
     # Compute (1 AND 1) = 1; Other binary gate options are OR, NAND, and NOR
     # Compute (1 AND 1) = 1; Other binary gate options are OR, NAND, and NOR

+ 2 - 14
tests/test_cryptocontext.py

@@ -1,26 +1,14 @@
 import pytest
 import pytest
 import openfhe as fhe
 import openfhe as fhe
 
 
-@pytest.mark.skipif(fhe.get_native_int() != 128, reason="Only for NATIVE_INT=128")
-@pytest.mark.parametrize("scaling", [fhe.FIXEDAUTO, fhe.FIXEDMANUAL])
-def test_ckks_context_nativeint128(scaling):
-    batch_size = 8
-    parameters = fhe.CCParamsCKKSRNS()
-    parameters.SetMultiplicativeDepth(5)
-    parameters.SetScalingModSize(78)
-    parameters.SetBatchSize(batch_size)
-    parameters.SetScalingTechnique(scaling)
-    parameters.SetNumLargeDigits(2)
-    cc = fhe.GenCryptoContext(parameters)
-    assert isinstance(cc, fhe.CryptoContext)
-
+pytestmark = pytest.mark.skipif(fhe.get_native_int() != 128, reason="Only for NATIVE_INT=128")
 
 
 @pytest.mark.parametrize("scaling", [fhe.FIXEDAUTO, fhe.FIXEDMANUAL])
 @pytest.mark.parametrize("scaling", [fhe.FIXEDAUTO, fhe.FIXEDMANUAL])
 def test_ckks_context(scaling):
 def test_ckks_context(scaling):
     batch_size = 8
     batch_size = 8
     parameters = fhe.CCParamsCKKSRNS()
     parameters = fhe.CCParamsCKKSRNS()
     parameters.SetMultiplicativeDepth(5)
     parameters.SetMultiplicativeDepth(5)
-    parameters.SetScalingModSize(60-1)
+    parameters.SetScalingModSize(78)
     parameters.SetBatchSize(batch_size)
     parameters.SetBatchSize(batch_size)
     parameters.SetScalingTechnique(scaling)
     parameters.SetScalingTechnique(scaling)
     parameters.SetNumLargeDigits(2)
     parameters.SetNumLargeDigits(2)

+ 1 - 3
tests/test_serial_cc.py

@@ -64,9 +64,7 @@ def test_serial_cryptocontext_str(mode):
     # First plaintext vector is encoded
     # First plaintext vector is encoded
     vectorOfInts1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
     vectorOfInts1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
     plaintext1 = cryptoContext.MakePackedPlaintext(vectorOfInts1)
     plaintext1 = cryptoContext.MakePackedPlaintext(vectorOfInts1)
-    assert len(plaintext1) == plaintext1.GetLength()
-    assert len(plaintext1) == 12
-    
+
     # Second plaintext vector is encoded
     # Second plaintext vector is encoded
     vectorOfInts2 = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12]
     vectorOfInts2 = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12]
     plaintext2 = cryptoContext.MakePackedPlaintext(vectorOfInts2)
     plaintext2 = cryptoContext.MakePackedPlaintext(vectorOfInts2)