octra
TwitterDiscordTelegramChat [en]GitHub
  • Octra Developer Documentation
  • Technology
    • HFHE
      • Modular arithmetic over hypergraphs in HFHE
      • Subtraction in hypergraph space
        • Hypergraph stability after subtraction
        • Minimizing deviations in hypergraph matrices
      • Multiplication of integers
      • Integer division and range narrowing mechanics
      • HFHE Key Sharding
      • Starting vector generation
      • SBox module
      • Transformation mechanism
      • Noise basis determination
      • Noise assessment in ciphertext elements
    • Isolated Environments
  • Running a Node
    • Validators
Powered by GitBook
On this page
  • Logarithmic effects and aggregation of all elements
  • Adding hypervertices and hyperedges
Export as PDF
  1. Technology
  2. HFHE

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, AAA and BBB, shall be defined. They will be preliminarily transformed and processed through a transformation mechanism:

A=E(xA),B=E(xB)A = \mathcal{E}(x_A), \quad B = \mathcal{E}(x_B)A=E(xA​),B=E(xB​)

The form of the tensor product of these values will be defined as follows:

T(A,B)=A⊗BT(A, B) = A \otimes BT(A,B)=A⊗B

where:

T(A,B)ij=E(Aij)⋅E(Bij)T(A, B)_{ij} = \mathcal{E}(A_{ij}) \cdot \mathcal{E}(B_{ij})T(A,B)ij​=E(Aij​)⋅E(Bij​)

Now it is necessary to add cubic effects to the accumulation of noise for each element of the matrices:

N(Aij)=1r2+ϵij+O(ϵij3)N(A_{ij}) = \frac{1}{r^2} + \epsilon_{ij} + O\left( \epsilon_{ij}^3 \right)N(Aij​)=r21​+ϵij​+O(ϵij3​)

Now, for the result of the product, the noise will be defined as follows:

N(T(A,B))=∑i=1r(N(Aij)+N(Bij))+O(∑i,jϵij3)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(Aij​)+N(Bij​))+O(i,j∑​ϵij3​)

The normalization mechanism for row iii of matrix (Υ)(\Upsilon)(Υ), where all noise elements include cubic dependencies, is defined as follows:

ϵij=1r2+ϵij,j≠i\epsilon_{ij} = \frac{1}{r^2} + \epsilon_{ij}, \quad j \neq iϵij​=r21​+ϵij​,j=i

The estimate for the normalized row, taking cubic terms into account, is defined as follows:

fi(Υ)=∑j=1r(1r2+ϵij+O(ϵij3))ln⁡(1+r2ϵij)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})fi​(Υ)=j=1∑r​(r21​+ϵij​+O(ϵij3​))ln(1+r2ϵij​)

Ultimately, the noise for the product of the elements is defined as follows:

N(T(A,B))=ln⁡rr−δiln⁡(r−r2δi)+∑j≠iδijln⁡(r2δij)+O(∑i,jϵij3)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))=lnrr​−δi​ln(r−r2δi​)+j=i∑​δij​ln(r2δij​)+O(i,j∑​ϵij3​)

The accumulated noise now incorporates both a logarithmic component and cubic elements:

fi(Υ)≥ln⁡rr+δiln⁡δi+δiln⁡(rr−1)−δi+O(δi3)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)fi​(Υ)≥rlnr​+δi​lnδi​+δi​ln(r−1r​)−δi​+O(δi3​)

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=1r(1r2+ϵij+O(ϵij3))ln⁡(1+r2ϵij)+NtotalT(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​(r21​+ϵij​+O(ϵij3​))ln(1+r2ϵij​)+Ntotal​

where:

Ntotal=∑i,j(N(Aij)+N(Bij))+O(∑i,jϵij3)N_{\text{total}} = \sum_{i,j} \left( N(A_{ij}) + N(B_{ij}) \right) + O\left( \sum_{i,j} \epsilon_{ij}^3 \right)Ntotal​=i,j∑​(N(Aij​)+N(Bij​))+O(i,j∑​ϵij3​)

The final form of the product of integer values is expressed as follows:

T(A,B)=∑i=1nE(ai⋅log⁡(bi+1))+O(∑i,jϵij3)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(ai​⋅log(bi​+1))+O(i,j∑​ϵij3​)
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(ai⋅bi)→E(ai⋅log⁡(bi+1))\mathcal{E}(a_i \cdot b_i) \rightarrow \mathcal{E}(a_i \cdot \log(b_i + 1))E(ai​⋅bi​)→E(ai​⋅log(bi​+1))

After applying logarithmic effects to each element, all results are aggregated to obtain the final product of the vectors:

∑i=1nE(ai⋅log⁡(bi+1))\sum_{i=1}^{n} \mathcal{E}(a_i \cdot \log(b_i + 1))i=1∑n​E(ai​⋅log(bi​+1))

This mechanism integrates all the results of operations on vector structures, resulting in the product of AAA and BBB, while preserving homomorphism.

Adding hypervertices and hyperedges

  • At each step of the multiplication E(ai⋅log⁡(bi+1))\mathcal{E}(a_i \cdot \log(b_i + 1))E(ai​⋅log(bi​+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.

vi=E(ai⋅log⁡(bi+1)),ϵij=1r2+O(ϵij3)v_i = \mathcal{E}(a_i \cdot \log(b_i + 1)), \quad \epsilon_{ij} = \frac{1}{r^2} + O(\epsilon_{ij}^3)vi​=E(ai​⋅log(bi​+1)),ϵij​=r21​+O(ϵij3​)
eij=E(ai⋅bj)+O(ϵij3)e_{ij} = \mathcal{E}(a_i \cdot b_j) + O(\epsilon_{ij}^3)eij​=E(ai​⋅bj​)+O(ϵij3​)
eij=vi⊗vje_{ij} = v_i \otimes v_jeij​=vi​⊗vj​

The cases of matrix multiplication and floating-point numbers are considered separately in other articles.

PreviousMinimizing deviations in hypergraph matricesNextInteger division and range narrowing mechanics

Last updated 7 months ago