I'm trying to factor $n = pq$ where $p, q$ are large prime numbers with an oracle that returns a random sq. root.
My attempt after looking at this answer
I pick $a \in Z_n$ and run oracle on $a^2 \mod n$ to get $z$ s.t $z^2 \equiv a^2$
Now clearly, $n | z^2 - a^2$ which implies $n|z - a $ or $n| z + a$.
So then if $z$ is not a trivial sq. root (i.e $z \not\equiv \pm a)$ then I can simply get a factor by computing $gcd(z - a, n)$
I've 3 questions about this:
1) Can't we do it by computing $gcd(z + a, n)$ as well ?
2) Does $gcd(z - a, n)$ always return the smallest of $p, q$ ?
3) Moreover, can $z + a$ be anything? For example, I wanted to verify the method so I tried to factor $n = 14 = 7.2$ by computing sq. roots of $a^2 \equiv 4$ which are $12$ and $2$.
Now, for $z = 12$ and $a = 2, z + a = 14 \equiv 0 \mod 14$. Was that just a coincidence ?
Answers: