예제 #1
0
        static void HandleReportsGenericBenaloh(BenalohPersistanceReport report, string output = "")
        {
            //group by key and handle for each key following outputs
            var selectdDivide      = report.Reports.Select(po => po.divideItem).GroupBy(grp => grp.KeyLength).Select(grp => new { KeyLength = grp.Key, Operation = OperationType.DivideSecret, reports = grp.Take(grp.Count()) });
            var selectdReconstruct = report.Reports.Select(po => po.reconstructItem).GroupBy(grp => grp.KeyLength).Select(grp => new { KeyLength = grp.Key, Operation = OperationType.ReconstructSecret, reports = grp.Take(grp.Count()) });;

            PDFGenerator pdfreport = new PDFGenerator();


            //selectdDivide = selectdDivide.Concat(selectdReconstruct);
            foreach (var reportGroup in selectdReconstruct.Concat(selectdDivide))
            {
                PerormanceAnalysisForm perfViewer = new PerormanceAnalysisForm();
                var curves = new List <IEnumerable <BenalohLeichterBenchmarkReport> >();
                //curves.Add(reportGroup.Reports);
                var titles = new List <String>()
                {
                    reportGroup.KeyLength.ToString()
                };
                Func <BenalohLeichterBenchmarkReport, long> selector = null;
                string selectorTitle = "n";
                switch (reportGroup.Operation)
                {
                case OperationType.DivideSecret:
                case OperationType.ReconstructSecret:
                    selectorTitle = "Length of the access structure";
                    selector      = delegate(BenalohLeichterBenchmarkReport po) { return(po.Access.Where(pr => char.IsDigit(pr)).Count()); };

                    break;
                }

                var mergedAccssesWithSameLength = reportGroup.reports.GroupBy(selector).Select(grp => new BenalohLeichterBenchmarkReport
                                                                                                   ()
                {
                    KeyLength    = grp.First().KeyLength,
                    Access       = grp.First().Access,
                    ElapsedTicks = accumulateElapsedTime(grp.Count(), grp.Select(po => po.ElapsedTicks)),
                }).OrderBy(po => po.Access.Where(pr => char.IsDigit(pr)).Count());

                curves.Add(mergedAccssesWithSameLength);
                perfViewer.ExportPerformanceReportsAsPNG_PDF(curves, titles,
                                                             "",//String.Format("{0}-Key length:{1}", reportGroup.Operation.ToString(), reportGroup.KeyLength),
                                                             false, true, selector, selectorTitle, po => (double)po.Average() / (double)TimeSpan.TicksPerMillisecond, "time(ms)",
                                                             string.Format("{0}/perf_{1}_{2}bits", output, reportGroup.Operation.ToString(), reportGroup.KeyLength));
            }
            //pdfreport.GenBenchmarkDoc(string.Format("{0}{1}bit_n{2}_k{3}_recon_chunk{4}bit.pdf", output, report.KeySize, report.N, report.K, chunk * 8), queryreconrep);
            //pdfreport.GenBenchmarkDoc(string.Format("{0}{1}bit_n{2}_k{3}_gen_chunk{4}bit.pdf", output, report.KeySize, report.N, report.K, chunk * 8), querygenrep);
        }
예제 #2
0
        static void HandleReportsGeneric(PersistanceReport report, string output, PersistanceReport reportcompared)
        {
            //group by key and handle for each key following outputs

            int[] PerformanceK = new int[] { 5, 20, 50 };
            int[] PerformanceN = new int[] { 50, 100 };


            var filtered = report.Reports.GroupBy(rp => new { opr = rp.Operation, keyLength = rp.keyLength })
                           .Select(grp => new { KeyLength = grp.Key.keyLength, Operation = grp.Key.opr,
                                                Reports   = report.Reports.Where(po => po.Operation == grp.Key.opr && po.keyLength == grp.Key.keyLength) });

            var filteredcompared = reportcompared.Reports.GroupBy(rp => new { opr = rp.Operation, keyLength = rp.keyLength })
                                   .Select(grp => new
            {
                KeyLength = grp.Key.keyLength,
                Operation = grp.Key.opr,
                Reports   = reportcompared.Reports.Where(po => po.Operation == grp.Key.opr && po.keyLength == grp.Key.keyLength)
            });
            PDFGenerator pdfreport = new PDFGenerator();


            foreach (var reportGroup in filtered)
            {
                PerormanceAnalysisForm perfViewer = new PerormanceAnalysisForm();
                var curves = new List <IEnumerable <SecretSharingBenchmarkReport> >();
                //curves.Add(reportGroup.Reports);
                var titles = new List <String>();// { reportGroup.Operation.ToString() };
                Func <SecretSharingBenchmarkReport, long> selector;
                string selectorTitle = "n";
                switch (reportGroup.Operation)
                {
                case SecretSharingBenchmarkReport.OperationType.SecretReconstruction:

                case SecretSharingBenchmarkReport.OperationType.RandomSecretReconstruction:
                case SecretSharingBenchmarkReport.OperationType.SpecialSecretReconstruction:
                    selector      = delegate(SecretSharingBenchmarkReport po) { return(po.k); };
                    selectorTitle = "k";

                    break;

                case SecretSharingBenchmarkReport.OperationType.VerifyPooledShares:
                case SecretSharingBenchmarkReport.OperationType.ShareGeneration:
                case SecretSharingBenchmarkReport.OperationType.VerifyShares:
                case SecretSharingBenchmarkReport.OperationType.DecryptShares:
                case SecretSharingBenchmarkReport.OperationType.ShareGenerationRandomSecret:
                case SecretSharingBenchmarkReport.OperationType.ShareGenerationSpecialSecret:
                case SecretSharingBenchmarkReport.OperationType.InitProtocol:
                default:
                    selector = delegate(SecretSharingBenchmarkReport po) { return(po.n); };

                    break;
                }
                var temp = reportGroup.Reports.GroupBy(po => selectorTitle != "k" ? po.k : po.n).Select(grp => new
                {
                    Axis    = grp.Key,
                    reports = reportGroup.Reports.Where(rpt => (selectorTitle != "k" ? rpt.k : rpt.n) == grp.Key)
                });
                var sortedTemp = temp.OrderByDescending(po => po.Axis);
                foreach (var groupedAxis in sortedTemp)
                {
                    curves.Add(groupedAxis.reports);
                    titles.Add(string.Format("{0}={1}", selectorTitle != "k" ? "k" : "n", groupedAxis.Axis));
                    if (reportGroup.Operation == SecretSharingBenchmarkReport.OperationType.DecryptShares ||
                        reportGroup.Operation == SecretSharingBenchmarkReport.OperationType.VerifyPooledShares ||
                        reportGroup.Operation == SecretSharingBenchmarkReport.OperationType.RandomSecretReconstruction)
                    {
                        break;
                    }
                }

                perfViewer.ExportPerformanceReportsAsPNG_PDF(curves, titles, "",/*String.Format("{0}-Key length:{1}"reportGroup.Operation.ToString(), reportGroup.KeyLength),*/
                                                             false, true, selector, selectorTitle, po => (double)po.Average() / (double)TimeSpan.TicksPerMillisecond, "Time (ms)",
                                                             string.Format("{0}perf_{1}_{2}bits", output, reportGroup.Operation.ToString(), reportGroup.KeyLength));
                var comparereport = filteredcompared.Where(po => po.KeyLength * 2 == reportGroup.KeyLength && (po.Operation == reportGroup.Operation || (po.Operation == SecretSharingBenchmarkReport.OperationType.ShareGeneration && reportGroup.Operation == SecretSharingBenchmarkReport.OperationType.ShareGenerationRandomSecret)));

                pdfreport.GenBenchmarkDoc(string.Format("{0}{1}bit_n{2}_k{3}_{4}.pdf", output, report.KeySize, report.N, report.K, reportGroup.Operation.ToString()), reportGroup.Reports, comparereport == null || comparereport.Count() == 0?null:comparereport.Single().Reports);
            }
        }
예제 #3
0
        static void HandleReports(PersistanceReport report, string output = "")
        {
            //group by key and handle for each key following outputs

            int[] PerformanceK = new int[] { 5, 20, 50 };
            int[] PerformanceN = new int[] { 50, 100 };

            var filteredreconrep = report.Reports.Where(po => po.Operation == SecretSharingBenchmarkReport.OperationType.SecretReconstruction);
            var filteredgenrep   = report.Reports.Where(po => po.Operation == SecretSharingBenchmarkReport.OperationType.ShareGeneration);
            var filteredprime    = report.Reports.Where(po => po.Operation == SecretSharingBenchmarkReport.OperationType.PrimeGneration);

            PDFGenerator pdfreport = new PDFGenerator();

            List <IEnumerable <SecretSharingBenchmarkReport> >[] generationPerformanceCurves     = new List <IEnumerable <SecretSharingBenchmarkReport> > [PerformanceK.Length];
            List <IEnumerable <SecretSharingBenchmarkReport> >[] reconstructionPerformanceCurves = new List <IEnumerable <SecretSharingBenchmarkReport> > [PerformanceN.Length];
            List <IEnumerable <SecretSharingBenchmarkReport> >[] primePerformanceCurves          = new List <IEnumerable <SecretSharingBenchmarkReport> > [PerformanceK.Length];

            List <string>[] genTitles   = new List <string> [PerformanceK.Length];
            List <string>[] primeTitles = new List <string> [PerformanceK.Length];
            List <string>[] reconTitles = new List <string> [PerformanceN.Length];
            for (int i = 1; i <= report.KeySize; i *= 2)
            {
                var chunk         = i;
                var queryreconrep = filteredreconrep.Where(po => po.chunkSize == chunk);
                var querygenrep   = filteredgenrep.Where(po => po.chunkSize == chunk);
                var queryprime    = filteredprime.Where(po => po.chunkSize == chunk);

                for (int kiterate = 0; kiterate < PerformanceK.Length; kiterate++)
                {
                    if (generationPerformanceCurves[kiterate] == null)
                    {
                        generationPerformanceCurves[kiterate] = new List <IEnumerable <SecretSharingBenchmarkReport> >();
                    }
                    if (primePerformanceCurves[kiterate] == null)
                    {
                        primePerformanceCurves[kiterate] = new List <IEnumerable <SecretSharingBenchmarkReport> >();
                    }
                    if (genTitles[kiterate] == null)
                    {
                        genTitles[kiterate] = new List <string>();
                    }
                    if (primeTitles[kiterate] == null)
                    {
                        primeTitles[kiterate] = new List <string>();
                    }
                    var wantedK = PerformanceK[kiterate];

                    var performanceCurveReport = querygenrep.Where(po => po.k == wantedK);
                    if (performanceCurveReport.Count() > 0)
                    {
                        generationPerformanceCurves[kiterate].Add(performanceCurveReport);
                        genTitles[kiterate].Add(string.Format("chunk={0}bit", chunk * 8));
                    }

                    var performancePrimeCurve = queryprime.Where(po => po.k == wantedK);
                    if (performancePrimeCurve.Count() > 0)
                    {
                        primePerformanceCurves[kiterate].Add(performancePrimeCurve);
                        primeTitles[kiterate].Add(string.Format("chunk={0}bit", chunk * 8));
                    }
                }

                for (int niterate = 0; niterate < PerformanceN.Length; niterate++)
                {
                    var wantedN = PerformanceN[niterate];
                    var performanceCurveReport = querygenrep.Where(po => po.n == wantedN);
                    if (reconstructionPerformanceCurves[niterate] == null)
                    {
                        reconstructionPerformanceCurves[niterate] = new List <IEnumerable <SecretSharingBenchmarkReport> >();
                    }
                    if (reconTitles[niterate] == null)
                    {
                        reconTitles[niterate] = new List <string>();
                    }
                    performanceCurveReport = queryreconrep.Where(po => po.n == wantedN);
                    if (performanceCurveReport.Count() > 0)
                    {
                        reconstructionPerformanceCurves[niterate].Add(performanceCurveReport);
                        reconTitles[niterate].Add(string.Format("chunk={0}bit", chunk * 8));
                    }
                }

                pdfreport.GenBenchmarkDoc(string.Format("{0}{1}bit_n{2}_k{3}_recon_chunk{4}bit.pdf", output, report.KeySize, report.N, report.K, chunk * 8), queryreconrep);
                pdfreport.GenBenchmarkDoc(string.Format("{0}{1}bit_n{2}_k{3}_gen_chunk{4}bit.pdf", output, report.KeySize, report.N, report.K, chunk * 8), querygenrep);
            }

            PerormanceAnalysisForm perfViewer = new PerormanceAnalysisForm();

            for (int l = 0; l < PerformanceK.Length; l++)
            {
#if calcPrimeTime
                perfViewer.ExportPerformanceReportsAsPNG_PDF(generationPerformanceCurves[l], genTitles[l]
                                                             , string.Format("Generate no prime KeySize={0}  K={1} ", report.KeySize, PerformanceK[l])
                                                             , true, false,
                                                             string.Format("{0}perf_NoPrime_gen_Key{1}bits_K{2}", output, report.KeySize, PerformanceK[l])
                                                             );

                perfViewer.ExportPerformanceReportsAsPNG_PDF(generationPerformanceCurves[l], genTitles[l]
                                                             , string.Format("Generate timeKeySize={0}  K={1}", report.KeySize, PerformanceK[l]), true, true,
                                                             string.Format("{0}perf_PrimeAndNoPrime_gen_Key{1}bits_K{2}", output, report.KeySize, PerformanceK[l])
                                                             );
#endif
                perfViewer.ExportPerformanceReportsAsPNG_PDF(generationPerformanceCurves[l], genTitles[l]
                                                             , string.Format("Share Generation KeySize={0}  K={1}", report.KeySize, PerformanceK[l])
                                                             , false, true, po => po.n, "n", po => (double)po.Average() / (double)TimeSpan.TicksPerMillisecond, "ms",
                                                             string.Format("{0}perf_Gen_Key{1}bits_K{2}", output, report.KeySize, PerformanceK[l])
                                                             );
                perfViewer.ExportPerformanceReportsAsPNG_PDF(primePerformanceCurves[l], primeTitles[l]
                                                             , string.Format("Prime KeySize={0}  K={1}", report.KeySize, PerformanceK[l])
                                                             , false, true, po => po.n, "n", po => perfViewer.StandardDeviation(po.ToList()), "Standard-D",
                                                             string.Format("{0}perf_Prime_Key{1}bits_K{2}", output, report.KeySize, PerformanceK[l])
                                                             );
            }

            for (int l = 0; l < PerformanceN.Length; l++)
            {
                perfViewer.ExportPerformanceReportsAsPNG_PDF(reconstructionPerformanceCurves[l], reconTitles[l]
                                                             , string.Format("Reconstruction KeySize={0}  N={1}", report.KeySize, PerformanceN[l])
                                                             , false, true, po => po.k, "k", po => (double)po.Average() / (double)TimeSpan.TicksPerMillisecond, "ms",
                                                             string.Format("{0}perf_recon_Key{1}bits_N{2}", output, report.KeySize, PerformanceN[l])
                                                             );
            }
        }