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)); } } } }
private void N_h_button_Click(object sender, RoutedEventArgs e) { if (this.r_min_textbox.Text == "" || this.l_max_textbox.Text == "") { return; } if (!CheckShoof()) { return; } BigInteger u = BigInteger.Parse(this.schoof_value.Text); BigInteger r_min = BigInteger.Parse(this.r_min_textbox.Text); BigInteger l_max = BigInteger.Parse(this.l_max_textbox.Text); if (l_max < 3) { return; } BigInteger n = Maths.CheckingForNearPrimality(u, r_min, l_max); if (n == -1) { this.n_value.Text = ""; this.h_value.Text = ""; MessageBox.Show("Необходимо изменить набор параметров a, b и p"); } else { BigInteger h = u / n; this.n_value.Text = n.ToString(); this.h_value.Text = h.ToString(); ConditionsN(); } }