identity_manager.set_identity_password(&identity_id, "password123")?;identity_manager.change_identity_password(
&identity_id,
"oldPassword", // Required for security
"newPassword"
)?;identity_manager.remove_identity_password(
&identity_id,
"currentPassword" // Required for verification
)?;let validation = identity_manager.validate_identity_password(
&identity_id,
"password123"
)?;
if validation.valid {
// User authenticated
}let wallet_manager = &mut identity.wallet_manager;
wallet_manager.set_wallet_password(
&wallet_id,
"walletPass123"
)?;wallet_manager.change_wallet_password(
&wallet_id,
"oldPass",
"newPass"
)?;wallet_manager.remove_wallet_password(
&wallet_id,
"currentPass"
)?;let validation = wallet_manager.validate_wallet_password(
&wallet_id,
"walletPass123"
)?;
if validation.valid {
// Proceed with wallet operation
}if wallet_manager.wallet_has_password(&wallet_id) {
// Wallet is password-protected
}let protected = wallet_manager.list_password_protected_wallets();
for wallet_id in protected {
println!("Protected: {}", hex::encode(&wallet_id.0[..8]));
}| Type | Minimum Length | Can Change | Can Remove |
|---|---|---|---|
| DID Password | 8 characters | ✅ Yes | ✅ Yes |
| Wallet Password | 6 characters | ✅ Yes | ✅ Yes |
| Master Seed Phrase | 20 words | ❌ Never | ❌ Never |
// Seed phrase is provided during identity creation
let result = identity_manager.create_citizen_identity(...).await?;
// CRITICAL: Store this offline!
println!("Your 20-word seed phrase:");
println!("{}", result.master_seed_phrase.words.join(" "));// Import identity from seed phrase on new device
let identity_id = identity_manager.import_identity_from_phrase(
"word1 word2 word3 ... word20"
).await?;
// Set new password after recovery
identity_manager.set_identity_password(&identity_id, "newPass")?;✅ Write seed phrase on paper/metal
✅ Store in multiple secure offline locations
✅ Use strong, unique passwords (8+ characters)
✅ Change passwords if you suspect compromise
✅ Add wallet passwords to high-value wallets
❌ Store seed phrase digitally (no photos, no cloud)
❌ Share seed phrase with anyone
❌ Use same password for DID and wallets
❌ Forget to backup seed phrase
❌ Rely only on passwords (seed phrase is ultimate backup)
// Add extra password to savings wallet
wallet_manager.set_wallet_password(
&savings_wallet_id,
"savingsSecure123"
)?;// If you think password was compromised
identity_manager.change_identity_password(
&identity_id,
"oldCompromisedPass",
"newSecurePass456"
)?;// If device is fully secured, remove password
identity_manager.remove_identity_password(
&identity_id,
"currentPassword"
)?;// Validate wallet password before large transaction
let validation = wallet_manager.validate_wallet_password(
&wallet_id,
"walletPassword"
)?;
if validation.valid {
wallet_manager.transfer_between_wallets(
&wallet_id,
&destination_wallet,
10000, // Large amount
"Important transfer".to_string()
)?;
}use lib_identity::auth::PasswordError;
match identity_manager.set_identity_password(&id, "pass") {
Ok(_) => println!("Password set!"),
Err(PasswordError::IdentityNotImported) => {
println!("Must import identity first");
}
Err(PasswordError::WeakPassword) => {
println!("Password too weak (min 8 chars)");
}
Err(PasswordError::InvalidPassword) => {
println!("Wrong password provided");
}
Err(PasswordError::PasswordNotSet) => {
println!("No password to validate");
}
}| Feature | File Location |
|---|---|
| DID passwords | src/auth/password.rs |
| Wallet passwords | src/wallets/wallet_password.rs |
| Identity manager | src/identity/manager.rs |
| Wallet manager | src/wallets/manager_integration.rs |
For complete guide see: docs/PASSWORD_SECURITY_GUIDE.md