22//!
33//! Run with: `cargo run -p heartwood-core --example basic_usage`
44
5- fn main ( ) -> Result < ( ) , heartwood_core :: HeartwoodError > {
5+ fn main ( ) -> Result < ( ) , nsec_tree_rs :: HeartwoodError > {
66 // --- 1. Create a tree root from a BIP-39 mnemonic ---
77 //
88 // The mnemonic is the master secret. Everything derives from it.
@@ -11,52 +11,52 @@ fn main() -> Result<(), heartwood_core::HeartwoodError> {
1111 let mnemonic = "abandon abandon abandon abandon abandon abandon \
1212 abandon abandon abandon abandon abandon about";
1313
14- let root = heartwood_core :: from_mnemonic ( mnemonic, None ) ?;
14+ let root = nsec_tree_rs :: from_mnemonic ( mnemonic, None ) ?;
1515 println ! ( "Master pubkey: {}" , root. master_pubkey) ;
1616
1717 // --- 2. Derive child identities by purpose and index ---
1818 //
1919 // Each (purpose, index) pair produces a deterministic, unique keypair.
2020 // Different purposes create unlinkable identity sets.
21- let social = heartwood_core :: derive ( & root, "social" , 0 ) ?;
21+ let social = nsec_tree_rs :: derive ( & root, "social" , 0 ) ?;
2222 println ! ( "\n Social identity:" ) ;
2323 println ! ( " npub: {}" , social. npub) ;
2424 println ! ( " purpose: {}, index: {}" , social. purpose, social. index) ;
2525
26- let commerce = heartwood_core :: derive ( & root, "commerce" , 0 ) ?;
26+ let commerce = nsec_tree_rs :: derive ( & root, "commerce" , 0 ) ?;
2727 println ! ( "\n Commerce identity:" ) ;
2828 println ! ( " npub: {}" , commerce. npub) ;
2929
3030 // Same purpose + different index = different identity, same category
31- let social_alt = heartwood_core :: derive ( & root, "social" , 1 ) ?;
31+ let social_alt = nsec_tree_rs :: derive ( & root, "social" , 1 ) ?;
3232 assert_ne ! ( social. npub, social_alt. npub) ;
3333 println ! ( "\n Social alt (index 1): {}" , social_alt. npub) ;
3434
3535 // --- 3. Named personas ---
3636 //
3737 // Personas are a convenience wrapper: derive_persona("work") is
3838 // equivalent to derive("nostr:persona:work", 0).
39- let work = heartwood_core :: derive_persona ( & root, "work" , None ) ?;
39+ let work = nsec_tree_rs :: derive_persona ( & root, "work" , None ) ?;
4040 println ! ( "\n Work persona: {}" , work. identity. npub) ;
4141
4242 // Sub-identities from a persona (two-level hierarchy)
43- let work_dms = heartwood_core :: derive_from_persona ( & work, "dms" , None ) ?;
43+ let work_dms = nsec_tree_rs :: derive_from_persona ( & work, "dms" , None ) ?;
4444 println ! ( " Work DMs sub-identity: {}" , work_dms. npub) ;
4545
4646 // --- 4. Linkage proofs ---
4747 //
4848 // Prove that a child key belongs to the master, without revealing
4949 // the derivation path (blind) or with it (full).
50- let blind_proof = heartwood_core :: create_blind_proof ( & root, & social) ?;
51- assert ! ( heartwood_core :: verify_proof( & blind_proof) ?) ;
50+ let blind_proof = nsec_tree_rs :: create_blind_proof ( & root, & social) ?;
51+ assert ! ( nsec_tree_rs :: verify_proof( & blind_proof) ?) ;
5252 println ! (
5353 "\n Blind proof verified: master {} owns child {}" ,
5454 & blind_proof. master_pubkey[ ..12 ] ,
5555 & blind_proof. child_pubkey[ ..12 ]
5656 ) ;
5757
58- let full_proof = heartwood_core :: create_full_proof ( & root, & social) ?;
59- assert ! ( heartwood_core :: verify_proof( & full_proof) ?) ;
58+ let full_proof = nsec_tree_rs :: create_full_proof ( & root, & social) ?;
59+ assert ! ( nsec_tree_rs :: verify_proof( & full_proof) ?) ;
6060 println ! (
6161 "Full proof: purpose={}, index={}" ,
6262 full_proof. purpose. as_deref( ) . unwrap_or( "?" ) ,
@@ -67,7 +67,7 @@ fn main() -> Result<(), heartwood_core::HeartwoodError> {
6767 //
6868 // Scan a set of purposes to rediscover all derived identities.
6969 // Useful after restoring from mnemonic backup.
70- let found = heartwood_core :: recover (
70+ let found = nsec_tree_rs :: recover (
7171 & root,
7272 & [ "social" . to_string ( ) , "commerce" . to_string ( ) ] ,
7373 None , // default scan range (20 indices per purpose)
0 commit comments