Exemplo n.º 1
0
        public static List <AccessStructure> ExploreAllPossibleAccessStructures(IEnumerable <Trustee> participants)
        {
            List <QualifiedSubset> qss = new List <QualifiedSubset>();

            // build up all possible access structure for given input trustees
            for (int i = 1; i <= participants.Count(); i++)
            {
                var combs = GetKCombs <Trustee>(participants, i);
                foreach (var com in combs)
                {
                    QualifiedSubset qs = new QualifiedSubset(com);
                    qss.Add(qs);
                    Console.Write(qs.ToString() + '\t');
                }
                Console.WriteLine();
            }

            List <AccessStructure> accesses = new List <AccessStructure>();

            for (int i = 2; i <= qss.Count; i++)
            {
                var combinedaccesses = GetKCombs <QualifiedSubset>(qss, i);
                foreach (var ac in combinedaccesses)
                {
                    var access = new AccessStructure(ac.ToList());
                    accesses.Add(access);
                    Console.Write(access.ToString() + '\t');
                }

                Console.WriteLine();
            }

            return(accesses);
        }
Exemplo n.º 2
0
        private IEnumerable <BenalohLeichterBenchmarkReportSet> benchmarkScheme(AccessStructure access, string key, int iterate, List <LoadedPrimeNumber> primes)
        {
            Console.WriteLine("benchmarking {0}...", access);
            var filteredPrimes = primes.Where(po => po.PrimeSize == key.Length).ToList();

            PrimeGenerator.SetLoadedPrimes(filteredPrimes);
            List <BenalohLeichterBenchmarkReportSet> results = new List <BenalohLeichterBenchmarkReportSet>();
            List <long>             elapsedDivide            = new List <long>();
            List <long>             elapsedReconstruction    = new List <long>();
            List <IShareCollection> shares = null;

            Antix.Testing.Benchmark.Run(() =>
            {
                shares = wrappedDivideSecret(access, key, ref elapsedDivide);
            }, iterate);
            BenalohLeichterBenchmarkReport divideReport = new BenalohLeichterBenchmarkReport()
            {
                Access       = access.ToString(),
                ElapsedTicks = elapsedDivide.ToArray(),
                KeyLength    = key.Length * 8,
                Operation    = OperationType.DivideSecret
            };

            Antix.Testing.Benchmark.Run(() =>
            {
                wrappedConstructSecret(shares, ref elapsedReconstruction);
            }, iterate);

            BenalohLeichterBenchmarkReport reconstructReport = new BenalohLeichterBenchmarkReport()
            {
                Access       = access.ToString(),
                ElapsedTicks = elapsedReconstruction.ToArray(),
                KeyLength    = key.Length * 8,
                Operation    = OperationType.ReconstructSecret
            };
            var setReport = new BenalohLeichterBenchmarkReportSet()
            {
                divideItem      = divideReport,
                reconstructItem = reconstructReport,
            };

            results.Add(setReport);
            return(results);
        }
Exemplo n.º 3
0
        private IEnumerable <BenalohLeichterBenchmarkReportSet> benchmarkShareLengthAccessStructure(AccessStructure access, string key, int iterate)
        {
            List <BenalohLeichterBenchmarkReportSet> results = new List <BenalohLeichterBenchmarkReportSet>();
            List <long>     elapsedDivideOptimisdIntersected = new List <long>();
            List <long>     elapsedDivideOptimisd            = new List <long>();
            List <long>     elapsedDivide         = new List <long>();
            List <long>     elapsedReconstruction = new List <long>();
            int             shares         = 0;
            AccessStructure optimsedAccess = null;

            Antix.Testing.Benchmark.Run(() =>
            {
                shares = wrappedShareLengthDivideSecret(access, true, true, key, ref elapsedDivideOptimisdIntersected, ref optimsedAccess);
            }, iterate);

            var numberOfShares = shares;
            BenalohLeichterBenchmarkReport divideReportOptimisedIntersected = new BenalohLeichterBenchmarkReport()
            {
                Access          = access.ToString(),
                ElapsedTicks    = elapsedDivideOptimisdIntersected.ToArray(),
                KeyLength       = key.Length * 8,
                NumberOfShares  = numberOfShares,
                Operation       = OperationType.DivideSecretOptimisedIntersected,
                OptimisedAccess = optimsedAccess.ToString(),
            };

            Antix.Testing.Benchmark.Run(() =>
            {
                shares = wrappedShareLengthDivideSecret(access, true, false, key, ref elapsedDivideOptimisd, ref optimsedAccess);
            }, iterate);
            numberOfShares = shares;
            BenalohLeichterBenchmarkReport divideReportOptimised = new BenalohLeichterBenchmarkReport()
            {
                Access          = access.ToString(),
                ElapsedTicks    = elapsedDivideOptimisd.ToArray(),
                KeyLength       = key.Length * 8,
                NumberOfShares  = numberOfShares,
                Operation       = OperationType.DivideSecretOptimised,
                OptimisedAccess = optimsedAccess.ToString(),
            };

            Antix.Testing.Benchmark.Run(() =>
            {
                shares = wrappedShareLengthDivideSecret(access, false, false, key, ref elapsedDivide, ref optimsedAccess);
            }, iterate);
            numberOfShares = shares;
            BenalohLeichterBenchmarkReport divideReport = new BenalohLeichterBenchmarkReport()
            {
                Access         = access.ToString(),
                ElapsedTicks   = elapsedDivide.ToArray(),
                KeyLength      = key.Length * 8,
                NumberOfShares = numberOfShares,
                Operation      = OperationType.DivideSecret
            };

            var setReport = new BenalohLeichterBenchmarkReportSet()
            {
                divideItem      = divideReport,
                optimisedItem   = divideReportOptimised,
                IntersectedItem = divideReportOptimisedIntersected
            };

            results.Add(setReport);


            return(results);
        }