public void SEALContextParamsTest() { EncryptionParameters parms = new EncryptionParameters(SchemeType.BFV) { PolyModulusDegree = 128, PlainModulus = new Modulus(1 << 6), CoeffModulus = CoeffModulus.Create(128, new int[] { 30, 30, 30 }) }; SEALContext context = new SEALContext(parms, expandModChain: true, secLevel: SecLevelType.None); SEALContext.ContextData data = context.KeyContextData; Assert.IsNotNull(data); EncryptionParameters parms2 = data.Parms; Assert.AreEqual(parms.PolyModulusDegree, parms2.PolyModulusDegree); 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.AreEqual(SecLevelType.None, qualifiers.SecLevel); Assert.IsFalse(qualifiers.UsingDescendingModulusChain); Assert.IsTrue(context.UsingKeyswitching); 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); Assert.IsNull(data.PrevContextData); SEALContext.ContextData data2 = data.NextContextData; Assert.IsNotNull(data2); Assert.AreEqual(1ul, data2.ChainIndex); Assert.AreEqual(2ul, data2.PrevContextData.ChainIndex); SEALContext.ContextData data3 = data2.NextContextData; Assert.IsNotNull(data3); Assert.AreEqual(0ul, data3.ChainIndex); Assert.AreEqual(1ul, data3.PrevContextData.ChainIndex); Assert.IsNull(data3.NextContextData); parms = new EncryptionParameters(SchemeType.BFV) { PolyModulusDegree = 127, PlainModulus = new Modulus(1 << 6), CoeffModulus = CoeffModulus.Create(128, new int[] { 30, 30, 30 }) }; context = new SEALContext(parms, expandModChain: true, secLevel: SecLevelType.None); Assert.AreEqual(context.ParameterErrorName(), "invalid_poly_modulus_degree_non_power_of_two"); Assert.AreEqual(context.ParameterErrorMessage(), "poly_modulus_degree is not a power of two"); }