-
Notifications
You must be signed in to change notification settings - Fork 1
/
BigInt_cache.c
137 lines (113 loc) · 3.37 KB
/
BigInt_cache.c
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include <stdint.h>
#include <stdlib.h>
#include "BigInt.h"
static uint128_t u128_MAX_VAL = {
.array = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
},
.type = uint128
};
static uint256_t u256_MAX_VAL = {
.array = {
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
},
.type = uint256
};
static uint512_t u512_MAX_VAL = {
.array = {
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
},
.type = uint512
};
static uint1024_t u1024_MAX_VAL = {
.array = {
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
},
.type = uint1024
};
static uint2048_t u2048_MAX_VAL = {
.array = {
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
},
.type = uint2048
};
uint128_t BigInt_get_u128_MAX() {
return u128_MAX_VAL;
}
uint256_t BigInt_get_u256_MAX() {
return u256_MAX_VAL;
}
uint512_t BigInt_get_u512_MAX() {
return u512_MAX_VAL;
}
uint1024_t BigInt_get_u1024_MAX() {
return u1024_MAX_VAL;
}
uint2048_t BigInt_get_u2048_MAX() {
return u2048_MAX_VAL;
}
uint128_t BigInt_get_u128_RAND() {
uint128_t u128_rand;
for (uint8_t i = 0; i < uint128; i++) {
u128_rand.array[i] = rand();
}
u128_rand.type = uint128;
return u128_rand;
}
uint256_t BigInt_get_u256_RAND() {
uint256_t u256_rand;
for (uint8_t i = 0; i < uint256; i++) {
u256_rand.array[i] = rand();
}
u256_rand.type = uint256;
return u256_rand;
}
uint512_t BigInt_get_u512_RAND() {
uint512_t u512_rand;
for (uint8_t i = 0; i < uint512; i++) {
u512_rand.array[i] = rand();
}
u512_rand.type = uint512;
return u512_rand;
}
uint1024_t BigInt_get_u1024_RAND() {
uint1024_t u1024_rand;
for (uint8_t i = 0; i < uint1024; i++) {
u1024_rand.array[i] = rand();
}
u1024_rand.type = uint1024;
return u1024_rand;
}
uint2048_t BigInt_get_u2048_RAND() {
uint2048_t u2048_rand;
for (uint8_t i = 0; i < uint2048; i++) {
u2048_rand.array[i] = rand();
}
u2048_rand.type = uint2048;
return u2048_rand;
}