Skip to main content
. 2023 May 14;23(10):4746. doi: 10.3390/s23104746
Algorithm 5 Variance algorithm for ciphertexts.
  • 1:

    Input N: the number of the household

  • 2:

    Input rowCount: the count of records per day of each household

  • 3:

    Input ciphertexts: the ciphertexts array transferred from the service provider

  • 4:

    Input evaluator: the object that performs homomorphic computations

  • 5:

    for index=1,2,,N do

  • 6:

          cciphertexts[index]

  • 7:

          ccopycopy(c)

  • 8:

          evaluator.sumEachElement(c)

  • 9:

          c.averageBy(rowCount)

  • 10:

        cevaluator.Multiply(c,1)

  • 11:

        cevaluator.Add(c,ccopy)

  • 12:

        cevaluator.Multiply(c,c)

  • 13:

        evaluator.sumEachElement(c)

  • 14:

        c.averageBy(rowCount)

  • 15:

    end for

  • 16:

    Output ciphertexts array back to the service provider