public void GenerateNewGGH(int dim, int l) { UiServices.SetBusyState(); GGH = GGH != null && GGH.dim == dim ? new GGHModel(dim, l, GGH.errorVector) : new GGHModel(dim, l); Paragraph paragraph = new Paragraph(); paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonGenerateNewCryptosystem + " **\r\n")))); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPrivateKeyR + ":"))); paragraph.Inlines.Add(" " + GGH.privateKeyR + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPrivateKeyR1 + ":"))); paragraph.Inlines.Add(" " + GGH.privateKeyR1.ToStringLog() + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPublicKeyB + ":"))); paragraph.Inlines.Add(" " + GGH.publicKeyB + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPublicKeyB1 + ":"))); paragraph.Inlines.Add(" " + GGH.publicKeyB1.ToStringLog() + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelUnimodularTransformationMatrix + ":"))); paragraph.Inlines.Add(" " + Lattice.LatticeTransformationToString() + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelParameterL))); paragraph.Inlines.Add(" " + GGH.l + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelErrorVector))); paragraph.Inlines.Add(" " + GGH.errorVector + "\r\n"); if (History.Document.Blocks.FirstBlock != null) { History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph); } else { History.Document.Blocks.Add(paragraph); } NotifyPropertyChanged("ErrorVector"); }
public void WriteHistoryForNewLattice(string firstLine) { Paragraph paragraph = new Paragraph(); paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + firstLine + " **\r\n")))); paragraph.Inlines.Add(new Bold(new Run(Languages.labelLatticeBasis + ":"))); paragraph.Inlines.Add(" " + Lattice.LatticeToString() + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(" " + Languages.labelLengthBasisVectors))); paragraph.Inlines.Add(" " + Lattice.VectorLengthToString() + "\r\n"); if (Lattice.N == 2 && Lattice.M == 2) { paragraph.Inlines.Add(new Bold(new Run(" " + Languages.labelAngleBasisVectors))); paragraph.Inlines.Add(" " + Util.FormatDoubleLog(Lattice.AngleBasisVectors) + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(" " + Languages.labelEstimationR))); paragraph.Inlines.Add(" " + Util.FormatDoubleLog(Math.Sqrt(hermiteConstant * (double)Lattice.Determinant)) + "\r\n"); } paragraph.Inlines.Add(new Bold(new Run(Languages.labelReducedLatticeBasis + ":"))); paragraph.Inlines.Add(" " + Lattice.LatticeReducedToString() + "\r\n"); List <string> reductionSteps = Lattice.LatticeReductionStepsToString(); for (int i = 1; i <= reductionSteps.Count; i++) { paragraph.Inlines.Add(" " + string.Format(Languages.labelReductionStep, i, reductionSteps.Count) + " " + reductionSteps[i - 1] + "\r\n"); } paragraph.Inlines.Add(new Bold(new Run(" " + Languages.labelSuccessiveMinima))); paragraph.Inlines.Add(" " + Lattice.VectorReducedLengthToString() + "\r\n"); if (Lattice.N == 2 && Lattice.M == 2) { paragraph.Inlines.Add(new Bold(new Run(" " + Languages.labelAngleReducedVectors))); paragraph.Inlines.Add(" " + Util.FormatDoubleLog(Lattice.AngleReducedVectors) + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(" " + Languages.labelDensity))); paragraph.Inlines.Add(" " + Util.FormatDoubleToPercentageLog(Lattice.Density) + " / " + Util.FormatDoubleToPercentageLog(Lattice.DensityRelToOptimum) + "\r\n"); } paragraph.Inlines.Add(new Bold(new Run(" " + Languages.labelMinimalVector))); paragraph.Inlines.Add(" " + Lattice.GetMinimalReducedVector() + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelUnimodularTransformationMatrix))); paragraph.Inlines.Add(" " + Lattice.LatticeTransformationToString() + "\r\n"); if (Lattice.N == Lattice.M) { paragraph.Inlines.Add(new Bold(new Run(Languages.labelDeterminant))); paragraph.Inlines.Add(" " + Lattice.Determinant + "\r\n"); } if (History.Document.Blocks.FirstBlock != null) { History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph); } else { History.Document.Blocks.Add(paragraph); } }