Signup
Before you can store data on a homeserver, you need to sign up with that homeserver using your keypair. In Pubky, you first create a PubkySigner
from your keypair, then use it to sign up.
async fn signup() -> pubky::Result<()> {
let pubky = Pubky::new()?;
// Generate a new keypair for the user
let keypair = Keypair::random();
let signer = pubky.signer(keypair);
// The homeserver's public key (as a string)
let homeserver = PublicKey::try_from("o4dksfbqk85ogzdb5osziw6befigbuxmuxkuxq8434q89uj56uyy")
.expect("Valid homeserver public key");
// Sign up to the homeserver
let _session = signer.signup(&homeserver, None).await?;
println!("Successfully signed up to homeserver");
Ok(())
}
The signup process:
- Create a
Pubky
instance - Generate or use an existing keypair
- Create a
PubkySigner
from your keypair usingpubky.signer(keypair)
- Identify the homeserver you want to use (by its public key)
- Call
signup
on the signer with the homeserver's public key - Optionally provide a signup code if the homeserver requires one
After successful signup, your public key will be associated with the homeserver and published via PKARR. The signup returns a PubkySession
which you can use for authenticated operations.