Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }