# Deterministic generation of RSA keys for IPFS / OrbitDB [duplicate]

I am in the process of working on a decentralized application using IPFS and OrbitDB. IPFS uses 2048 bit RSA keys for the Node runtime peer-id and secp256k1 for read/write access in OrbitDB. For secp256k1 there exists a method for deterministically generating keys (bip39 mnemonic phrase).

Let's say I take an existing RSA implementation and replace the RNG with a seeded RNG which is seeded with the mnemonic phrase from above. Assuming I didn't roll my own implementation, aside from swapping out the RNG, how secure would this be? Are there any obvious flaws with this approach?

• Deterministic key generation is insecure. If somehow attackers steel the seed, they will recovery all of the previous keys and if they stored all of the previous communication, done! – kelalaka Mar 11 '19 at 19:18
• Well that is true but a rather large amount of the cryptocurrency community have decided that the seed is secure enough to store hundreds of millions of dollars or more worth of cryptocurrencies. Obviously the fact that everyone does a thing doesn't make them right or it right but considering it has been heavily scrutinized without any security issues found means I trust them. I'm not concerned here with someone stealing the seed phrase but rather any other obvious flaws(like not enough entropy in the seed, etc) that could lead to an attacker determining the seed or private key – NomadCrypto Mar 11 '19 at 20:10
• You can do this, and there's no problem with the security as long as the seed is chosen uniformly at random from a sufficiently large space of, say, $2^{256}$ possibilities. Some past questions on the subject: crypto.stackexchange.com/q/1662 crypto.stackexchange.com/q/24514 crypto.stackexchange.com/q/58547 – Squeamish Ossifrage Mar 11 '19 at 20:50
• crypto.stackexchange.com/a/58553 goes into some details of how you can turn a series of 256 fair coin flips into an RSA key. Substitute a seed phrase—which you let a machine choose uniformly at random from a space of ${>}2^{256}$ possibilities, right?—for the coin flips and the result is the same. – Squeamish Ossifrage Mar 11 '19 at 20:52
• In brief: you just use the seed phrase as a seed for the PRNG used in any old RSA key generation algorithm, and just make sure to use the same RSA key generation algorithm each time. Of course, RSA key generation is a lot more expensive than elliptic curve key generation, which is why people don't usually do this! – Squeamish Ossifrage Mar 11 '19 at 22:16