HEaaN
Crypto Lab's great homomorphic encryption library
Message.hpp
Go to the documentation of this file.
1 // //
3 // Copyright (C) 2021-2023 Crypto Lab Inc. //
4 // //
5 // - This file is part of HEaaN homomorphic encryption library. //
6 // - HEaaN cannot be copied and/or distributed without the express permission //
7 // of Crypto Lab Inc. //
8 // //
10 
11 #pragma once
12 
13 #include <iterator>
14 #include <vector>
15 
16 #include "HEaaN/HEaaNExport.hpp"
17 #include "HEaaN/Integers.hpp"
18 #include "HEaaN/Pointer.hpp"
19 #include "HEaaN/Real.hpp"
20 #include "HEaaN/device/Device.hpp"
21 
22 namespace HEaaN {
29 class MessageImpl;
31 public:
33  using ConstMessageIterator = const Complex *;
34 
35  Message();
36 
42  explicit Message(u64 log_slots);
43 
49  explicit Message(u64 log_slots, Complex initial);
50 
51  Complex &operator[](u64 idx);
52 
53  const Complex &operator[](u64 idx) const;
54 
57  bool isEmpty() const;
58 
61  u64 getLogSlots() const;
62 
63  u64 getSize() const;
64 
65  void resize(u64 size);
66 
67  MessageIterator begin() noexcept;
68 
69  ConstMessageIterator begin() const noexcept;
70 
71  MessageIterator end() noexcept;
72 
73  ConstMessageIterator end() const noexcept;
74 
75  auto rbegin() { return std::reverse_iterator(end()); }
76 
77  auto rbegin() const { return std::reverse_iterator(end()); }
78 
79  auto rend() { return std::reverse_iterator(begin()); }
80 
81  auto rend() const { return std::reverse_iterator(begin()); }
82 
83  template <class Archive> void serialize(Archive &ar);
84 
85  void to(const Device &device);
86 
87  void allocate(const Device &device);
88 
89  const Device &getDevice() const;
90 
91  void save(const std::string &path) const;
92 
93  void save(std::ostream &stream) const;
94 
95  void load(const std::string &path);
96 
97  void load(std::istream &stream);
98 
99 private:
101 };
102 } // namespace HEaaN
HEaaN::Complex
std::complex< Real > Complex
Default type for representing a complex number.
Definition: Real.hpp:22
HEaaN::load
HEAAN_API void load(EvaluationKey &key, std::istream &stream)
Load key from a given stream.
HEaaN::Message
Definition: Message.hpp:30
HEaaN::Pointer< MessageImpl >
Device.hpp
HEaaN::Message::rbegin
auto rbegin() const
Definition: Message.hpp:77
HEaaN::u64
std::uint64_t u64
Definition: Integers.hpp:17
Pointer.hpp
HEaaN::Message::rend
auto rend()
Definition: Message.hpp:79
HEaaN::Message::impl_
Pointer< MessageImpl > impl_
Definition: Message.hpp:100
HEaaN::Device
Definition: Device.hpp:33
HEaaN::Message::rend
auto rend() const
Definition: Message.hpp:81
Integers.hpp
HEaaN::Message::ConstMessageIterator
const Complex * ConstMessageIterator
Definition: Message.hpp:33
HEaaN::save
HEAAN_API void save(const EvaluationKey &key, std::ostream &stream)
Save key to a given stream.
HEaaNExport.hpp
HEaaN::Message::MessageIterator
Complex * MessageIterator
Definition: Message.hpp:32
HEAAN_API
#define HEAAN_API
Definition: HEaaNExport.hpp:26
HEaaN
Definition: Bootstrapper.hpp:16
Real.hpp