public void EncodeDecodeComplexTest() { EncryptionParameters parms = new EncryptionParameters(SchemeType.CKKS) { PolyModulusDegree = 64, CoeffModulus = new List <SmallModulus>() { DefaultParams.SmallMods40Bit(0), DefaultParams.SmallMods40Bit(1), DefaultParams.SmallMods40Bit(2), DefaultParams.SmallMods40Bit(3) } }; SEALContext context = SEALContext.Create(parms); CKKSEncoder encoder = new CKKSEncoder(context); Plaintext plain = new Plaintext(); Complex value = new Complex(3.1415, 2.71828); encoder.Encode(value, scale: Math.Pow(2, 20), destination: plain); List <Complex> result = new List <Complex>(); encoder.Decode(plain, result); Assert.IsTrue(result.Count > 0); Assert.AreEqual(3.1415, result[0].Real, delta: 0.0001); Assert.AreEqual(2.71828, result[0].Imaginary, delta: 0.0001); }
public void CreateTest() { List <SmallModulus> coeffModulus = new List <SmallModulus> { DefaultParams.SmallMods40Bit(0) }; EncryptionParameters parms = new EncryptionParameters(SchemeType.BFV) { PolyModulusDegree = 64, PlainModulus = new SmallModulus(1 << 6), CoeffModulus = coeffModulus }; SEALContext context = SEALContext.Create(parms); KeyGenerator keygen = new KeyGenerator(context); SecretKey secret = keygen.SecretKey; SecretKey copy = new SecretKey(secret); Assert.AreEqual(64ul, copy.Data.CoeffCount); Assert.IsTrue(copy.Data.IsNTTForm); SecretKey copy2 = new SecretKey(); copy2.Set(copy); Assert.AreEqual(64ul, copy2.Data.CoeffCount); Assert.IsTrue(copy2.Data.IsNTTForm); }
public void EncodeDecodeUlongTest() { int slots = 32; EncryptionParameters parms = new EncryptionParameters(SchemeType.CKKS); parms.PolyModulusDegree = (ulong)slots * 2; List <SmallModulus> coeffModulus = new List <SmallModulus>(4); coeffModulus.Add(DefaultParams.SmallMods40Bit(0)); coeffModulus.Add(DefaultParams.SmallMods40Bit(1)); coeffModulus.Add(DefaultParams.SmallMods40Bit(2)); coeffModulus.Add(DefaultParams.SmallMods40Bit(3)); parms.CoeffModulus = coeffModulus; SEALContext context = SEALContext.Create(parms); CKKSEncoder encoder = new CKKSEncoder(context); Plaintext plain = new Plaintext(); List <Complex> result = new List <Complex>(); long value = 15; encoder.Encode(value, plain); encoder.Decode(plain, result); for (int i = 0; i < slots; i++) { double tmp = Math.Abs(value - result[i].Real); Assert.IsTrue(tmp < 0.5); } }
public void EncodeDecodeDoubleTest() { EncryptionParameters parms = new EncryptionParameters(SchemeType.CKKS); parms.PolyModulusDegree = 64; List <SmallModulus> coeffModulus = new List <SmallModulus>(4); coeffModulus.Add(DefaultParams.SmallMods40Bit(0)); coeffModulus.Add(DefaultParams.SmallMods40Bit(1)); coeffModulus.Add(DefaultParams.SmallMods40Bit(2)); coeffModulus.Add(DefaultParams.SmallMods40Bit(3)); parms.CoeffModulus = coeffModulus; SEALContext context = SEALContext.Create(parms); int slots = 16; Plaintext plain = new Plaintext(); double delta = 1 << 16; List <Complex> result = new List <Complex>(); CKKSEncoder encoder = new CKKSEncoder(context); Assert.AreEqual(32ul, encoder.SlotCount); double value = 10d; encoder.Encode(value, delta, plain); encoder.Decode(plain, result); for (int i = 0; i < slots; i++) { double tmp = Math.Abs(value - result[i].Real); Assert.IsTrue(tmp < 0.5); } }
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 SmallMods40BitTest() { SmallModulus sm = DefaultParams.SmallMods40Bit(10); Assert.IsNotNull(sm); Assert.AreEqual(40, sm.BitCount); Assert.AreEqual(0xFFFE100001ul, sm.Value); Assert.ThrowsException <ArgumentOutOfRangeException>(() => DefaultParams.SmallMods40Bit(64)); }
public void SaveLoadTest() { TestDelegate save_load_test = delegate(SchemeType scheme) { List <SmallModulus> coeffModulus = new List <SmallModulus> { DefaultParams.SmallMods40Bit(0), DefaultParams.SmallMods40Bit(1) }; EncryptionParameters parms = new EncryptionParameters(scheme) { PolyModulusDegree = 8, CoeffModulus = coeffModulus }; if (scheme == SchemeType.BFV) { parms.SetPlainModulus(257); } EncryptionParameters loaded = null; using (MemoryStream stream = new MemoryStream()) { EncryptionParameters.Save(parms, stream); stream.Seek(offset: 0, loc: SeekOrigin.Begin); loaded = EncryptionParameters.Load(stream); } Assert.AreEqual(scheme, loaded.Scheme); Assert.AreEqual(8ul, loaded.PolyModulusDegree); if (scheme == SchemeType.BFV) { Assert.AreEqual(257ul, loaded.PlainModulus.Value); } else if (scheme == SchemeType.CKKS) { Assert.AreEqual(0ul, loaded.PlainModulus.Value); } List <SmallModulus> loadedCoeffModulus = new List <SmallModulus>(loaded.CoeffModulus); Assert.AreEqual(2, loadedCoeffModulus.Count); Assert.AreNotSame(coeffModulus[0], loadedCoeffModulus[0]); Assert.AreNotSame(coeffModulus[1], loadedCoeffModulus[1]); Assert.AreEqual(coeffModulus[0], loadedCoeffModulus[0]); Assert.AreEqual(coeffModulus[1], loadedCoeffModulus[1]); Assert.AreEqual(parms.NoiseMaxDeviation, loaded.NoiseMaxDeviation, delta: 0.001); Assert.AreEqual(parms.NoiseStandardDeviation, loaded.NoiseStandardDeviation, delta: 0.001); }; save_load_test(SchemeType.BFV); save_load_test(SchemeType.CKKS); }
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 SaveLoadTest() { List <SmallModulus> coeffModulus = new List <SmallModulus> { DefaultParams.SmallMods40Bit(0) }; EncryptionParameters parms = new EncryptionParameters(SchemeType.BFV) { PolyModulusDegree = 64, PlainModulus = new SmallModulus(1 << 6), CoeffModulus = coeffModulus }; SEALContext context = SEALContext.Create(parms); KeyGenerator keygen = new KeyGenerator(context); SecretKey secret = keygen.SecretKey; Assert.AreEqual(64ul, secret.Data.CoeffCount); Assert.IsTrue(secret.Data.IsNTTForm); Assert.AreNotEqual(ParmsId.Zero, secret.ParmsId); SecretKey secret2 = new SecretKey(); MemoryPoolHandle handle = secret2.Pool; Assert.IsNotNull(secret2); Assert.AreEqual(0ul, secret2.Data.CoeffCount); Assert.IsFalse(secret2.Data.IsNTTForm); ulong alloced = handle.AllocByteCount; using (MemoryStream stream = new MemoryStream()) { secret.Save(stream); stream.Seek(offset: 0, loc: SeekOrigin.Begin); secret2.Load(context, stream); } Assert.AreNotSame(secret, secret2); Assert.AreEqual(64ul, secret2.Data.CoeffCount); Assert.IsTrue(secret2.Data.IsNTTForm); Assert.AreNotEqual(ParmsId.Zero, secret2.ParmsId); Assert.AreEqual(secret.ParmsId, secret2.ParmsId); Assert.IsTrue(handle.AllocByteCount != alloced); }
public void EqualsTest() { EncryptionParameters parms = new EncryptionParameters(SchemeType.BFV) { PolyModulusDegree = 8, PlainModulus = new SmallModulus(257), CoeffModulus = new List <SmallModulus>() { DefaultParams.SmallMods40Bit(0), DefaultParams.SmallMods40Bit(1) } }; EncryptionParameters parms2 = new EncryptionParameters(SchemeType.CKKS); Assert.AreNotEqual(parms, parms2); Assert.IsFalse(parms.Equals(null)); }
public void SaveLoadTest() { List <SmallModulus> coeffModulus = new List <SmallModulus> { DefaultParams.SmallMods40Bit(0) }; EncryptionParameters parms = new EncryptionParameters(SchemeType.BFV) { PolyModulusDegree = 64, PlainModulus = new SmallModulus(1 << 6), CoeffModulus = coeffModulus }; SEALContext context = SEALContext.Create(parms); KeyGenerator keygen = new KeyGenerator(context); PublicKey pub = keygen.PublicKey; Assert.IsNotNull(pub); Assert.AreEqual(2ul, pub.Data.Size); Assert.IsTrue(pub.Data.IsNTTForm); PublicKey pub2 = new PublicKey(); MemoryPoolHandle handle = pub2.Pool; Assert.AreEqual(0ul, pub2.Data.Size); Assert.IsFalse(pub2.Data.IsNTTForm); Assert.AreEqual(ParmsId.Zero, pub2.ParmsId); using (MemoryStream stream = new MemoryStream()) { pub.Save(stream); stream.Seek(offset: 0, loc: SeekOrigin.Begin); pub2.Load(context, stream); } Assert.AreNotSame(pub, pub2); Assert.AreEqual(2ul, pub2.Data.Size); Assert.IsTrue(pub2.Data.IsNTTForm); Assert.AreEqual(pub.ParmsId, pub2.ParmsId); Assert.AreNotEqual(ParmsId.Zero, pub2.ParmsId); Assert.IsTrue(handle.AllocByteCount != 0ul); }
public void SEALContextCKKSParamsTest() { int slotSize = 4; List <SmallModulus> coeffModulus = new List <SmallModulus> { DefaultParams.SmallMods40Bit(0), DefaultParams.SmallMods40Bit(1), DefaultParams.SmallMods40Bit(2), DefaultParams.SmallMods40Bit(3) }; EncryptionParameters parms = new EncryptionParameters(SchemeType.CKKS) { PolyModulusDegree = 2 * (ulong)slotSize, CoeffModulus = coeffModulus }; SEALContext context = SEALContext.Create(parms); SEALContext.ContextData data = context.FirstContextData; Assert.IsNotNull(data); // This should be available in CKKS Assert.IsNotNull(data.UpperHalfThreshold); Assert.AreEqual(4, data.UpperHalfThreshold.Length); Assert.IsNull(data.UpperHalfIncrement); Assert.AreEqual(3ul, data.ChainIndex); SEALContext.ContextData data2 = data.NextContextData; Assert.IsNotNull(data2); Assert.AreEqual(2ul, data2.ChainIndex); SEALContext.ContextData data3 = data2.NextContextData; Assert.IsNotNull(data3); Assert.AreEqual(1ul, data3.ChainIndex); SEALContext.ContextData data4 = data3.NextContextData; Assert.IsNotNull(data4); Assert.AreEqual(0ul, data4.ChainIndex); Assert.IsNull(data4.NextContextData); }
public void SchemeIsCKKSTest() { List <SmallModulus> coeffModulus = new List <SmallModulus> { DefaultParams.SmallMods40Bit(0), DefaultParams.SmallMods40Bit(1), DefaultParams.SmallMods40Bit(2), DefaultParams.SmallMods40Bit(3) }; EncryptionParameters parms = new EncryptionParameters(SchemeType.CKKS) { PolyModulusDegree = 8, CoeffModulus = coeffModulus }; SEALContext context = SEALContext.Create(parms); Assert.ThrowsException <ArgumentException>(() => { BatchEncoder encoder = new BatchEncoder(context); }); }
public void ScaleTest() { List <SmallModulus> coeffModulus = new List <SmallModulus>() { DefaultParams.SmallMods40Bit(0), DefaultParams.SmallMods40Bit(1), DefaultParams.SmallMods40Bit(2), DefaultParams.SmallMods40Bit(3) }; EncryptionParameters parms = new EncryptionParameters(SchemeType.CKKS) { CoeffModulus = coeffModulus, PolyModulusDegree = 8 }; SEALContext context = SEALContext.Create(parms); KeyGenerator keygen = new KeyGenerator(context); GaloisKeys galoisKeys = keygen.GaloisKeys(decompositionBitCount: 4); Encryptor encryptor = new Encryptor(context, keygen.PublicKey); Evaluator evaluator = new Evaluator(context); CKKSEncoder encoder = new CKKSEncoder(context); MemoryPoolHandle pool = MemoryManager.GetPool(MMProfOpt.ForceNew); Assert.AreEqual(0ul, pool.AllocByteCount); Ciphertext encrypted = new Ciphertext(pool); Plaintext plain = new Plaintext(); MemoryPoolHandle cipherPool = encrypted.Pool; Assert.IsNotNull(cipherPool); Assert.AreEqual(0ul, cipherPool.AllocByteCount); List <Complex> input = new List <Complex>() { new Complex(1, 1), new Complex(2, 2), new Complex(3, 3), new Complex(4, 4) }; double delta = Math.Pow(2, 70); encoder.Encode(input, parms.ParmsId, delta, plain); encryptor.Encrypt(plain, encrypted); Assert.AreEqual(delta, encrypted.Scale, delta: Math.Pow(2, 60)); Ciphertext encrypted2 = new Ciphertext(); encrypted2.Set(encrypted); Assert.AreEqual(delta, encrypted2.Scale, delta: Math.Pow(2, 60)); evaluator.RescaleToNextInplace(encrypted); Assert.AreEqual(Math.Pow(2, 30), encrypted.Scale, delta: 10000); Assert.AreNotEqual(0ul, cipherPool.AllocByteCount); double newScale = Math.Pow(2, 10); encrypted.Scale = newScale; Assert.AreEqual(newScale, encrypted.Scale, delta: 100); }
public void FVEncryptDecryptNET() { var parms = new EncryptionParameters(); var plain_modulus = new SmallModulus(1 << 6); parms.NoiseStandardDeviation = 3.19; parms.PlainModulus = plain_modulus; { parms.PolyModulus = "1x^64 + 1"; parms.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods60Bit(0) }; var context = new SEALContext(parms); var keygen = new KeyGenerator(context); var encoder = new BalancedEncoder(plain_modulus); var encryptor = new Encryptor(context, keygen.PublicKey); var decryptor = new Decryptor(context, keygen.SecretKey); var encrypted = new Ciphertext(); var plain = new Plaintext(); encryptor.Encrypt(encoder.Encode(0x12345678), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0x12345678UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(0), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(1), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(1UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(2), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(2UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(0x7FFFFFFFFFFFFFFD), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0x7FFFFFFFFFFFFFFDUL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(0x7FFFFFFFFFFFFFFE), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0x7FFFFFFFFFFFFFFEUL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(0x7FFFFFFFFFFFFFFF), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0x7FFFFFFFFFFFFFFFUL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(314159265), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(314159265UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); } { parms.PolyModulus = "1x^128 + 1"; parms.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods40Bit(0), DefaultParams.SmallMods40Bit(1) }; var context = new SEALContext(parms); var keygen = new KeyGenerator(context); var encoder = new BalancedEncoder(plain_modulus); var encryptor = new Encryptor(context, keygen.PublicKey); var decryptor = new Decryptor(context, keygen.SecretKey); var encrypted = new Ciphertext(); var plain = new Plaintext(); encryptor.Encrypt(encoder.Encode(0x12345678), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0x12345678UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(0), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(1), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(1UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(2), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(2UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(0x7FFFFFFFFFFFFFFD), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0x7FFFFFFFFFFFFFFDUL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(0x7FFFFFFFFFFFFFFE), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0x7FFFFFFFFFFFFFFEUL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(0x7FFFFFFFFFFFFFFF), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0x7FFFFFFFFFFFFFFFUL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(314159265), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(314159265UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); } { parms.PolyModulus = "1x^256 + 1"; parms.CoeffModulus = new List <SmallModulus> { DefaultParams.SmallMods40Bit(0), DefaultParams.SmallMods40Bit(1), DefaultParams.SmallMods40Bit(2) }; var context = new SEALContext(parms); var keygen = new KeyGenerator(context); var encoder = new BalancedEncoder(plain_modulus); var encryptor = new Encryptor(context, keygen.PublicKey); var decryptor = new Decryptor(context, keygen.SecretKey); var encrypted = new Ciphertext(); var plain = new Plaintext(); encryptor.Encrypt(encoder.Encode(0x12345678), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0x12345678UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(0), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(1), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(1UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(2), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(2UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(0x7FFFFFFFFFFFFFFD), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0x7FFFFFFFFFFFFFFDUL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(0x7FFFFFFFFFFFFFFE), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0x7FFFFFFFFFFFFFFEUL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(0x7FFFFFFFFFFFFFFF), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(0x7FFFFFFFFFFFFFFFUL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); encryptor.Encrypt(encoder.Encode(314159265), encrypted); decryptor.Decrypt(encrypted, plain); Assert.AreEqual(314159265UL, encoder.DecodeUInt64(plain)); Assert.AreEqual(encrypted.HashBlock, parms.HashBlock); } }