summaryrefslogtreecommitdiff
path: root/test/src/math/test_koblitz.c
blob: 93272ab99659babf14618ec75a074fdf08fbef17 (plain)
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
/*
 * ecgen, tool for generating Elliptic curve domain parameters
 * Copyright (C) 2017-2018 J08nY
 */
#include <criterion/criterion.h>
#include "gen/point.h"
#include "math/koblitz.h"
#include "test/default.h"

TestSuite(koblitz, .init = default_setup, .fini = default_teardown);

Test(koblitz, test_koblitz_is_curve) {
	curve_t curve = {
	    .field = stoi(23), .a = mkintmodu(3, 23), .b = mkintmodu(2, 23)};

	cr_assert_not(koblitz_is_curve(&curve), );
	curve.a = mkintmodu(1, 23);
	curve.b = mkintmodu(1, 23);
	cr_assert(koblitz_is_curve(&curve), );
}

Test(koblitz, test_koblitz_find) {
	const koblitz_t *koblitz = koblitz_find(107, 0);
	cr_assert_not_null(koblitz, );
}

Test(koblitz, test_koblitz_get_order) {
	GEN order = koblitz_get_order(107, 0);
	cr_assert(gequal(order, strtoi("0x7ffffffffffffb57c25324737c4")), );
}