private void Bw_RunWorkerCompletedRand(object sender, RunWorkerCompletedEventArgs e) { if (n == -1) { BeginRandomGeneration(); } else if (n > 0) { this.schoof_value.Text = n.ToString(); BigInteger u = BigInteger.Parse(this.schoof_value.Text); if (this.r_min_textbox.Text == "" || this.l_max_textbox.Text == "") { this.r_min_textbox.Text = "5"; this.l_max_textbox.Text = "3"; } BigInteger r_min = BigInteger.Parse(this.r_min_textbox.Text); BigInteger l_max = BigInteger.Parse(this.l_max_textbox.Text); BigInteger nn = Maths.CheckingForNearPrimality(u, r_min, l_max); if (nn == -1) { BeginRandomGeneration(); } else { BigInteger h = u / nn; this.n_value.Text = nn.ToString(); this.h_value.Text = h.ToString(); BigInteger p = BigInteger.Parse(this.gen_textbox_p.value_textbox.Text); BigInteger a = BigInteger.Parse(this.gen_textbox_a.value_textbox.Text); BigInteger b = BigInteger.Parse(this.gen_textbox_b.value_textbox.Text); EllipticCurve curv = new EllipticCurve(p, a, b, nn, u); EllipticCurve_Point point; int k = 0; do { k++; point = curv.PointFinding(u, h, nn); if (!point.IsNull) { break; } }while (k < 3); if (point.IsNull) { BeginRandomGeneration(); } else { this.Gx_textbox.Text = point.X.ToString(); this.Gy_textbox.Text = point.Y.ToString(); timer.Stop(); this.schoof_stop_button.Visibility = Visibility.Hidden; MessageBox.Show(String.Format("Найдена схема:\n p = {0},\n a = {1},\n b = {2},\n n = {3},\n Gx = {4},\n Gy = {5}.", this.gen_textbox_p.value_textbox.Text, this.gen_textbox_a.value_textbox.Text, this.gen_textbox_b.value_textbox.Text, this.n_value.Text, this.Gx_textbox.Text, this.Gy_textbox.Text)); } } } }
public Schoof(int seed, BigInteger a, BigInteger b, BigInteger p, BackgroundWorker bw) { this.ecs = new EllipticCurve(p, a, b, 0, 0); this.bw = bw; q = Maths.Sqrt(p); if (q * q < p) { q++; } p1 = p - 1; q2 = 2 * q; q4 = 4 * q; hcr = new HcsrWithSEED(seed); pm = new PolynomialMethods(hcr); random = new Random(seed); }
private void Find_point_button_Click(object sender, RoutedEventArgs e) { this.warn_text_g.Visibility = Visibility.Hidden; if (!CheckN()) { return; } BigInteger p = BigInteger.Parse(this.gen_textbox_p.value_textbox.Text); BigInteger a = BigInteger.Parse(this.gen_textbox_a.value_textbox.Text); BigInteger b = BigInteger.Parse(this.gen_textbox_b.value_textbox.Text); BigInteger u = BigInteger.Parse(this.schoof_value.Text); BigInteger n = BigInteger.Parse(this.n_value.Text); BigInteger h = u / n; EllipticCurve curv = new EllipticCurve(p, a, b, n, u); EllipticCurve_Point point; try { int k = 0; do { k++; point = curv.PointFinding(u, h, n); if (!point.IsNull) { break; } }while (k < 4); this.Gx_textbox.Text = point.X.ToString(); this.Gy_textbox.Text = point.Y.ToString(); CheckG(); } catch { MessageBox.Show("Неверный порядок группы точек, проверьте параметры"); } }
public void LoadScheme(Scheme sch) { this.curv = new EllipticCurve(BigInteger.Parse(sch.P), BigInteger.Parse(sch.A), BigInteger.Parse(sch.B), BigInteger.Parse(sch.N), new EllipticCurve_Point(BigInteger.Parse(sch.Gx), BigInteger.Parse(sch.Gy))); }
public EllipticCurve_EDS(BigInteger p, BigInteger a, BigInteger b, BigInteger n, BigInteger gx, BigInteger gy) { this.curv = new EllipticCurve(p, a, b, n, new EllipticCurve_Point(gx, gy)); }
public EllipticCurve_EDS() { this.curv = null; }