summaryrefslogtreecommitdiff
path: root/src/tspi/daa/big_integer/test/multi_exp.c
blob: 2ff80fc139cc6783c411ad5d4dcc2d6a36f99f8c (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
#include <stdio.h>

#include <bi.h>

// use standard C definition to avoid .h
int test_exp_multi(void) {
	bi_t result;
	bi_t g[3];
	unsigned long e[3];

	bi_new( result);
	bi_new( g[0]);
	bi_new( g[1]);
	bi_new( g[2]);
	// result = (2^2 * 5^4 * 7^7) mod 56 -> should give 28
	bi_set_as_dec( g[0], "2");
	bi_set_as_dec( g[1], "5");
	bi_set_as_dec( g[2], "7");
	e[0] = 2L;
	e[1] = 4L;
	e[2] = 7L;
	bi_multi_mod_exp( result, 3, g, e, 56);
	printf("multi-exponentiation <result>=%s\n", bi_2_dec_char(result));
	bi_free( g[0]);
	bi_free( g[1]);
	bi_free( g[2]);
	bi_free( result);
	return 0;
}