示例#1
0
        public static BigPolyArray[] GetEncryptedDataInBatches(EncCal encCal, Pgm picture, int size = 3)
        {
            var encryptedData = new BigPolyArray[picture.Length * size];

            Parallel.For(0, picture.Length, l =>
            {
                int slotCount = encCal.CrtBuilder.SlotCount;
                var values1   = new BigUInt[encCal.CrtBuilder.SlotCount];
                var values2   = new BigUInt[encCal.CrtBuilder.SlotCount];
                var values3   = new BigUInt[encCal.CrtBuilder.SlotCount];
                Parallel.For(0, slotCount, i =>
                {
                    values1[i] = new BigUInt(encCal.GetBitCount(), 0);
                    values2[i] = new BigUInt(encCal.GetBitCount(), 0);
                    values3[i] = new BigUInt(encCal.GetBitCount(), 0);
                });
                Parallel.For(0, picture.Width, i =>
                {
                    values1[i].Set(picture.Data[(l * picture.Length) + i]);
                    values2[i + 1].Set(picture.Data[(l * picture.Length) + i]);
                    values3[i + 2].Set(picture.Data[(l * picture.Length) + i]);
                });
                encryptedData[size * l]     = encCal.GetEnc(encCal.CrtBuilder.Compose(values1.ToList()));
                encryptedData[size * l + 1] = encCal.GetEnc(encCal.CrtBuilder.Compose(values2.ToList()));
                encryptedData[size * l + 2] = encCal.GetEnc(encCal.CrtBuilder.Compose(values3.ToList()));
            });
            return(encryptedData);
        }