Exemplo n.º 1
0
        public void CompareToTest()
        {
            BigUInt bui   = new BigUInt("DEADBEEF");
            BigUInt other = new BigUInt("DEADBFFF");

            Assert.IsTrue(bui.CompareTo(other) < 0);
            Assert.IsTrue(other.CompareTo(bui) > 0);

            BigUInt third = new BigUInt(bui);

            Assert.AreNotSame(bui, third);
            Assert.AreEqual(0, bui.CompareTo(third));
            Assert.IsTrue(bui.CompareTo(null) > 0);
        }
Exemplo n.º 2
0
        public void DecodeTest()
        {
            EncryptionParameters parms = new EncryptionParameters(SchemeType.BFV)
            {
                PlainModulus = new SmallModulus(1024)
            };
            SEALContext    context = SEALContext.Create(parms);
            IntegerEncoder encoder = new IntegerEncoder(context);

            Plaintext plain = new Plaintext("0x^5 + 1x^4 + 1x^3 + 1x^1 + 0");

            Assert.AreEqual(6ul, plain.CoeffCount);

            ulong resultU64 = encoder.DecodeUInt64(plain);

            Assert.AreEqual(26UL, resultU64);

            long resultI64 = encoder.DecodeInt64(plain);

            Assert.AreEqual(26L, resultI64);

            uint resultU32 = encoder.DecodeUInt32(plain);

            Assert.AreEqual(26U, resultU32);

            int resultI32 = encoder.DecodeInt32(plain);

            Assert.AreEqual(26, resultI32);

            BigUInt bui = encoder.DecodeBigUInt(plain);

            Assert.IsNotNull(bui);
            Assert.AreEqual(0, bui.CompareTo(26ul));
        }
Exemplo n.º 3
0
        public void DecodeTest()
        {
            IntegerEncoder encoder = new IntegerEncoder(GlobalContext.BFVContext);

            Plaintext plain = new Plaintext("0x^5 + 1x^4 + 1x^3 + 1x^1 + 0");

            Assert.AreEqual(6ul, plain.CoeffCount);

            ulong resultU64 = encoder.DecodeUInt64(plain);

            Assert.AreEqual(26UL, resultU64);

            long resultI64 = encoder.DecodeInt64(plain);

            Assert.AreEqual(26L, resultI64);

            uint resultU32 = encoder.DecodeUInt32(plain);

            Assert.AreEqual(26U, resultU32);

            int resultI32 = encoder.DecodeInt32(plain);

            Assert.AreEqual(26, resultI32);

            BigUInt bui = encoder.DecodeBigUInt(plain);

            Assert.IsNotNull(bui);
            Assert.AreEqual(0, bui.CompareTo(26ul));
        }