# How to calculate inverse of an element using MPC and secret sharing

Suppose we have multiple parties $${P_i}$$ each holding a secret share $$(y_i,k_i)$$ of the secret $$(y,k)$$. How can we calculate the inverse value $$(y+k)^{-1}$$ using multiparty computation such that these secret shares are never revealed?

First, to simplify notation, note that computing $$(y+k)^{-1}$$ is equivalent to computing $$z^{-1}$$, where $$z=y+k$$, which can be locally computed by the parties. Furthermore, I assume that $$z \in \mathbb{F}_p$$ is a field element (e.g., integers mod $$p$$).
Now, to compute $$z^{-1} \in \mathbb{F}_p$$, each party can (locally) sample a random share of a value $$r \in \mathbb{F}_p \setminus \{0\}$$. Then, the parties reveal $$zr$$ to compute $$(zr)^{-1} \in \mathbb{F}_p$$, in the clear. Finally, the parties use their shares of $$r$$ to engage in a MPC protocol for multiplication to compute $$(zr)^{-1}\cdot r = z^{-1} \in \mathbb{F}_p$$. A similar protocol was described in Algorithm for computing modular inverse in MPC under a different context.