skills/manage-bap-backup/SKILL.md
This skill should be used when the user asks to "export BAP identity", "import BAP backup", "view BAP backup", "manage BAP backup", "backup BAP identity", or needs to work with BAP identity backup files using the bap CLI.
npx skillsauth add b-open-io/bsv-skills manage-bap-backupInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Export and import BAP identity backups using the bsv-bap library.
bun add bsv-bap @bsv/sdk
Contains everything needed to reconstruct all identities:
{
"rootPk": "L4vB5...", // Master key WIF (Type42) or xprv (BIP32)
"ids": "<encrypted string>", // All identity metadata, encrypted with master
"label": "optional",
"createdAt": "2026-03-13T..."
}
The encrypted ids blob contains: name, description, identityKey (BAP ID), identityAttributes, and paths.
import { BAP } from "bsv-bap";
const bap = new BAP({ rootPk: storedWif });
bap.importIds(encryptedIds);
const backup = bap.exportForBackup("My Identity");
// { rootPk: "L1SJ...", ids: "QklFMQ...", createdAt: "..." }
import { writeFileSync } from "node:fs";
writeFileSync("backup.json", JSON.stringify(backup, null, 2));
import { BAP } from "bsv-bap";
import { readFileSync } from "node:fs";
const backup = JSON.parse(readFileSync("backup.json", "utf-8"));
const bap = new BAP({ rootPk: backup.rootPk });
if (backup.ids) {
bap.importIds(backup.ids);
}
const idKeys = bap.listIds();
const identity = bap.getId(idKeys[0]);
console.log(identity.idName, identity.getIdentityKey());
const idKeys = bap.listIds();
for (const key of idKeys) {
const identity = bap.getId(key);
console.log(`${identity.idName}: ${key}`);
console.log(` Root: ${identity.rootAddress}`);
console.log(` Current: ${identity.getCurrentAddress()}`);
}
For encrypted backup files using AES-256-GCM, use the bitcoin-backup CLI:
bun add -g bitcoin-backup
# Encrypt a backup
bbackup enc backup.json -p "password" -o identity.bep
# Decrypt a backup
bbackup dec identity.bep -p "password" -o decrypted.json
See encrypt-decrypt-backup skill for full bitcoin-backup reference.
For quick operations, use the bap CLI:
bun add -g bsv-bap
bap export # Export identity JSON to stdout
bap export > backup.json
bap import backup.json # Import from file
bap info # View current identity
On macOS arm64, the BAP CLI can protect the master key with the Secure Enclave via @1sat/vault. When Touch ID protection is enabled (bap touchid enable), the rootPk is encrypted with a hardware-bound P-256 key and removed from disk. All backup/export operations that need the master key will trigger Touch ID. Use bap touchid status to check protection state. Set BAP_NO_TOUCHID=1 for headless/CI environments.
BAP supports two backup levels with different capabilities:
| Backup Type | Contains | Can Derive New IDs? | Use Case | |-------------|----------|-------------------|----------| | Master | rootPk (Type42) or xprv (legacy) + ids | Yes | Full identity management, key rotation | | Member | Single derived WIF + encrypted identity data | No | Delegated access, agent auth, app-scoped signing |
exportMemberBackup() produces a MemberIdentity with:
derivedPrivateKey — the stable member key WIF (from rootPath, never changes)address — the current signing address (changes on rotation)counter — rotation counter for the signing key derivationidentityKey — the BAP identity keyThe member key is the stable identity anchor for authentication:
import { getStableMemberWif, getStableMemberPubkey } from "./bap/utils";
// These stay fixed even after key rotation
const wif = getStableMemberWif(identity); // For auth token signing
const pubkey = getStableMemberPubkey(identity); // For identity resolution
Auth tokens (bitcoin-auth) are signed with the stable member WIF, not the rotating signing key. This ensures identity continuity across rotations.
create-bap-identity - Create new BAP identitiesencrypt-decrypt-backup - bitcoin-backup CLI for .bep fileskey-derivation - Type42 and BRC-43 key derivationBAP identities can be used for OAuth authentication with Sigma Identity. See @sigma-auth/better-auth-plugin for integration patterns.
development
This skill should be used when the user asks to integrate "Yours Wallet", "connect a BSV wallet", use "BRC-100", "pay with BSV wallet", add "wallet checkout in a web app", use "yours-wallet-provider", build a "pay with Yours Wallet" button, access "window.CWI", or connect a React app to a BRC-100 wallet.
development
This skill should be used when the user asks to "send BSV", "transfer satoshis", "create payment transaction", "send from WIF", "P2PKH transaction", or needs to build, sign, and broadcast P2PKH transactions from a WIF private key using @bsv/sdk.
development
This skill should be used when the user asks to "encrypt message with BSV key", "decrypt with private key", "ECDH encryption", "AES-256-GCM BSV", "EncryptedMessage", "BRC-2 encryption", or needs to encrypt/decrypt data using BSV keys and @bsv/sdk.
tools
This skill should be used when the user asks to "implement BRC-100 wallet", "use wallet-toolbox", "TypeScript BSV wallet", "BRC-100 implementation", "desktop wallet", "Electron wallet", "browser wallet", "IndexedDB wallet storage", "wallet actions", "wallet baskets", "UTXO management", "createAction", "listOutputs", "wallet certificates", "WalletClient", "noSend", "BEEF payment", "pay-beef", "send BEEF", "Transaction.fromBEEF", "toHexBEEF", or needs guidance on building conforming wallets using @bsv/wallet-toolbox or connecting to a user's BRC-100 wallet via WalletClient.