Textbooks say the one-way function is merely two primes...
Yes, that's the key part.
It turns out that if you have a number that's a product of two large primes, deducing which primes factor that number is quite difficult.
So, what we understand from this is that if you have $n = pq$, and you know $p$ and $q$, you can generate $n$, but if you have only $n$, it is hard to generate $p$ and $q$.
These are not keys by and of themselves - they're parts of a process used to find a key. Specifically, a number $e$ is chosen and then you need to find $de = 1 \mod (p-1)(q-1)$. I've covered the mathematics in detail here, but the essential part to understand is that it is difficult to compute $p-1$ or $q-1$ without $p$ and $q$, which you don't have if you have only $n$. Thus, if you know $e$, you have no way to get to $d$ (it's important to understand it isn't theoretically impossible. It's just very, very hard practically).
$e$ and $d$ form the key - $e$ is chosen and $d$ is usually computed, although not always by the mechanism I described.
...if ... the one-way function could be broken by a third party, then could they decrypt the message with a key generated by the other prime?
Yes. The message wouldn't be generated by another prime in the case of RSA, but if they could somehow undo the one-way function, then the cryptosystem is broken and all your messages would be readable.
Would it matter which prime was used?
There are two cases here:
- In the case of which primes are used for RSA - it does matter. They need to be big! At one time, the choice of prime did matter, for resistance against Pollard's p-1. However, it is now thought that for more advanced methods this is not the case.
- In the case of the keys (which may or may not be prime) - for RSA you can actually interchange the keys, which makes RSA a trapdoor permutation. However, this is unusual and many other one-way functions are just trapdoor functions - which means they don't have this property.
What i am wondering is what is the process whereby the primes behind the one-way function are converted into keys and is that process the same regardless of encryption used?
The $de = 1 \mod (p-1)(q-1)$ process is not the only way to relate $d$ to $e$. You can also use $\lambda(n)$, the Carmichael function, which is what happens in PKCS#1.
Other public key systems have different conversion functions, not all of which rely on the use of prime number factorisation. Common examples are the discrete logarithm problem and point multiplication over elliptic curves.
(You can use this script to render the Mathjax in this answer; it'll automatically render if this Q gets migrated).