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
Export as PDF
  1. Technology
  2. HFHE

Starting vector generation

Starting Vector serves as the starting point for GSM (Global State Machine) initialization and also acts as the basis for key generation.

PreviousHFHE Key ShardingNextSBox module

Last updated 1 year ago

Generation of SV\textbf{SV}SV proceeds by summing products of field elements {pij}\{p_{ij}\}{pij​} with coefficients aija_{ij}aij​, after transformation via functions ϕi\phi_iϕi​:

SVi=∑j=1miaij⋅ϕi(pij)\textbf{SV}_i = \sum_{j=1}^{m_i} a_{ij} \cdot \phi_i(p_{ij})SVi​=j=1∑mi​​aij​⋅ϕi​(pij​)

This process assembles SV\textbf{SV}SV, essential for cryptographic key generation.

Below is a reference test implementation of the Starting Vector generation.

module type FIELD = sig
  type t
  val zero : t
  val one : t
  val add : t -> t -> t
  val mul : t -> t -> t
  val sub : t -> t -> t
  val inv : t -> t
  val rand : unit -> t
end

module PrimeField : FIELD with type t = Z.t = struct
  type t = Z.t
  let prime = Z.(nextprime (one lsl 1024))
  let zero = Z.zero
  let one = Z.one
  let add = Z.add
  let mul = Z.mul
  let sub = Z.sub
  let inv x = Z.invert x prime
  let rand () =
    let bits = Z.numbits prime in
    let rec loop () =
      let r = Z.(random_bits bits mod prime) in
      if Z.(r >= prime) then loop () else r
    in
    loop ()
end

module Vector (F : FIELD) = struct
  type t = F.t list

  let init n : t = List.init n (fun _ -> F.rand ())
  let map2 f a b = List.map2 f a b
  let reduce = List.fold_left F.add F.zero
end

module StartingVector = struct
  module V = Vector(PrimeField)

  let phi a p = 
    let open PrimeField in
    let r = rand () in
    mul (add (mul a a) r) (add a one)

  let generate n : PrimeField.t list =
    let a = V.init n in
    let p = V.init n in
    let phi_applied = List.map2 phi a p in
    List.map V.reduce (List.map (fun x -> [x]) phi_applied)
end