-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add HEXL-FPGA compatibility for DyadicMultiply and KeySwitch (#109)
Co-authored-by: Tomas Gonzalez Aragon <tomas.gonzalez.aragon@intel.com>
- Loading branch information
1 parent
352e9ed
commit fe56a32
Showing
14 changed files
with
211 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (C) 2020-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef HEXL_FPGA_COMPATIBLE_DYADIC_MULTIPLY | ||
|
||
#include "hexl/experimental/seal/dyadic-multiply.hpp" | ||
|
||
#include "hexl/experimental/seal/dyadic-multiply-internal.hpp" | ||
|
||
namespace intel { | ||
namespace hexl { | ||
|
||
void DyadicMultiply(uint64_t* result, const uint64_t* operand1, | ||
const uint64_t* operand2, uint64_t n, | ||
const uint64_t* moduli, uint64_t num_moduli) { | ||
intel::hexl::internal::DyadicMultiply(result, operand1, operand2, n, moduli, | ||
num_moduli); | ||
} | ||
|
||
} // namespace hexl | ||
} // namespace intel | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (C) 2020-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef HEXL_FPGA_COMPATIBLE_KEYSWITCH | ||
|
||
#include "hexl/experimental/seal/key-switch.hpp" | ||
|
||
#include "hexl/experimental/seal/key-switch-internal.hpp" | ||
|
||
namespace intel { | ||
namespace hexl { | ||
|
||
void KeySwitch(uint64_t* result, const uint64_t* t_target_iter_ptr, uint64_t n, | ||
uint64_t decomp_modulus_size, uint64_t key_modulus_size, | ||
uint64_t rns_modulus_size, uint64_t key_component_count, | ||
const uint64_t* moduli, const uint64_t** k_switch_keys, | ||
const uint64_t* modswitch_factors, | ||
const uint64_t* root_of_unity_powers_ptr) { | ||
intel::hexl::internal::KeySwitch( | ||
result, t_target_iter_ptr, n, decomp_modulus_size, key_modulus_size, | ||
rns_modulus_size, key_component_count, moduli, k_switch_keys, | ||
modswitch_factors, root_of_unity_powers_ptr); | ||
} | ||
|
||
} // namespace hexl | ||
} // namespace intel | ||
#endif |
29 changes: 29 additions & 0 deletions
29
hexl/include/hexl/experimental/seal/dyadic-multiply-internal.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (C) 2020-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
namespace intel { | ||
namespace hexl { | ||
namespace internal { | ||
|
||
/// @brief Computes dyadic multiplication | ||
/// @param[in,out] result Ciphertext data. Will be over-written with result. Has | ||
/// (2 * n * num_moduli) elements | ||
/// @param[in] operand1 First ciphertext argument. Has (2 * n * num_moduli) | ||
/// elements. | ||
/// @param[in] operand2 Second ciphertext argument. Has (2 * n * num_moduli) | ||
/// elements. | ||
/// @param[in] n Number of coefficients in each polynomial | ||
/// @param[in] moduli Pointer to contiguous array of num_moduli word-sized | ||
/// coefficient moduli | ||
/// @param[in] num_moduli Number of word-sized coefficient moduli | ||
void DyadicMultiply(uint64_t* result, const uint64_t* operand1, | ||
const uint64_t* operand2, uint64_t n, | ||
const uint64_t* moduli, uint64_t num_moduli); | ||
|
||
} // namespace internal | ||
} // namespace hexl | ||
} // namespace intel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
hexl/include/hexl/experimental/seal/key-switch-internal.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (C) 2020-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
namespace intel { | ||
namespace hexl { | ||
namespace internal { | ||
|
||
/// @brief Computes key switching in-place | ||
/// @param[in,out] result Ciphertext data. Will be over-written with result. Has | ||
/// (n * decomp_modulus_size * key_component_count) elements | ||
/// @param[in] t_target_iter_ptr Pointer to the last component of the input | ||
/// ciphertext | ||
/// @param[in] n Number of coefficients in each polynomial | ||
/// @param[in] decomp_modulus_size Number of moduli in the ciphertext at its | ||
/// current level, excluding one auxiliary prime. | ||
/// @param[in] key_modulus_size Number of moduli in the ciphertext at its top | ||
/// level, including one auxiliary prime. | ||
/// @param[in] rns_modulus_size Number of moduli in the ciphertext at its | ||
/// current level, including one auxiliary prime. rns_modulus_size == | ||
/// decomp_modulus_size + 1 | ||
/// @param[in] key_component_count Number of components in the resulting | ||
/// ciphertext, e.g. key_component_count == 2. | ||
/// @param[in] moduli Array of word-sized coefficient moduli. There must be | ||
/// key_modulus_size moduli in the array | ||
/// @param[in] k_switch_keys Array of evaluation key data. Has | ||
/// decomp_modulus_size entries, each with | ||
/// coeff_count * ((key_modulus_size - 1)+ (key_component_count - 1) * | ||
/// (key_modulus_size) + 1) entries | ||
/// @param[in] modswitch_factors Array of modulus switch factors | ||
/// @param[in] root_of_unity_powers_ptr Array of root of unity powers | ||
void KeySwitch(uint64_t* result, const uint64_t* t_target_iter_ptr, uint64_t n, | ||
uint64_t decomp_modulus_size, uint64_t key_modulus_size, | ||
uint64_t rns_modulus_size, uint64_t key_component_count, | ||
const uint64_t* moduli, const uint64_t** k_switch_keys, | ||
const uint64_t* modswitch_factors, | ||
const uint64_t* root_of_unity_powers_ptr = nullptr); | ||
|
||
} // namespace internal | ||
} // namespace hexl | ||
} // namespace intel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.