Goldschmidt division initialization using CKKS

297 views Asked by At

I recently found out that I don't really understand how to make the initialization for goldschmidt division denoted in the following article: https://eprint.iacr.org/2021/914.pdf
It isn't really explained how to find the initial value it is just stated that we want the following relation to be upheld: enter image description here

I have the following python code:

def gold_div(a,b):
    r = 1/b     
    for i in range(0,10):
        a = r*a
        b = r*b
        r = 2 + -1*b
    return a

which works but dividing in a function which is is supposed to be the division algorithm doesn't make much sense. I was thinking of using his source which he references (http://www.informatik.uni-trier.de/Reports/TR-08-2004/rnc6_12_markstein.pdf ) but I get confused about what they are doing.

The picture below illustrates what they are doing: enter image description here

I understand that sgn is a function which basically just finds out if b is negative or positive but I don't really see how I can use their Y0 since it seems to substitute the unknown Y0 with the unknown n (thereby we have 2 unknowns). They also seem to just jump quickly over it since we normally just use a lookup table which I again don't believe we can use since we are using CKKS.

The only thing I can see which might would work is by using the fact that since we are dividing then we can assume that b isn't 0 and thereby we can rewrite the initial expression for y0 to 3/4b_0<=Y_0<3/2b_0.

1

There are 1 answers

0
Henrik On

I found an answer I can solve the problem by using Newton-rahpson the following way:

import numpy as np
def newton_method(a, number_iters = 70):
number = np.finfo(float).eps # number to get inverse of
for i in range(number_iters): # iteration number
    number = number*(2-a*number) # update
return number

It uses epsilon because it helps using a very small number so it won't go towards infinity.