aboutsummaryrefslogtreecommitdiff
path: root/src/math/equation.c
blob: 571ee719efe1a27d9ad6e08b0d1422095dd53cce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * ecgen, tool for generating Elliptic curve domain parameters
 * Copyright (C) 2017 J08nY
 */
#include <io/input.h>
#include "equation.h"

int eq_random(curve_t *curve, config_t *config, ...) {
	int r = a_random(curve, config) + b_random(curve, config);
	if (r == 2) {
		return r;
	}
	return -1;
}

int a_random(curve_t *curve, config_t *config, ...) {
	curve->a = genrand(curve->field);
	return 1;
}

int a_input(curve_t *curve, config_t *config, ...) {
	curve->a = fread_int(in, "a: ", config->bits, '\n');
	return 1;
}

int a_zero(curve_t *curve, config_t *config, ...) {
	curve->a = gen_0;
	return 1;
}

int a_one(curve_t *curve, config_t *config, ...) {
	curve->a = gen_1;
	return 1;
}

int a_seed(curve_t *curve, config_t *config, ...) {}

int b_random(curve_t *curve, config_t *config, ...) {
	curve->b = genrand(curve->field);
	return 1;
}

int b_input(curve_t *curve, config_t *config, ...) {
	curve->b = fread_int(in, "a: ", config->bits, '\n');
	return 1;
}

int b_zero(curve_t *curve, config_t *config, ...) {
	curve->b = gen_0;
	return 1;
}

int b_one(curve_t *curve, config_t *config, ...) {
	curve->b = gen_1;
	return 1;
}

int b_seed(curve_t *curve, config_t *config, ...) {}