Confusion with how encryption is carried out in private torrents in transmission-gtk or qbittorrent

I read this in the qbittorrent forum, what I have understood is that you need a passkey to join the swarm, after this how does encryption happen? I have seen peers in ubuntu 24.04 amd64 iso torrent where some peers have the “E” flag which when hovered on shows “encrypted”. So, is encryption exclusive in private trackers with say the passkey being your private key and the tracker having your public key, then you doing DHKE with the swarm and getting the same secret and encrypting with that for your peers? But this arrangement would fail on a public tracker as no passkeys are required, so how is this achieved?