Multiplication of integers Multiplication of integers via hypergraphs in HFHE. Principles of noise control in multiplication.
The mechanics of integer multiplication are different from those used for cipher vectors and can be reduced to tensor products over hyperedges. To begin, two integer values, A A A and B B B , shall be defined. They will be preliminarily transformed and processed through a transformation mechanism:
A = E ( x A ) , B = E ( x B ) A = \mathcal{E}(x_A), \quad B = \mathcal{E}(x_B) A = E ( x A ) , B = E ( x B ) The form of the tensor product of these values will be defined as follows:
T ( A , B ) = A ⊗ B T(A, B) = A \otimes B T ( A , B ) = A ⊗ B where:
T ( A , B ) i j = E ( A i j ) ⋅ E ( B i j ) T(A, B)_{ij} = \mathcal{E}(A_{ij}) \cdot \mathcal{E}(B_{ij}) T ( A , B ) ij = E ( A ij ) ⋅ E ( B ij ) Now it is necessary to add cubic effects to the accumulation of noise for each element of the matrices:
N ( A i j ) = 1 r 2 + ϵ i j + O ( ϵ i j 3 ) N(A_{ij}) = \frac{1}{r^2} + \epsilon_{ij} + O\left( \epsilon_{ij}^3 \right) N ( A ij ) = r 2 1 + ϵ ij + O ( ϵ ij 3 ) Now, for the result of the product, the noise will be defined as follows:
N ( T ( A , B ) ) = ∑ i = 1 r ( N ( A i j ) + N ( B i j ) ) + O ( ∑ i , j ϵ i j 3 ) N(T(A, B)) = \sum_{i=1}^{r} \left( N(A_{ij}) + N(B_{ij}) \right) + O\left( \sum_{i,j} \epsilon_{ij}^3 \right) N ( T ( A , B )) = i = 1 ∑ r ( N ( A ij ) + N ( B ij ) ) + O ( i , j ∑ ϵ ij 3 ) The normalization mechanism for row i i i of matrix ( Υ ) (\Upsilon) ( Υ ) , where all noise elements include cubic dependencies, is defined as follows:
ϵ i j = 1 r 2 + ϵ i j , j ≠ i \epsilon_{ij} = \frac{1}{r^2} + \epsilon_{ij}, \quad j \neq i ϵ ij = r 2 1 + ϵ ij , j = i The estimate for the normalized row, taking cubic terms into account, is defined as follows:
f i ( Υ ) = ∑ j = 1 r ( 1 r 2 + ϵ i j + O ( ϵ i j 3 ) ) ln ( 1 + r 2 ϵ i j ) f_i(\Upsilon) = \sum_{j=1}^{r} \left( \frac{1}{r^2} + \epsilon_{ij} + O(\epsilon_{ij}^3) \right) \ln(1 + r^2 \epsilon_{ij}) f i ( Υ ) = j = 1 ∑ r ( r 2 1 + ϵ ij + O ( ϵ ij 3 ) ) ln ( 1 + r 2 ϵ ij ) Ultimately, the noise for the product of the elements is defined as follows:
N ( T ( A , B ) ) = ln r r − δ i ln ( r − r 2 δ i ) + ∑ j ≠ i δ i j ln ( r 2 δ i j ) + O ( ∑ i , j ϵ i j 3 ) N(T(A, B)) = \ln \frac{r}{r} - \delta_i \ln(r - r^2 \delta_i) + \sum_{j \neq i} \delta_{ij} \ln(r^2 \delta_{ij}) + O\left( \sum_{i,j} \epsilon_{ij}^3 \right) N ( T ( A , B )) = ln r r − δ i ln ( r − r 2 δ i ) + j = i ∑ δ ij ln ( r 2 δ ij ) + O ( i , j ∑ ϵ ij 3 ) The accumulated noise now incorporates both a logarithmic component and cubic elements:
f i ( Υ ) ≥ ln r r + δ i ln δ i + δ i ln ( r r − 1 ) − δ i + O ( δ i 3 ) f_i(\Upsilon) \geq \frac{\ln r}{r} + \delta_i \ln \delta_i + \delta_i \ln \left( \frac{r}{r - 1} \right) - \delta_i + O(\delta_i^3) f i ( Υ ) ≥ r ln r + δ i ln δ i + δ i ln ( r − 1 r ) − δ i + O ( δ i 3 ) Thus, the system of multiplication of two integers will include the tensor product, logarithmic dependencies and cubic elements and is expressed as follows:
T ( A , B ) = ∑ i = 1 r ( 1 r 2 + ϵ i j + O ( ϵ i j 3 ) ) ln ( 1 + r 2 ϵ i j ) + N total T(A, B) = \sum_{i=1}^{r} \left( \frac{1}{r^2} + \epsilon_{ij} + O(\epsilon_{ij}^3) \right) \ln(1 + r^2 \epsilon_{ij}) + N_{\text{total}} T ( A , B ) = i = 1 ∑ r ( r 2 1 + ϵ ij + O ( ϵ ij 3 ) ) ln ( 1 + r 2 ϵ ij ) + N total where:
N total = ∑ i , j ( N ( A i j ) + N ( B i j ) ) + O ( ∑ i , j ϵ i j 3 ) N_{\text{total}} = \sum_{i,j} \left( N(A_{ij}) + N(B_{ij}) \right) + O\left( \sum_{i,j} \epsilon_{ij}^3 \right) N total = i , j ∑ ( N ( A ij ) + N ( B ij ) ) + O ( i , j ∑ ϵ ij 3 ) The final form of the product of integer values is expressed as follows:
T ( A , B ) = ∑ i = 1 n E ( a i ⋅ log ( b i + 1 ) ) + O ( ∑ i , j ϵ i j 3 ) T(A, B) = \sum_{i=1}^{n} \mathcal{E}(a_i \cdot \log(b_i + 1)) + O\left( \sum_{i,j} \epsilon_{ij}^3 \right) T ( A , B ) = i = 1 ∑ n E ( a i ⋅ log ( b i + 1 )) + O ( i , j ∑ ϵ ij 3 )
Copy let t_product a b =
let epsilon i j = Random . float 1.0 ** 3.0 in
let log_term i = ( List . nth a i) *. log (( List . nth b i) +. 1.0 ) in
let eps_sum i =
let rec inner_sum j acc =
if j >= List . length a then acc
else inner_sum (j + 1 ) (acc +. epsilon i j)
in
inner_sum 0 0.0
in
let rec summation i acc_log acc_eps =
if i >= List . length a then acc_log +. acc_eps
else
let log_acc = log_term i in
let eps_acc = eps_sum i in
summation (i + 1 ) (acc_log +. log_acc) (acc_eps +. eps_acc)
in
summation 0 0.0 0.0
module HG = struct
type hg = { vertices : (float * float) list ; hyperedges : (float * float) list list }
let create () = { vertices = [] ; hyperedges = [] }
let add_vertex hg vertex = { hg with vertices = vertex :: hg . vertices }
let connect hg vertices = { hg with hyperedges = vertices :: hg . hyperedges }
let rec hyper_mul hg acc_enc acc_noise base_enc base_noise exp =
if exp <= 0.0 then (acc_enc , acc_noise , hg)
else
let hg = add_vertex hg (base_enc , base_noise) in
let acc_enc' , acc_noise' , hg =
if exp > 1.0 then
let new_acc_enc = acc_enc +. base_enc in
let new_acc_noise = acc_noise +. base_noise in
let hg = connect hg [ (base_enc , base_noise) ] in
(new_acc_enc , new_acc_noise , hg)
else
(acc_enc , acc_noise , hg)
in
let new_base_enc = base_enc +. base_enc in
let new_base_noise = base_noise +. base_noise in
hyper_mul hg acc_enc' acc_noise' new_base_enc new_base_noise (exp /. 2.0 )
end
let perform_multiplication a b key_pair =
let key_enc , key_noise = key_pair in
let hg_init = HG . create () in
let enc_a = List . nth a 0 *. key_enc in
let noise_a = List . nth b 0 *. key_noise in
let node_b_state = List . nth b 1 in
let new_enc_value , new_noise , _ = HG . hyper_mul hg_init enc_a noise_a enc_a noise_a node_b_state in
t_product a b +. new_enc_value +. new_noise
Logarithmic effects and aggregation of all elements
A logarithmic transformation is added to each element:
E ( a i ⋅ b i ) → E ( a i ⋅ log ( b i + 1 ) ) \mathcal{E}(a_i \cdot b_i) \rightarrow \mathcal{E}(a_i \cdot \log(b_i + 1)) E ( a i ⋅ b i ) → E ( a i ⋅ log ( b i + 1 )) After applying logarithmic effects to each element, all results are aggregated to obtain the final product of the vectors:
∑ i = 1 n E ( a i ⋅ log ( b i + 1 ) ) \sum_{i=1}^{n} \mathcal{E}(a_i \cdot \log(b_i + 1)) i = 1 ∑ n E ( a i ⋅ log ( b i + 1 )) This mechanism integrates all the results of operations on vector structures, resulting in the product of A A A and B B B , while preserving homomorphism.
Adding hypervertices and hyperedges
At each step of the multiplication E ( a i ⋅ log ( b i + 1 ) ) \mathcal{E}(a_i \cdot \log(b_i + 1)) E ( a i ⋅ log ( b i + 1 )) , a new vertex is added to the hypergraph with the corresponding noise and result;
After obtaining the product of the elements, a hyperedge is created, connecting the vertices that represent the result of the multiplication;
Each vertex is connected to other vertices through a hyperedge, which preserves the product result and the accumulated noise.
v i = E ( a i ⋅ log ( b i + 1 ) ) , ϵ i j = 1 r 2 + O ( ϵ i j 3 ) v_i = \mathcal{E}(a_i \cdot \log(b_i + 1)), \quad \epsilon_{ij} = \frac{1}{r^2} + O(\epsilon_{ij}^3) v i = E ( a i ⋅ log ( b i + 1 )) , ϵ ij = r 2 1 + O ( ϵ ij 3 ) e i j = E ( a i ⋅ b j ) + O ( ϵ i j 3 ) e_{ij} = \mathcal{E}(a_i \cdot b_j) + O(\epsilon_{ij}^3) e ij = E ( a i ⋅ b j ) + O ( ϵ ij 3 ) e i j = v i ⊗ v j e_{ij} = v_i \otimes v_j e ij = v i ⊗ v j
The cases of matrix multiplication and floating-point numbers are considered separately in other articles.