BUILD 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. # Copyright 2017 Google LLC.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # https://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. load("@rules_cc//cc:defs.bzl", "cc_library")
  15. load("@rules_proto//proto:defs.bzl", "proto_library")
  16. package(default_visibility = ["//visibility:public"])
  17. licenses(["notice"])
  18. exports_files(["LICENSE"])
  19. # Protos.
  20. proto_library(
  21. name = "serialization_proto",
  22. srcs = ["serialization.proto"],
  23. )
  24. cc_proto_library(
  25. name = "serialization_cc_proto",
  26. deps = [":serialization_proto"],
  27. )
  28. # Context.
  29. cc_library(
  30. name = "context",
  31. hdrs = ["context.h"],
  32. deps = [
  33. ":error_params",
  34. ":ntt_parameters",
  35. ":statusor_fork",
  36. "@com_google_absl//absl/memory",
  37. ],
  38. )
  39. cc_test(
  40. name = "context_test",
  41. size = "small",
  42. srcs = ["context_test.cc"],
  43. deps = [
  44. ":constants",
  45. ":context",
  46. ":integral_types",
  47. ":montgomery",
  48. ":statusor_fork",
  49. "//testing:parameters",
  50. "//testing:status_testing",
  51. "@com_github_google_googletest//:gtest_main",
  52. "@com_google_absl//absl/numeric:int128",
  53. ],
  54. )
  55. # Integral types for integers.
  56. cc_library(
  57. name = "integral_types",
  58. hdrs = ["integral_types.h"],
  59. deps = [
  60. "@com_google_absl//absl/numeric:int128",
  61. ],
  62. )
  63. # Constants.
  64. cc_library(
  65. name = "constants",
  66. hdrs = ["constants.h"],
  67. deps = [
  68. ":integral_types",
  69. "@com_google_absl//absl/numeric:int128",
  70. ],
  71. )
  72. # Utilities.
  73. cc_library(
  74. name = "bits_util",
  75. hdrs = ["bits_util.h"],
  76. deps = [
  77. ":integral_types",
  78. "@com_google_absl//absl/numeric:int128",
  79. ],
  80. )
  81. cc_test(
  82. name = "bits_util_test",
  83. size = "small",
  84. srcs = ["bits_util_test.cc"],
  85. deps = [
  86. ":bits_util",
  87. "@com_github_google_googletest//:gtest_main",
  88. "@com_google_absl//absl/numeric:int128",
  89. ],
  90. )
  91. cc_library(
  92. name = "sample_error",
  93. hdrs = ["sample_error.h"],
  94. deps = [
  95. ":bits_util",
  96. ":constants",
  97. ":error_params",
  98. ":statusor_fork",
  99. "//prng",
  100. "@com_google_absl//absl/strings",
  101. ],
  102. )
  103. cc_test(
  104. name = "sample_error_test",
  105. size = "small",
  106. srcs = [
  107. "sample_error_test.cc",
  108. ],
  109. deps = [
  110. ":context",
  111. ":montgomery",
  112. ":sample_error",
  113. ":symmetric_encryption",
  114. "//testing:parameters",
  115. "//testing:status_is_fork",
  116. "//testing:status_testing",
  117. "//testing:testing_prng",
  118. "@com_github_google_googletest//:gtest_main",
  119. ],
  120. )
  121. cc_library(
  122. name = "statusor_fork",
  123. srcs = ["statusor.cc"],
  124. hdrs = [
  125. "status_macros.h",
  126. "statusor.h",
  127. ],
  128. deps = [
  129. "@com_github_google_glog//:glog",
  130. "@com_google_absl//absl/base:core_headers",
  131. "@com_google_absl//absl/status",
  132. "@com_google_absl//absl/types:optional",
  133. ],
  134. )
  135. cc_test(
  136. name = "statusor_test",
  137. size = "small",
  138. srcs = ["statusor_test.cc"],
  139. deps = [
  140. ":statusor_fork",
  141. "@com_github_google_googletest//:gtest_main",
  142. "@com_google_absl//absl/status",
  143. ],
  144. )
  145. cc_test(
  146. name = "status_macros_test",
  147. size = "small",
  148. srcs = ["status_macros_test.cc"],
  149. deps = [
  150. ":statusor_fork",
  151. "@com_github_google_googletest//:gtest_main",
  152. "@com_google_absl//absl/status",
  153. ],
  154. )
  155. # Montgomery integers.
  156. cc_library(
  157. name = "montgomery",
  158. srcs = ["montgomery.cc"],
  159. hdrs = ["montgomery.h"],
  160. deps = [
  161. ":bits_util",
  162. ":constants",
  163. ":int256",
  164. ":serialization_cc_proto",
  165. ":statusor_fork",
  166. ":transcription",
  167. "//prng",
  168. "@com_github_google_glog//:glog",
  169. "@com_google_absl//absl/numeric:int128",
  170. "@com_google_absl//absl/strings",
  171. ],
  172. )
  173. cc_test(
  174. name = "montgomery_test",
  175. size = "small",
  176. srcs = [
  177. "montgomery_test.cc",
  178. ],
  179. deps = [
  180. ":constants",
  181. ":montgomery",
  182. ":serialization_cc_proto",
  183. ":statusor_fork",
  184. "//testing:parameters",
  185. "//testing:status_is_fork",
  186. "//testing:status_testing",
  187. "//testing:testing_prng",
  188. "@com_github_google_googletest//:gtest_main",
  189. "@com_google_absl//absl/numeric:int128",
  190. ],
  191. )
  192. # NTT parameters.
  193. cc_library(
  194. name = "ntt_parameters",
  195. srcs = ["ntt_parameters.cc"],
  196. hdrs = ["ntt_parameters.h"],
  197. deps = [
  198. ":constants",
  199. ":statusor_fork",
  200. "@com_google_absl//absl/memory",
  201. "@com_google_absl//absl/strings",
  202. ],
  203. )
  204. cc_test(
  205. name = "ntt_parameters_test",
  206. size = "small",
  207. srcs = [
  208. "ntt_parameters_test.cc",
  209. ],
  210. deps = [
  211. ":constants",
  212. ":montgomery",
  213. ":ntt_parameters",
  214. ":statusor_fork",
  215. "//testing:parameters",
  216. "//testing:status_is_fork",
  217. "//testing:status_testing",
  218. "@com_github_google_googletest//:gtest_main",
  219. "@com_google_absl//absl/numeric:int128",
  220. ],
  221. )
  222. # NTT polynomial.
  223. cc_library(
  224. name = "polynomial",
  225. hdrs = ["polynomial.h"],
  226. deps = [
  227. ":constants",
  228. ":ntt_parameters",
  229. ":serialization_cc_proto",
  230. ":statusor_fork",
  231. "//prng",
  232. "@com_google_absl//absl/strings",
  233. ],
  234. )
  235. cc_test(
  236. name = "polynomial_test",
  237. size = "small",
  238. srcs = [
  239. "polynomial_test.cc",
  240. ],
  241. deps = [
  242. ":constants",
  243. ":montgomery",
  244. ":ntt_parameters",
  245. ":polynomial",
  246. ":serialization_cc_proto",
  247. ":statusor_fork",
  248. "//prng:integral_prng_testing_types",
  249. "//testing:coefficient_polynomial",
  250. "//testing:status_is_fork",
  251. "//testing:status_testing",
  252. "//testing:testing_prng",
  253. "@com_github_google_googletest//:gtest_main",
  254. ],
  255. )
  256. # Error parameters.
  257. cc_library(
  258. name = "error_params",
  259. hdrs = ["error_params.h"],
  260. deps = [
  261. ":montgomery",
  262. ":ntt_parameters",
  263. ":statusor_fork",
  264. ],
  265. )
  266. cc_test(
  267. name = "error_params_test",
  268. size = "small",
  269. srcs = [
  270. "error_params_test.cc",
  271. ],
  272. deps = [
  273. ":constants",
  274. ":context",
  275. ":error_params",
  276. ":montgomery",
  277. ":ntt_parameters",
  278. ":statusor_fork",
  279. ":symmetric_encryption",
  280. "//prng:integral_prng_types",
  281. "//testing:parameters",
  282. "//testing:status_is_fork",
  283. "//testing:status_testing",
  284. "//testing:testing_prng",
  285. "//testing:testing_utils",
  286. "@com_github_google_googletest//:gtest_main",
  287. ],
  288. )
  289. # Encryption.
  290. cc_library(
  291. name = "symmetric_encryption",
  292. hdrs = ["symmetric_encryption.h"],
  293. deps = [
  294. ":error_params",
  295. ":polynomial",
  296. ":sample_error",
  297. ":serialization_cc_proto",
  298. ":statusor_fork",
  299. "//prng",
  300. "//prng:integral_prng_types",
  301. ],
  302. )
  303. cc_test(
  304. name = "symmetric_encryption_test",
  305. size = "medium",
  306. srcs = [
  307. "symmetric_encryption_test.cc",
  308. ],
  309. deps = [
  310. ":constants",
  311. ":context",
  312. ":montgomery",
  313. ":ntt_parameters",
  314. ":polynomial",
  315. ":serialization_cc_proto",
  316. ":statusor_fork",
  317. ":symmetric_encryption",
  318. "//prng:integral_prng_types",
  319. "//testing:parameters",
  320. "//testing:status_is_fork",
  321. "//testing:status_testing",
  322. "//testing:testing_prng",
  323. "//testing:testing_utils",
  324. "@com_github_google_googletest//:gtest_main",
  325. ],
  326. )
  327. cc_library(
  328. name = "symmetric_encryption_with_prng",
  329. hdrs = ["symmetric_encryption_with_prng.h"],
  330. deps = [
  331. ":polynomial",
  332. ":statusor_fork",
  333. ":symmetric_encryption",
  334. "//prng",
  335. "//prng:integral_prng_types",
  336. ],
  337. )
  338. cc_test(
  339. name = "symmetric_encryption_with_prng_test",
  340. size = "small",
  341. srcs = [
  342. "symmetric_encryption_with_prng_test.cc",
  343. ],
  344. deps = [
  345. ":context",
  346. ":montgomery",
  347. ":ntt_parameters",
  348. ":polynomial",
  349. ":statusor_fork",
  350. ":symmetric_encryption_with_prng",
  351. "//prng:integral_prng_types",
  352. "//testing:parameters",
  353. "//testing:status_is_fork",
  354. "//testing:status_testing",
  355. "//testing:testing_utils",
  356. "@com_github_google_googletest//:gtest_main",
  357. ],
  358. )
  359. # Relinearization Key
  360. cc_library(
  361. name = "relinearization_key",
  362. srcs = ["relinearization_key.cc"],
  363. hdrs = ["relinearization_key.h"],
  364. deps = [
  365. ":bits_util",
  366. ":montgomery",
  367. ":sample_error",
  368. ":statusor_fork",
  369. ":symmetric_encryption",
  370. ":symmetric_encryption_with_prng",
  371. "//prng:integral_prng_types",
  372. "@com_google_absl//absl/numeric:int128",
  373. ],
  374. )
  375. cc_test(
  376. name = "relinearization_key_test",
  377. size = "small",
  378. srcs = ["relinearization_key_test.cc"],
  379. deps = [
  380. ":constants",
  381. ":montgomery",
  382. ":ntt_parameters",
  383. ":polynomial",
  384. ":relinearization_key",
  385. ":statusor_fork",
  386. ":symmetric_encryption",
  387. "//prng:integral_prng_types",
  388. "//testing:status_is_fork",
  389. "//testing:status_testing",
  390. "//testing:testing_prng",
  391. "@com_github_google_googletest//:gtest_main",
  392. ],
  393. )
  394. # Galois Key.
  395. cc_library(
  396. name = "galois_key",
  397. hdrs = ["galois_key.h"],
  398. deps = [
  399. ":relinearization_key",
  400. ":statusor_fork",
  401. "@com_google_absl//absl/strings",
  402. ],
  403. )
  404. cc_test(
  405. name = "galois_key_test",
  406. size = "small",
  407. srcs = ["galois_key_test.cc"],
  408. deps = [
  409. ":constants",
  410. ":galois_key",
  411. ":montgomery",
  412. ":ntt_parameters",
  413. ":polynomial",
  414. ":statusor_fork",
  415. ":symmetric_encryption",
  416. "//prng:integral_prng_types",
  417. "//testing:status_is_fork",
  418. "//testing:status_testing",
  419. "//testing:testing_prng",
  420. "//testing:testing_utils",
  421. "@com_github_google_googletest//:gtest_main",
  422. ],
  423. )
  424. # int256 Type
  425. cc_library(
  426. name = "int256",
  427. srcs = ["int256.cc"],
  428. hdrs = ["int256.h"],
  429. deps = [
  430. ":integral_types",
  431. "@com_github_google_glog//:glog",
  432. "@com_google_absl//absl/numeric:int128",
  433. ],
  434. )
  435. cc_test(
  436. name = "int256_test",
  437. size = "small",
  438. srcs = ["int256_test.cc"],
  439. deps = [
  440. ":int256",
  441. "@com_github_google_glog//:glog",
  442. "@com_github_google_googletest//:gtest_main",
  443. "@com_google_absl//absl/container:fixed_array",
  444. "@com_google_absl//absl/numeric:int128",
  445. ],
  446. )
  447. # Transcription
  448. cc_library(
  449. name = "transcription",
  450. hdrs = ["transcription.h"],
  451. deps = [
  452. ":statusor_fork",
  453. "@com_google_absl//absl/status",
  454. "@com_google_absl//absl/strings",
  455. ],
  456. )
  457. cc_test(
  458. name = "transcription_test",
  459. size = "small",
  460. srcs = ["transcription_test.cc"],
  461. deps = [
  462. ":integral_types",
  463. ":statusor_fork",
  464. ":transcription",
  465. "//testing:status_is_fork",
  466. "//testing:status_testing",
  467. "@com_github_google_googletest//:gtest_main",
  468. "@com_google_absl//absl/numeric:int128",
  469. ],
  470. )