public void EncodeDecodeVectorDoubleTest() { EncryptionParameters parms = new EncryptionParameters(SchemeType.CKKS) { PolyModulusDegree = 64, CoeffModulus = new List <SmallModulus>() { DefaultParams.SmallMods30Bit(0), DefaultParams.SmallMods30Bit(1) } }; SEALContext context = SEALContext.Create(parms); CKKSEncoder encoder = new CKKSEncoder(context); Plaintext plain = new Plaintext(); double[] values = new double[] { 0.1, 2.3, 34.4 }; encoder.Encode(values, scale: Math.Pow(2, 20), destination: plain); List <double> result = new List <double>(); encoder.Decode(plain, result); Assert.IsNotNull(result); Assert.AreEqual(0.1, result[0], delta: 0.001); Assert.AreEqual(2.3, result[1], delta: 0.001); Assert.AreEqual(34.4, result[2], delta: 0.001); }
public void EncryptionParametersCompareNET() { var parms1 = new EncryptionParameters(); parms1.NoiseStandardDeviation = 3.19; parms1.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods30Bit(0) }; parms1.PlainModulus = 1 << 6; parms1.PolyModulus = "1x^64 + 1"; var parms2 = new EncryptionParameters(parms1); Assert.IsTrue(parms1.Equals(parms2)); var parms3 = new EncryptionParameters(); parms3.Set(parms2); Assert.IsTrue(parms3.Equals(parms2)); parms3.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods30Bit(1) }; Assert.IsFalse(parms3.Equals(parms2)); parms3.Set(parms2); Assert.IsTrue(parms3.Equals(parms2)); parms3.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods30Bit(0), DefaultParams.SmallMods30Bit(1) }; Assert.IsFalse(parms3.Equals(parms2)); parms3.Set(parms2); parms3.PolyModulus = "1x^128 + 1"; Assert.IsFalse(parms3.Equals(parms1)); parms3.Set(parms2); parms3.PlainModulus = (1 << 6) + 1; Assert.IsFalse(parms3.Equals(parms2)); parms3.Set(parms2); parms3.NoiseStandardDeviation = 3.18; Assert.IsFalse(parms3.Equals(parms2)); parms3.Set(parms2); parms3.PolyModulus = "1"; parms3.PolyModulus = "1x^128 + 1"; parms3.PolyModulus = "1x^64 + 1"; Assert.IsTrue(parms3.Equals(parms1)); parms3.Set(parms2); parms3.CoeffModulus = new List <SmallModulus> { 2 }; parms3.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods50Bit(0) }; parms3.CoeffModulus = parms2.CoeffModulus; Assert.IsTrue(parms3.Equals(parms2)); }
public void EncryptionParametersSetNET() { var parms = new EncryptionParameters(); parms.NoiseStandardDeviation = 0; parms.CoeffModulus = new List <SmallModulus> { }; parms.PlainModulus = 0; parms.PolyModulus = "0"; Assert.AreEqual(0.0, parms.NoiseStandardDeviation); Assert.AreEqual(0.0, parms.NoiseMaxDeviation); Assert.IsTrue(parms.CoeffModulus.Count == 0); Assert.IsTrue(parms.PlainModulus.Value == 0); Assert.IsTrue(parms.PolyModulus.ToString() == "0"); parms.NoiseStandardDeviation = 0; parms.CoeffModulus = new List <SmallModulus> { 2 }; parms.PlainModulus = 2; parms.PolyModulus = "1"; Assert.AreEqual(0.0, parms.NoiseStandardDeviation); Assert.AreEqual(0.0, parms.NoiseMaxDeviation); Assert.IsTrue(parms.CoeffModulus[0].Value == 2); Assert.IsTrue(parms.PlainModulus.Value == 2); Assert.IsTrue(parms.PolyModulus.ToString() == "1"); parms.NoiseStandardDeviation = 3.19; parms.CoeffModulus = new List <SmallModulus> { 2, 3 }; parms.PlainModulus = 2; parms.PolyModulus = "1x^2 + 1"; Assert.AreEqual(3.19, parms.NoiseStandardDeviation); Assert.AreEqual(3.19 * 6, parms.NoiseMaxDeviation); Assert.IsTrue(parms.CoeffModulus[0].Value == 2); Assert.IsTrue(parms.CoeffModulus[1].Value == 3); Assert.IsTrue(parms.PlainModulus.Value == 2); Assert.IsTrue(parms.PolyModulus.ToString() == "1x^2 + 1"); parms.NoiseStandardDeviation = 3.19; parms.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods30Bit(0), DefaultParams.SmallMods40Bit(0), DefaultParams.SmallMods50Bit(0) }; parms.PlainModulus = 2; parms.PolyModulus = "1x^128 + 1"; Assert.AreEqual(3.19, parms.NoiseStandardDeviation); Assert.AreEqual(3.19 * 6, parms.NoiseMaxDeviation); Assert.IsTrue(parms.CoeffModulus[0].Equals(DefaultParams.SmallMods30Bit(0))); Assert.IsTrue(parms.CoeffModulus[1].Equals(DefaultParams.SmallMods40Bit(0))); Assert.IsTrue(parms.CoeffModulus[2].Equals(DefaultParams.SmallMods50Bit(0))); Assert.IsTrue(parms.PolyModulus.ToString() == "1x^128 + 1"); }
public void FVKeyGenerationNET() { var parms = new EncryptionParameters(); { parms.NoiseStandardDeviation = 3.19; parms.PolyModulus = "1x^64 + 1"; parms.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods60Bit(0) }; parms.PlainModulus = 1 << 6; var context = new SEALContext(parms); var keygen = new KeyGenerator(context); Assert.IsTrue(keygen.PublicKey.HashBlock.Equals(parms.HashBlock)); Assert.IsTrue(keygen.SecretKey.HashBlock.Equals(parms.HashBlock)); var evk = new EvaluationKeys(); keygen.GenerateEvaluationKeys(60, evk); Assert.AreEqual(evk.HashBlock, parms.HashBlock); Assert.AreEqual(2, evk.Key(2)[0].Size); keygen.GenerateEvaluationKeys(30, 1, evk); Assert.AreEqual(evk.HashBlock, parms.HashBlock); Assert.AreEqual(4, evk.Key(2)[0].Size); keygen.GenerateEvaluationKeys(2, 2, evk); Assert.AreEqual(evk.HashBlock, parms.HashBlock); Assert.AreEqual(60, evk.Key(2)[0].Size); } { parms.NoiseStandardDeviation = 3.19; parms.PolyModulus = "1x^256 + 1"; parms.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods60Bit(0), DefaultParams.SmallMods30Bit(0), DefaultParams.SmallMods30Bit(1) }; parms.PlainModulus = 1 << 6; var context = new SEALContext(parms); var keygen = new KeyGenerator(context); Assert.AreEqual(keygen.PublicKey.HashBlock, parms.HashBlock); Assert.AreEqual(keygen.SecretKey.HashBlock, parms.HashBlock); var evk = new EvaluationKeys(); keygen.GenerateEvaluationKeys(60, 2, evk); Assert.AreEqual(evk.HashBlock, parms.HashBlock); Assert.AreEqual(2, evk.Key(2)[0].Size); keygen.GenerateEvaluationKeys(30, 2, evk); Assert.AreEqual(evk.HashBlock, parms.HashBlock); Assert.AreEqual(4, evk.Key(2)[0].Size); keygen.GenerateEvaluationKeys(4, 1, evk); Assert.AreEqual(evk.HashBlock, parms.HashBlock); Assert.AreEqual(30, evk.Key(2)[0].Size); } }
public void SEALContextParamsTest() { List <SmallModulus> coeffModulus = new List <SmallModulus> { DefaultParams.SmallMods30Bit(0), DefaultParams.SmallMods30Bit(1), DefaultParams.SmallMods30Bit(2) }; EncryptionParameters parms = new EncryptionParameters(SchemeType.BFV) { PolyModulusDegree = 128, PlainModulus = new SmallModulus(1 << 6), CoeffModulus = coeffModulus }; SEALContext context = SEALContext.Create(parms); SEALContext.ContextData data = context.FirstContextData; Assert.IsNotNull(data); EncryptionParameters parms2 = data.Parms; Assert.AreEqual(parms.PolyModulusDegree, parms2.PolyModulusDegree); Assert.AreEqual(parms.NoiseStandardDeviation, parms2.NoiseStandardDeviation); EncryptionParameterQualifiers qualifiers = data.Qualifiers; Assert.IsNotNull(qualifiers); Assert.IsTrue(qualifiers.ParametersSet); Assert.IsFalse(qualifiers.UsingBatching); Assert.IsTrue(qualifiers.UsingFastPlainLift); Assert.IsTrue(qualifiers.UsingFFT); Assert.IsTrue(qualifiers.UsingNTT); Assert.IsTrue(qualifiers.UsingHEStdSecurity); ulong[] cdpm = data.CoeffDivPlainModulus; Assert.AreEqual(3, cdpm.Length); Assert.AreEqual(32ul, data.PlainUpperHalfThreshold); Assert.AreEqual(3, data.PlainUpperHalfIncrement.Length); Assert.IsNull(data.UpperHalfThreshold); Assert.IsNotNull(data.UpperHalfIncrement); Assert.AreEqual(3, data.UpperHalfIncrement.Length); Assert.AreEqual(2ul, data.ChainIndex); SEALContext.ContextData data2 = data.NextContextData; Assert.IsNotNull(data2); Assert.AreEqual(1ul, data2.ChainIndex); SEALContext.ContextData data3 = data2.NextContextData; Assert.IsNotNull(data3); Assert.AreEqual(0ul, data3.ChainIndex); Assert.IsNull(data3.NextContextData); }
public void SmallMods30BitTest() { SmallModulus sm = DefaultParams.SmallMods30Bit(20); Assert.IsNotNull(sm); Assert.AreEqual(30, sm.BitCount); Assert.AreEqual(0x3BE80001ul, sm.Value); Assert.ThrowsException <ArgumentOutOfRangeException>(() => DefaultParams.SmallMods30Bit(64)); }
public void EncryptionParametersSaveLoadNET() { var stream = new MemoryStream(); var parms = new EncryptionParameters(); var parms2 = new EncryptionParameters(); parms.Save(stream); stream.Seek(0, SeekOrigin.Begin); parms2.Load(stream); Assert.AreEqual(parms.NoiseStandardDeviation, parms2.NoiseStandardDeviation); Assert.AreEqual(parms.NoiseMaxDeviation, parms2.NoiseMaxDeviation); Assert.IsTrue(parms.CoeffModulus.SequenceEqual(parms2.CoeffModulus)); Assert.IsTrue(parms.PlainModulus.Equals(parms2.PlainModulus)); Assert.IsTrue(parms.PolyModulus.Equals(parms2.PolyModulus)); Assert.IsTrue(parms.Equals(parms2)); parms.NoiseStandardDeviation = 3.19; parms.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods30Bit(0) }; parms.PlainModulus = 1 << 6; parms.PolyModulus = "1x^64 + 1"; stream.Seek(0, SeekOrigin.Begin); parms.Save(stream); stream.Seek(0, SeekOrigin.Begin); parms2.Load(stream); Assert.AreEqual(parms.NoiseStandardDeviation, parms2.NoiseStandardDeviation); Assert.AreEqual(parms.NoiseMaxDeviation, parms2.NoiseMaxDeviation); Assert.IsTrue(parms.CoeffModulus.SequenceEqual(parms2.CoeffModulus)); Assert.IsTrue(parms.PlainModulus.Equals(parms2.PlainModulus)); Assert.IsTrue(parms.PolyModulus.Equals(parms2.PolyModulus)); Assert.IsTrue(parms.Equals(parms2)); parms.NoiseStandardDeviation = 3.19; parms.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods30Bit(0), DefaultParams.SmallMods60Bit(0), DefaultParams.SmallMods60Bit(1) }; parms.PlainModulus = 1 << 30; parms.PolyModulus = "1x^256 + 1"; stream.Seek(0, SeekOrigin.Begin); parms.Save(stream); stream.Seek(0, SeekOrigin.Begin); parms2.Load(stream); Assert.AreEqual(parms.NoiseStandardDeviation, parms2.NoiseStandardDeviation); Assert.AreEqual(parms.NoiseMaxDeviation, parms2.NoiseMaxDeviation); Assert.IsTrue(parms.CoeffModulus.SequenceEqual(parms2.CoeffModulus)); Assert.IsTrue(parms.PlainModulus.Equals(parms2.PlainModulus)); Assert.IsTrue(parms.PolyModulus.Equals(parms2.PolyModulus)); Assert.IsTrue(parms.Equals(parms2)); }
public void SaveLoadPublicKeyNET() { var stream = new MemoryStream(); { var parms = new EncryptionParameters(); parms.NoiseStandardDeviation = 3.19; parms.PolyModulus = "1x^64 + 1"; parms.PlainModulus = 1 << 6; parms.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods60Bit(0) }; var context = new SEALContext(parms); var keygen = new KeyGenerator(context); var pk = keygen.PublicKey; Assert.IsTrue(pk.HashBlock.Equals(parms.HashBlock)); stream.Seek(0, SeekOrigin.Begin); pk.Save(stream); var pk2 = new PublicKey(); stream.Seek(0, SeekOrigin.Begin); pk2.Load(stream); Assert.AreEqual(pk.Data, pk2.Data); Assert.AreEqual(pk.HashBlock, pk2.HashBlock); } { var parms = new EncryptionParameters(); parms.NoiseStandardDeviation = 3.19; parms.PolyModulus = "1x^256 + 1"; parms.PlainModulus = 1 << 20; parms.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods30Bit(0), DefaultParams.SmallMods40Bit(0) }; var context = new SEALContext(parms); var keygen = new KeyGenerator(context); var pk = keygen.PublicKey; Assert.IsTrue(pk.HashBlock.Equals(parms.HashBlock)); stream.Seek(0, SeekOrigin.Begin); pk.Save(stream); var pk2 = new PublicKey(); stream.Seek(0, SeekOrigin.Begin); pk2.Load(stream); Assert.AreEqual(pk.Data, pk2.Data); Assert.AreEqual(pk.HashBlock, pk2.HashBlock); } }
public void BFVKeyGenerationNET() { var parms = new EncryptionParameters(); { parms.NoiseStandardDeviation = 3.19; parms.PolyModulus = "1x^64 + 1"; parms.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods60Bit(0) }; parms.PlainModulus = 1 << 6; var context = new SEALContext(parms); var keygen = new KeyGenerator(context); Assert.IsTrue(keygen.PublicKey.HashBlock.Equals(parms.HashBlock)); Assert.IsTrue(keygen.SecretKey.HashBlock.Equals(parms.HashBlock)); var evk = new EvaluationKeys(); keygen.GenerateEvaluationKeys(60, evk); Assert.AreEqual(evk.HashBlock, parms.HashBlock); Assert.AreEqual(2, evk.Key(2)[0].Size); keygen.GenerateEvaluationKeys(30, 1, evk); Assert.AreEqual(evk.HashBlock, parms.HashBlock); Assert.AreEqual(4, evk.Key(2)[0].Size); keygen.GenerateEvaluationKeys(2, 2, evk); Assert.AreEqual(evk.HashBlock, parms.HashBlock); Assert.AreEqual(60, evk.Key(2)[0].Size); var galks = new GaloisKeys(); keygen.GenerateGaloisKeys(60, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.AreEqual(2, galks.Key(3)[0].Size); Assert.AreEqual(10, galks.Size); keygen.GenerateGaloisKeys(30, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.AreEqual(4, galks.Key(3)[0].Size); Assert.AreEqual(10, galks.Size); keygen.GenerateGaloisKeys(2, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.AreEqual(60, galks.Key(3)[0].Size); Assert.AreEqual(10, galks.Size); keygen.GenerateGaloisKeys(60, new List <UInt64> { 1, 3, 5, 7 }, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.IsTrue(galks.HasKey(1)); Assert.IsTrue(galks.HasKey(3)); Assert.IsTrue(galks.HasKey(5)); Assert.IsTrue(galks.HasKey(7)); Assert.IsFalse(galks.HasKey(9)); Assert.IsFalse(galks.HasKey(127)); Assert.AreEqual(2, galks.Key(1)[0].Size); Assert.AreEqual(2, galks.Key(3)[0].Size); Assert.AreEqual(2, galks.Key(5)[0].Size); Assert.AreEqual(2, galks.Key(7)[0].Size); Assert.AreEqual(4, galks.Size); keygen.GenerateGaloisKeys(30, new List <UInt64> { 1, 3, 5, 7 }, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.IsTrue(galks.HasKey(1)); Assert.IsTrue(galks.HasKey(3)); Assert.IsTrue(galks.HasKey(5)); Assert.IsTrue(galks.HasKey(7)); Assert.IsFalse(galks.HasKey(9)); Assert.IsFalse(galks.HasKey(127)); Assert.AreEqual(4, galks.Key(1)[0].Size); Assert.AreEqual(4, galks.Key(3)[0].Size); Assert.AreEqual(4, galks.Key(5)[0].Size); Assert.AreEqual(4, galks.Key(7)[0].Size); Assert.AreEqual(4, galks.Size); keygen.GenerateGaloisKeys(2, new List <UInt64> { 1, 3, 5, 7 }, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.IsTrue(galks.HasKey(1)); Assert.IsTrue(galks.HasKey(3)); Assert.IsTrue(galks.HasKey(5)); Assert.IsTrue(galks.HasKey(7)); Assert.IsFalse(galks.HasKey(9)); Assert.IsFalse(galks.HasKey(127)); Assert.AreEqual(60, galks.Key(1)[0].Size); Assert.AreEqual(60, galks.Key(3)[0].Size); Assert.AreEqual(60, galks.Key(5)[0].Size); Assert.AreEqual(60, galks.Key(7)[0].Size); Assert.AreEqual(4, galks.Size); keygen.GenerateGaloisKeys(30, new List <UInt64> { 1 }, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.IsTrue(galks.HasKey(1)); Assert.IsFalse(galks.HasKey(3)); Assert.IsFalse(galks.HasKey(127)); Assert.AreEqual(4, galks.Key(1)[0].Size); Assert.AreEqual(1, galks.Size); keygen.GenerateGaloisKeys(30, new List <UInt64> { 127 }, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.IsFalse(galks.HasKey(1)); Assert.IsTrue(galks.HasKey(127)); Assert.AreEqual(4, galks.Key(127)[0].Size); Assert.AreEqual(1, galks.Size); } { parms.NoiseStandardDeviation = 3.19; parms.PolyModulus = "1x^256 + 1"; parms.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods60Bit(0), DefaultParams.SmallMods30Bit(0), DefaultParams.SmallMods30Bit(1) }; parms.PlainModulus = 1 << 6; var context = new SEALContext(parms); var keygen = new KeyGenerator(context); Assert.AreEqual(keygen.PublicKey.HashBlock, parms.HashBlock); Assert.AreEqual(keygen.SecretKey.HashBlock, parms.HashBlock); var evk = new EvaluationKeys(); keygen.GenerateEvaluationKeys(60, 2, evk); Assert.AreEqual(evk.HashBlock, parms.HashBlock); Assert.AreEqual(2, evk.Key(2)[0].Size); keygen.GenerateEvaluationKeys(30, 2, evk); Assert.AreEqual(evk.HashBlock, parms.HashBlock); Assert.AreEqual(4, evk.Key(2)[0].Size); keygen.GenerateEvaluationKeys(4, 1, evk); Assert.AreEqual(evk.HashBlock, parms.HashBlock); Assert.AreEqual(30, evk.Key(2)[0].Size); var galks = new GaloisKeys(); keygen.GenerateGaloisKeys(60, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.AreEqual(2, galks.Key(3)[0].Size); Assert.AreEqual(14, galks.Size); keygen.GenerateGaloisKeys(30, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.AreEqual(4, galks.Key(3)[0].Size); Assert.AreEqual(14, galks.Size); keygen.GenerateGaloisKeys(2, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.AreEqual(60, galks.Key(3)[0].Size); Assert.AreEqual(14, galks.Size); keygen.GenerateGaloisKeys(60, new List <UInt64> { 1, 3, 5, 7 }, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.IsTrue(galks.HasKey(1)); Assert.IsTrue(galks.HasKey(3)); Assert.IsTrue(galks.HasKey(5)); Assert.IsTrue(galks.HasKey(7)); Assert.IsFalse(galks.HasKey(9)); Assert.IsFalse(galks.HasKey(511)); Assert.AreEqual(2, galks.Key(1)[0].Size); Assert.AreEqual(2, galks.Key(3)[0].Size); Assert.AreEqual(2, galks.Key(5)[0].Size); Assert.AreEqual(2, galks.Key(7)[0].Size); Assert.AreEqual(4, galks.Size); keygen.GenerateGaloisKeys(30, new List <UInt64> { 1, 3, 5, 7 }, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.IsTrue(galks.HasKey(1)); Assert.IsTrue(galks.HasKey(3)); Assert.IsTrue(galks.HasKey(5)); Assert.IsTrue(galks.HasKey(7)); Assert.IsFalse(galks.HasKey(9)); Assert.IsFalse(galks.HasKey(511)); Assert.AreEqual(4, galks.Key(1)[0].Size); Assert.AreEqual(4, galks.Key(3)[0].Size); Assert.AreEqual(4, galks.Key(5)[0].Size); Assert.AreEqual(4, galks.Key(7)[0].Size); Assert.AreEqual(4, galks.Size); keygen.GenerateGaloisKeys(2, new List <UInt64> { 1, 3, 5, 7 }, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.IsTrue(galks.HasKey(1)); Assert.IsTrue(galks.HasKey(3)); Assert.IsTrue(galks.HasKey(5)); Assert.IsTrue(galks.HasKey(7)); Assert.IsFalse(galks.HasKey(9)); Assert.IsFalse(galks.HasKey(511)); Assert.AreEqual(60, galks.Key(1)[0].Size); Assert.AreEqual(60, galks.Key(3)[0].Size); Assert.AreEqual(60, galks.Key(5)[0].Size); Assert.AreEqual(60, galks.Key(7)[0].Size); Assert.AreEqual(4, galks.Size); keygen.GenerateGaloisKeys(30, new List <UInt64> { 1 }, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.IsTrue(galks.HasKey(1)); Assert.IsFalse(galks.HasKey(3)); Assert.IsFalse(galks.HasKey(511)); Assert.AreEqual(4, galks.Key(1)[0].Size); Assert.AreEqual(1, galks.Size); keygen.GenerateGaloisKeys(30, new List <UInt64> { 511 }, galks); Assert.AreEqual(galks.HashBlock, parms.HashBlock); Assert.IsFalse(galks.HasKey(1)); Assert.IsTrue(galks.HasKey(511)); Assert.AreEqual(4, galks.Key(511)[0].Size); Assert.AreEqual(1, galks.Size); } }
public void ExceptionsTest() { EncryptionParameters parms = new EncryptionParameters(SchemeType.CKKS) { PolyModulusDegree = 64, CoeffModulus = new List <SmallModulus>() { DefaultParams.SmallMods30Bit(0), DefaultParams.SmallMods30Bit(1) } }; SEALContext context = SEALContext.Create(parms); CKKSEncoder encoder = new CKKSEncoder(context); List <double> vald = new List <double>(); List <double> vald_null = null; List <Complex> valc = new List <Complex>(); List <Complex> valc_null = null; Plaintext plain = new Plaintext(); Plaintext plain_null = null; MemoryPoolHandle pool = MemoryManager.GetPool(MMProfOpt.ForceGlobal); Complex complex = new Complex(1, 2); Assert.ThrowsException <ArgumentNullException>(() => encoder = new CKKSEncoder(null)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(vald, ParmsId.Zero, 10.0, plain_null)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(vald, null, 10.0, plain)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(vald_null, ParmsId.Zero, 10.0, plain)); Assert.ThrowsException <ArgumentException>(() => encoder.Encode(vald, ParmsId.Zero, 10.0, plain, pool)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(valc, ParmsId.Zero, 10.0, plain_null)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(valc, null, 10.0, plain)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(valc_null, ParmsId.Zero, 10.0, plain)); Assert.ThrowsException <ArgumentException>(() => encoder.Encode(valc, ParmsId.Zero, 10.0, plain, pool)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(vald, 10.0, plain_null)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(vald_null, 10.0, plain)); Assert.ThrowsException <ArgumentException>(() => encoder.Encode(vald, -10.0, plain, pool)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(valc, 10.0, plain_null)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(valc_null, 10.0, plain)); Assert.ThrowsException <ArgumentException>(() => encoder.Encode(valc, -10.0, plain, pool)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(10.0, ParmsId.Zero, 20.0, plain_null)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(10.0, null, 20.0, plain)); Assert.ThrowsException <ArgumentException>(() => encoder.Encode(10.0, ParmsId.Zero, 20.0, plain, pool)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(10.0, 20.0, plain_null)); Assert.ThrowsException <ArgumentException>(() => encoder.Encode(10.0, -20.0, plain, pool)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(complex, ParmsId.Zero, 10.0, plain_null)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(complex, null, 10.0, plain)); Assert.ThrowsException <ArgumentException>(() => encoder.Encode(complex, ParmsId.Zero, 10.0, plain, pool)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(complex, 10.0, plain_null)); Assert.ThrowsException <ArgumentException>(() => encoder.Encode(complex, -10.0, plain, pool)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(10, ParmsId.Zero, plain_null)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(10, null, plain)); Assert.ThrowsException <ArgumentException>(() => encoder.Encode(10, ParmsId.Zero, plain)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Encode(10, plain_null)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Decode(plain, vald_null)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Decode(plain_null, vald)); Assert.ThrowsException <ArgumentException>(() => encoder.Decode(plain, vald, pool)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Decode(plain, valc_null)); Assert.ThrowsException <ArgumentNullException>(() => encoder.Decode(plain_null, valc)); Assert.ThrowsException <ArgumentException>(() => encoder.Decode(plain, valc, pool)); }