fhelium/ckks_tables.h
#include <fhelium/ckks_tables.h> · namespace fhelium::ckks
Construction of the CKKS slot-embedding and Galois index tables.
The ring is step follows torch.roll(slots, shifts=step). The slot generator
| Function | Devices | Summary |
|---|---|---|
rotation_galois_element | Any device | Returns the Galois element step, where step for step for |
coefficient_galois_indices | Any device | Returns the gather that applies indices[j] and multiplies it by signs[j] [N]. |
slot_permutations | Any device | Returns the int64 slot permutations of the canonical embedding. |
periodic_extent | Any device | Returns the encoded length period slots: period is a power of two dividing |
periodic_slot_positions | Any device | Returns the int64 slot scatter of shape [U/2] for a periodic message of encoded length |
slot_twist | Any device | Returns the complex128 twist inverse false) or inverse true) for device. |
key_switch_table_set | Any device | Named KeySwitchTables of one key-switch configuration, without NTT schedules. |
rotation_sum_table_set | Any device | Named quotient tables of a rotation sum without rescale (sum_* slots of KeySwitchTables), which divide the QP rows by P. |
encapsulation_table_set | Any device | Named EncapsulationTables of an encapsulated modulus raise: the low key switch over source_q_moduli and low_p_moduli, the centered extension to the return basis [guard, Q, P], and the return quotient onto target_prime_ids. |
embedding_table_set | Any device | Named tables of the canonical embedding on device: the encoding scatter pre and the decoding gather post of slot_permutations, the forward twist twister and the inverse twist skewer of slot_twist of length |
periodic_table_set | Any device | Named tables of a periodic plaintext with period period slots over the basis rows of parameters (moduli moduli), on the parameters' device: the slot scatter pre and twist twister of length periodic_extent, twice_moduli even_indices, odd_indices and Montgomery twiddles whose roots are |
reconstruction_table_set | Any device | Named mixed-radix reconstruction tables of decryption over prime_ids. |
galois_table_set | Any device | GaloisTables of galois_element on device: NTT-domain source indices, coefficient source indices, and coefficient signs. |
table_slot_names | Any device | Slot names of one table family in positional order. |
rotation_galois_element
function View source
int64_t fhelium::ckks::rotation_galois_element(
int64_t log_n,
int64_t step,
int64_t generator);2
3
4
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.rotation_galois_element
fhelium_ckks_ops::rotation_galois_element(int log_n, int step, int generator) -> intReturns the Galois element step, where step for step for
coefficient_galois_indices
function View source
std::tuple<at::Tensor, at::Tensor> fhelium::ckks::coefficient_galois_indices(
int64_t log_n,
int64_t galois_element);2
3
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.coefficient_galois_indices
fhelium_ckks_ops::coefficient_galois_indices(int log_n, int galois_element) -> (Tensor, Tensor)Returns the gather that applies indices[j] and multiplies it by signs[j] [N].
slot_permutations
function View source
std::tuple<at::Tensor, at::Tensor> fhelium::ckks::slot_permutations(
int64_t log_n,
int64_t generator);2
3
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.slot_permutations
fhelium_ckks_ops::slot_permutations(int log_n, int generator) -> (Tensor, Tensor)Returns the int64 slot permutations of the canonical embedding.
Encoding scatters slot pre[i] (shape [N/2]), and decoding gathers FFT position post[k] into slot position [N]).
periodic_extent
function View source
int64_t fhelium::ckks::periodic_extent(
int64_t period,
int64_t log_n,
int64_t generator);2
3
4
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.periodic_extent
fhelium_ckks_ops::periodic_extent(int period, int log_n, int generator) -> intReturns the encoded length period slots: period is a power of two dividing
periodic_slot_positions
function View source
at::Tensor fhelium::ckks::periodic_slot_positions(
int64_t extent,
int64_t generator);2
3
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.periodic_slot_positions
fhelium_ckks_ops::periodic_slot_positions(int extent, int generator) -> TensorReturns the int64 slot scatter of shape [U/2] for a periodic message of encoded length
slot_twist
function View source
at::Tensor fhelium::ckks::slot_twist(
int64_t length,
bool inverse,
c10::Device device);2
3
4
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.slot_twist
fhelium_ckks_ops::slot_twist(int length, bool inverse, Device device) -> TensorReturns the complex128 twist inverse false) or inverse true) for device.
Encoding multiplies the FFT of the conjugate-extended slots by the forward twist; decoding multiplies the coefficients by the inverse twist before the inverse FFT.
key_switch_table_set
function View source
std::tuple<std::vector<std::string>, std::vector<at::Tensor>> fhelium::ckks::key_switch_table_set(
const at::Tensor& parameters,
c10::IntArrayRef moduli,
int64_t log_n,
c10::IntArrayRef q_prime_ids,
c10::IntArrayRef p_prime_ids,
c10::IntArrayRef digits,
std::string basis_conversion,
std::string moddown_rounding,
bool rescale,
c10::IntArrayRef drop_prime_ids,
c10::IntArrayRef target_prime_ids,
std::string rescale_rounding);2
3
4
5
6
7
8
9
10
11
12
13
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.key_switch_table_set
fhelium_ckks_ops::key_switch_table_set(Tensor parameters, int[] moduli, int log_n, int[] q_prime_ids, int[] p_prime_ids, int[] digits, str basis_conversion, str moddown_rounding, bool rescale, int[] drop_prime_ids, int[] target_prime_ids, str rescale_rounding) -> (str[], Tensor[])Named KeySwitchTables of one key-switch configuration, without NTT schedules.
digits lists flattened (start, stop, key_digit) triples over the Q rows. With rescale, the joint ModDown/rescale tables for the dropped rows and target rows are added. The result pairs the slot names of the defined fields with their Tensors.
rotation_sum_table_set
function View source
std::tuple<std::vector<std::string>, std::vector<at::Tensor>> fhelium::ckks::rotation_sum_table_set(
const at::Tensor& parameters,
c10::IntArrayRef moduli,
int64_t log_n,
c10::IntArrayRef q_prime_ids,
c10::IntArrayRef p_prime_ids,
std::string_view rounding);2
3
4
5
6
7
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.rotation_sum_table_set
fhelium_ckks_ops::rotation_sum_table_set(Tensor parameters, int[] moduli, int log_n, int[] q_prime_ids, int[] p_prime_ids, str rounding) -> (str[], Tensor[])Named quotient tables of a rotation sum without rescale (sum_* slots of KeySwitchTables), which divide the QP rows by P.
encapsulation_table_set
function View source
std::tuple<std::vector<std::string>, std::vector<at::Tensor>> fhelium::ckks::encapsulation_table_set(
const at::Tensor& parameters,
c10::IntArrayRef moduli,
int64_t log_n,
std::string_view ntt_backend,
double scale,
c10::IntArrayRef source_q_moduli,
c10::IntArrayRef low_p_moduli,
int64_t return_prime,
c10::IntArrayRef return_p_moduli,
c10::IntArrayRef q_moduli,
c10::IntArrayRef target_prime_ids,
std::string_view rounding);2
3
4
5
6
7
8
9
10
11
12
13
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.encapsulation_table_set
fhelium_ckks_ops::encapsulation_table_set(Tensor parameters, int[] moduli, int log_n, str ntt_backend, float scale, int[] source_q_moduli, int[] low_p_moduli, int return_prime, int[] return_p_moduli, int[] q_moduli, int[] target_prime_ids, str rounding) -> (str[], Tensor[])Named EncapsulationTables of an encapsulated modulus raise: the low key switch over source_q_moduli and low_p_moduli, the centered extension to the return basis [guard, Q, P], and the return quotient onto target_prime_ids.
embedding_table_set
function View source
std::tuple<std::vector<std::string>, std::vector<at::Tensor>> fhelium::ckks::embedding_table_set(
int64_t log_n,
int64_t generator,
c10::Device device);2
3
4
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.embedding_table_set
fhelium_ckks_ops::embedding_table_set(int log_n, int generator, Device device) -> (str[], Tensor[])Named tables of the canonical embedding on device: the encoding scatter pre and the decoding gather post of slot_permutations, the forward twist twister and the inverse twist skewer of slot_twist of length
periodic_table_set
function View source
std::tuple<std::vector<std::string>, std::vector<at::Tensor>> fhelium::ckks::periodic_table_set(
const at::Tensor& parameters,
c10::IntArrayRef moduli,
int64_t log_n,
int64_t period,
int64_t generator);2
3
4
5
6
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.periodic_table_set
fhelium_ckks_ops::periodic_table_set(Tensor parameters, int[] moduli, int log_n, int period, int generator) -> (str[], Tensor[])Named tables of a periodic plaintext with period period slots over the basis rows of parameters (moduli moduli), on the parameters' device: the slot scatter pre and twist twister of length periodic_extent, twice_moduli even_indices, odd_indices and Montgomery twiddles whose roots are
reconstruction_table_set
function View source
std::tuple<std::vector<std::string>, std::vector<at::Tensor>> fhelium::ckks::reconstruction_table_set(
const at::Tensor& parameters,
c10::IntArrayRef moduli,
int64_t log_n,
c10::IntArrayRef prime_ids);2
3
4
5
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.reconstruction_table_set
fhelium_ckks_ops::reconstruction_table_set(Tensor parameters, int[] moduli, int log_n, int[] prime_ids) -> (str[], Tensor[])Named mixed-radix reconstruction tables of decryption over prime_ids.
galois_table_set
function View source
std::vector<at::Tensor> fhelium::ckks::galois_table_set(
int64_t log_n,
int64_t galois_element,
c10::Device device);2
3
4
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.galois_table_set
fhelium_ckks_ops::galois_table_set(int log_n, int galois_element, Device device) -> Tensor[]GaloisTables of galois_element on device: NTT-domain source indices, coefficient source indices, and coefficient signs.
table_slot_names
function View source
std::vector<std::string> fhelium::ckks::table_slot_names(
std::string_view family,
int64_t digit_count);2
3
Devices: Any device
Torch operator: torch.ops.fhelium_ckks_ops.table_slot_names
fhelium_ckks_ops::table_slot_names(str family, int digit_count) -> str[]Slot names of one table family in positional order.
family is ntt, key_switch, rescale, basis_extension, trailing_quotient, encapsulation, ring, decryption, secret_conversion, or galois. The key_switch and encapsulation families append digit_count groups of digit<i>_ slots.