# AugPake implementation Doubt K computation

try to implement the AugPake protocol in java using BigInteger.

I am having some difficulty computing $K=Y^z \mod p$ because $z$ is always $0$, for $z={1\over x+(w*r)} \mod q$. Being a ratio between $1$ and a very large number $z$ will be always zero using the BigInteger.

Can help me to understand how to compute $z$? Maybe I misunderstood some of the document.

Thanks for your reponse.

To compute Z i use the extended Euclidean algorithm: ax + qy = gdc(a,b)

Thanks a lot

• Please note that the BigInteger.modInverse function, as most BigInteger-methods, does not run with constant time, so your implementation will be vulnerable to timing attacks. – VincBreaker Jan 15 '18 at 16:51

## 1 Answer

This is not ordinary real-valued division.

The computation you are looking at is done in the field $\mathbb F_q$ instead of $\mathbb R$, that is $1/x$ actually is the modular multiplicative inverse of $x\bmod q$.