PALISADE Lattice Crypto Library
1.11.9
A lattice crypto library for software engineers by software engineers.
src
core
include
utils
testcasegen.h
1
// @file testcasegen.h Helper methods for serialization.
2
// @author TPOC: contact@palisade-crypto.org
3
//
4
// @copyright Copyright(c) 2019, New Jersey Institute of Technology(NJIT)
5
// All rights reserved.
6
// Redistribution and use in source and binary forms, with or without
7
// modification, are permitted provided that the following conditions are met:
8
// 1. Redistributions of source code must retain the above copyright notice,
9
// this list of conditions and the following disclaimer.
10
// 2. Redistributions in binary form must reproduce the above copyright notice,
11
// this list of conditions and the following disclaimer in the documentation
12
// and/or other materials provided with the distribution. THIS SOFTWARE IS
13
// PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
14
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
16
// EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
17
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
24
#ifndef SRC_CORE_LIB_UTILS_TESTCASEGEN_H_
25
#define SRC_CORE_LIB_UTILS_TESTCASEGEN_H_
26
27
#define GENERATE_PKE_TEST_CASE(TOPNAME, FUNC, ELEMENT, SCHEME, ORD, PTM) \
28
TEST_F(TOPNAME, FUNC##_##ELEMENT##_##SCHEME) { \
29
CryptoContext<ELEMENT> cc; \
30
try { \
31
cc = GenTestCryptoContext<ELEMENT>(#SCHEME, ORD, PTM); \
32
} catch (const not_implemented_error&) { \
33
return; \
34
} catch (const not_available_error&) { \
35
return; \
36
} catch (const std::exception& ex) { \
37
std::cerr << "Exception occurred: " << ex.what() << std::endl; \
38
} catch (...) { \
39
std::cerr << "Unknown failure occurred." << std::endl; \
40
} \
41
FUNC<ELEMENT>(cc, #SCHEME); \
42
}
43
44
#define GENERATE_PKE_TEST_CASE_BITS(TOPNAME, FUNC, ELEMENT, SCHEME, ORD, PTM, \
45
BITS) \
46
TEST_F(TOPNAME, FUNC##_##ELEMENT##_##SCHEME) { \
47
CryptoContext<ELEMENT> cc; \
48
try { \
49
cc = GenTestCryptoContext<ELEMENT>(#SCHEME, ORD, PTM, BITS); \
50
} catch (const not_implemented_error&) { \
51
return; \
52
} catch (const not_available_error&) { \
53
return; \
54
} catch (const std::exception& ex) { \
55
std::cerr << "Exception occurred: " << ex.what() << std::endl; \
56
} catch (...) { \
57
std::cerr << "Unknown failure occurred." << std::endl; \
58
} \
59
FUNC<ELEMENT>(cc, #SCHEME); \
60
}
61
62
#define GENERATE_BGVrns_TEST_CASE(TOPNAME, FUNC, ELEMENT, SCHEME, ORD, PTM, \
63
SIZEMODULI, NUMPRIME, RELIN, KEYSWITCH, \
64
BATCH, RESCALEALG, MODSWITCHMETHOD) \
65
TEST_F(TOPNAME, \
66
FUNC##_##ELEMENT##_##SCHEME##_##KEYSWITCH##_##MODSWITCHMETHOD) { \
67
CryptoContext<ELEMENT> cc; \
68
try { \
69
cc = GenTestCryptoContext<ELEMENT>(#SCHEME, ORD, PTM, SIZEMODULI, \
70
NUMPRIME, RELIN, BATCH, KEYSWITCH, \
71
RESCALEALG, MODSWITCHMETHOD); \
72
} catch (const not_implemented_error&) { \
73
return; \
74
} catch (const not_available_error&) { \
75
return; \
76
} catch (const std::exception& ex) { \
77
std::cerr << "Exception occurred: " << ex.what() << std::endl; \
78
} catch (...) { \
79
std::cerr << "Unknown failure occurred." << std::endl; \
80
} \
81
FUNC<ELEMENT>(cc, #SCHEME); \
82
}
83
84
#define GENERATE_CKKS_TEST_CASE(TOPNAME, FUNC, ELEMENT, SCHEME, ORD, SCALE, \
85
NUMPRIME, RELIN, BATCH, KEYSWITCH, RESCALEALG) \
86
TEST_F(TOPNAME, FUNC##_##ELEMENT##_##SCHEME##_##KEYSWITCH##_##RESCALEALG) { \
87
CryptoContext<ELEMENT> cc; \
88
try { \
89
cc = GenTestCryptoContext<ELEMENT>(#SCHEME, ORD, SCALE, SCALE, NUMPRIME, \
90
RELIN, BATCH, KEYSWITCH, RESCALEALG); \
91
} catch (const not_implemented_error&) { \
92
return; \
93
} catch (const not_available_error&) { \
94
return; \
95
} catch (const std::exception& ex) { \
96
std::cerr << "Exception occurred: " << ex.what() << std::endl; \
97
} catch (...) { \
98
std::cerr << "Unknown failure occurred." << std::endl; \
99
} \
100
FUNC<ELEMENT>(cc, #SCHEME); \
101
}
102
103
#endif
/* SRC_CORE_LIB_UTILS_TESTCASEGEN_H_ */
Generated on Fri Dec 2 2022 21:02:06 for PALISADE Lattice Crypto Library by
1.8.13