soft3/mudra/examples/migrate.rs

// ---
// tags: mudra, rust, example
// crystal-type: source
// crystal-domain: comp
// ---
//! End-to-end spacepussy migration bridge: a mnemonic โ†’ its real `pussy1โ€ฆ`
//! account โ†’ a native neuron โ†’ a signed, verified claim binding the two.
//!
//!   cargo run --example migrate

fn main() {
    // A holder's wallet phrase (canonical BIP-39 test vector โ€” never use for value).
    let mnemonic =
        "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";

    // 1. seed โ†’ the exact secp256k1 key that controls their spacepussy account
    let key = mudra::seed::cosmos_key(mnemonic, "").expect("derive key");
    let pubkey = mudra::cosmos::compressed(key.verifying_key());
    let address = mudra::cosmos::address(&pubkey, mudra::cosmos::PUSSY).expect("address");

    // 2. the deterministic native neuron this account maps to: Hemera(pubkey)
    let neuron = mudra::claim::neuron_of(&pubkey);

    // 3. the holder signs a claim binding the legacy address โ†’ the native neuron
    let claim = mudra::claim::create(&key, mudra::cosmos::PUSSY, neuron).expect("claim");

    // 4. anyone verifies it โ€” no trusted party, just the signature and the address
    let ok = mudra::claim::verify(&claim, mudra::cosmos::PUSSY);

    println!("spacepussy account : {address}");
    println!("pubkey (compressed): {}", hex(&pubkey));
    println!("native neuron      : {}", hex(&neuron));
    println!("signature          : {}โ€ฆ", &hex(&claim.signature)[..24]);
    println!("claim verifies     : {ok}");
    assert!(ok);
}

fn hex(bytes: &[u8]) -> String {
    bytes.iter().map(|b| format!("{b:02x}")).collect()
}

Graph