Search code examples
ipfs

Why is IPFS generating an RSA key pair when initializing a node?


When initializing an ipfs node, ipfs seems to generate an RSA key pair as well:

$ jsipfs init
  initializing ipfs node at /Users/pascalprecht/.jsipfs
  generating 2048-bit RSA keypair...done
  peer identity: QmYDkVX6kUFrn8FKiDKrFqhrkbr4Ax1nxxvgJfT5C6feXv
  to get started, enter:

     jsipfs files cat /ipfs/QmfGBRT6BbWJd7yUc2uYdaUZJBbnEFvTqehPFoSMQ6wgdr/readme

While I'm aware that asymetric cryptography is one of the key building blocks when it comes to security and integrity, I'm still wondering why IPFS generates a key pair on node initialization and also, where and when it's used.


Solution

  • IPFS generates a RSA keypair for Identity. It is what gives your node a unique Id that only it can use (as long as the Private Key doesn't get leaked).

    It gets created and managed through this module -- https://github.com/libp2p/js-peer-id