Skip to content

Commit

Permalink
Renamed IntArray to DynArray
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlaine committed Oct 10, 2020
1 parent 79af9f8 commit f17ee91
Show file tree
Hide file tree
Showing 26 changed files with 150 additions and 151 deletions.
5 changes: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ The performance improvement should be expected to be around 20-30x.

### API Changes

- Added const overloads of `IntArray::begin` and `IntArray::end`.
- Added `std::hash` implementation for `EncryptionParameters` (in addition to `parms_id_type`) so it is possible to create e.g. `std::unordered_map` of `EncryptionParameters`.
- Removed `BatchEncoder` API for encoding and decoding `Plaintext` objects inplace.
This is because a `Plaintext` object with slot-data written into the coefficients is (confusingly) not valid to be used for encryption.
Expand All @@ -22,6 +21,8 @@ The `BigUInt` class was only used by the `IntegerEncoder`.
- Changed the names of the public key generation functions to clearly express that a new key is created each time, e.g., `KeyGenerator::create_public_key`.
- Removed the `KeyGenerator::relin_keys_local` and `KeyGenerator::galois_keys_local` functions.
These were poorly named and have been replaced with overloads of `KeyGenerator::create_relin_keys` and `KeyGenerator::create_galois_keys` that take an out-parameter of type `RelinKeys` or `GaloisKeys`.
- Renamed `IntArray` to `DynArray` (dynamic array) and removed unnecessary limitations on the object type template parameter.
- Added const overloads for `DynArray::begin` and `DynArray::end`.

### Other

Expand All @@ -35,6 +36,8 @@ These were poorly named and have been replaced with overloads of `KeyGenerator::

Renamed files and directories:

- `native/src/seal/intarray.h` to [native/src/seal/dynarray.h](native/src/seal/dynarray.h)

New files:

- [native/src/seal/util/dwthandler.h](native/src/seal/util/dwthandler.h)
Expand Down
2 changes: 1 addition & 1 deletion native/src/SEAL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<ClInclude Include="seal\encryptor.h" />
<ClInclude Include="seal\evaluator.h" />
<ClInclude Include="seal\galoiskeys.h" />
<ClInclude Include="seal\intarray.h" />
<ClInclude Include="seal\dynarray.h" />
<ClInclude Include="seal\keygenerator.h" />
<ClInclude Include="seal\kswitchkeys.h" />
<ClInclude Include="seal\memorymanager.h" />
Expand Down
2 changes: 1 addition & 1 deletion native/src/SEAL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<ClInclude Include="seal\galoiskeys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="seal\intarray.h">
<ClInclude Include="seal\dynarray.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="seal\keygenerator.h">
Expand Down
2 changes: 1 addition & 1 deletion native/src/seal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ install(
${CMAKE_CURRENT_LIST_DIR}/modulus.h
${CMAKE_CURRENT_LIST_DIR}/context.h
${CMAKE_CURRENT_LIST_DIR}/decryptor.h
${CMAKE_CURRENT_LIST_DIR}/dynarray.h
${CMAKE_CURRENT_LIST_DIR}/encryptionparams.h
${CMAKE_CURRENT_LIST_DIR}/encryptor.h
${CMAKE_CURRENT_LIST_DIR}/evaluator.h
${CMAKE_CURRENT_LIST_DIR}/galoiskeys.h
${CMAKE_CURRENT_LIST_DIR}/intarray.h
${CMAKE_CURRENT_LIST_DIR}/keygenerator.h
${CMAKE_CURRENT_LIST_DIR}/kswitchkeys.h
${CMAKE_CURRENT_LIST_DIR}/memorymanager.h
Expand Down
4 changes: 2 additions & 2 deletions native/src/seal/c/plaintext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using ph = struct Plaintext::PlaintextPrivateHelper
plain->scale_ = new_scale;
}

static void swap_data(seal::Plaintext *plain, seal::IntArray<uint64_t> &new_data)
static void swap_data(seal::Plaintext *plain, seal::DynArray<uint64_t> &new_data)
{
swap(plain->data_, new_data);
}
Expand Down Expand Up @@ -436,7 +436,7 @@ SEAL_C_FUNC Plaintext_SwapData(void *thisptr, uint64_t count, uint64_t *new_data
IfNullRet(plain, E_POINTER);
IfNullRet(new_data, E_POINTER);

IntArray<uint64_t> new_array(plain->pool());
DynArray<uint64_t> new_array(plain->pool());
new_array.resize(count);
copy_n(new_data, count, new_array.begin());

Expand Down
12 changes: 6 additions & 6 deletions native/src/seal/ciphertext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ namespace seal
size_t data_size;
if (has_seed_marker())
{
// Create a temporary aliased IntArray of smaller size
IntArray<ct_coeff_type> alias_data(
// Create a temporary aliased DynArray of smaller size
DynArray<ct_coeff_type> alias_data(
Pointer<ct_coeff_type>::Aliasing(const_cast<ct_coeff_type *>(data_.cbegin())), data_.size() / 2, false,
data_.pool());

Expand Down Expand Up @@ -188,7 +188,7 @@ namespace seal
// Save_members must be a const method.
// Create an alias of data_, must be handled with care.
// Alternatively, create and serialize a half copy of data_.
IntArray<ct_coeff_type> alias_data(data_.pool_);
DynArray<ct_coeff_type> alias_data(data_.pool_);
alias_data.size_ = half_size;
alias_data.capacity_ = half_size;
auto alias_ptr = util::Pointer<ct_coeff_type>::Aliasing(const_cast<ct_coeff_type *>(data_.cbegin()));
Expand All @@ -200,7 +200,7 @@ namespace seal
}
else
{
// Save the IntArray
// Save the DynArray
data_.save(stream, compr_mode_type::none);
}
}
Expand Down Expand Up @@ -276,8 +276,8 @@ namespace seal
new_data.data_.reserve(total_uint64_count);

// Load the data. Note that we are supplying also the expected maximum
// size of the loaded IntArray. This is an important security measure to
// prevent a malformed IntArray from causing arbitrarily large memory
// size of the loaded DynArray. This is an important security measure to
// prevent a malformed DynArray from causing arbitrarily large memory
// allocations.
new_data.data_.load(stream, total_uint64_count);

Expand Down
8 changes: 4 additions & 4 deletions native/src/seal/ciphertext.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#pragma once

#include "seal/context.h"
#include "seal/intarray.h"
#include "seal/dynarray.h"
#include "seal/memorymanager.h"
#include "seal/randomgen.h"
#include "seal/valcheck.h"
Expand Down Expand Up @@ -297,9 +297,9 @@ namespace seal
Ciphertext &operator=(Ciphertext &&assign) = default;

/**
Returns a reference to the backing IntArray object.
Returns a reference to the backing DynArray object.
*/
SEAL_NODISCARD inline const auto &int_array() const noexcept
SEAL_NODISCARD inline const auto &dyn_array() const noexcept
{
return data_;
}
Expand Down Expand Up @@ -691,6 +691,6 @@ namespace seal

double scale_ = 1.0;

IntArray<ct_coeff_type> data_;
DynArray<ct_coeff_type> data_;
};
} // namespace seal
Loading

0 comments on commit f17ee91

Please sign in to comment.