PALISADE Lattice Crypto Library  1.11.9
A lattice crypto library for software engineers by software engineers.
inttypes.h
1 // @file inttypes.h This code provides basic integer types for lattice crypto.
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 LBCRYPTO_UTILS_INTTYPES_H
25 #define LBCRYPTO_UTILS_INTTYPES_H
26 
27 #include <stdint.h>
28 #include <iostream>
29 #include <string>
30 
34 typedef uint8_t uschar;
35 
39 typedef uint16_t usshort;
40 
44 typedef uint32_t usint;
45 
46 typedef uint64_t PlaintextModulus;
47 
52 enum Format { EVALUATION = 0, COEFFICIENT = 1 };
53 
54 inline std::ostream &operator<<(std::ostream &s, Format f) {
55  switch (f) {
56  case EVALUATION:
57  s << "EVALUATION";
58  break;
59  case COEFFICIENT:
60  s << "COEFFICIENT";
61  break;
62  default:
63  s << "UKNOWN";
64  break;
65  }
66  return s;
67 }
68 
72 enum PKESchemeFeature {
73  ENCRYPTION = 0x01,
74  PRE = 0x02,
75  SHE = 0x04,
76  FHE = 0x08,
77  LEVELEDSHE = 0x10,
78  MULTIPARTY = 0x20,
79  ADVANCEDSHE = 0x40
80 };
81 
82 inline std::ostream &operator<<(std::ostream &s, PKESchemeFeature f) {
83  switch (f) {
84  case ENCRYPTION:
85  s << "ENCRYPTION";
86  break;
87  case PRE:
88  s << "PRE";
89  break;
90  case SHE:
91  s << "SHE";
92  break;
93  case FHE:
94  s << "FHE";
95  break;
96  case LEVELEDSHE:
97  s << "LEVELEDSHE";
98  break;
99  case MULTIPARTY:
100  s << "MULTIPARTY";
101  break;
102  case ADVANCEDSHE:
103  s << "ADVANCEDSHE";
104  break;
105  default:
106  s << "UKNOWN";
107  break;
108  }
109  return s;
110 }
111 
115 enum MODE { RLWE = 0, OPTIMIZED = 1, SPARSE = 2 };
116 
117 inline std::ostream &operator<<(std::ostream &s, MODE m) {
118  switch (m) {
119  case RLWE:
120  s << "RLWE";
121  break;
122  case OPTIMIZED:
123  s << "OPTIMIZED";
124  break;
125  case SPARSE:
126  s << "SPARSE";
127  break;
128  default:
129  s << "UKNOWN";
130  break;
131  }
132  return s;
133 }
134 
135 #endif