Ver código fonte

initial python serial example

Rener Oliveira (Ubuntu WSL) 2 anos atrás
pai
commit
f67bfafec2
1 arquivos alterados com 24 adições e 0 exclusões
  1. 24 0
      src/pke/examples/simple-integers-serial.py

+ 24 - 0
src/pke/examples/simple-integers-serial.py

@@ -0,0 +1,24 @@
+# Initial Settings
+from openfhe import *
+# import openfhe.PKESchemeFeature as Feature
+
+datafolder = 'demoData'
+
+print("This program requres the subdirectory `" + datafolder + "' to exist, otherwise you will get an error writing serializations.")
+
+# Sample Program: Step 1: Set CryptoContext
+parameters = CCParamsBFVRNS()
+parameters.SetPlaintextModulus(65537)
+parameters.SetMultiplicativeDepth(2)
+
+cryptoContext = GenCryptoContext(parameters)
+# Enable features that you wish to use
+cryptoContext.Enable(PKESchemeFeature.PKE)
+cryptoContext.Enable(PKESchemeFeature.KEYSWITCH)
+cryptoContext.Enable(PKESchemeFeature.LEVELEDSHE)
+
+## Not working yet
+if not SerializeToFile(datafolder + "/cryptocontext.txt", cryptoContext, 'binary'):
+   raise Exception("Error writing serialization of the crypto context to cryptocontext.txt")
+
+