just use a seed phrase like in true peer to peer systems.
keet uses 24 words and is a p2p messenger app. wallets use the same approach.
any p2p social network could do it as well and they exist for a long time, longer than mastodon and the fediverse.
mastodon was initially released 2016
By that time ssb and dat and others existed already and so did wallets